Skip to content

Commit 2a965d1

Browse files
Al Viroidryomov
authored andcommitted
ceph: get rid of passing callbacks in __dentry_leases_walk()
__dentry_leases_walk() gets a callback and calls it for a bunch of denties; there are exactly two callers and we already have a flag telling them apart - lwc->dir_lease. Seeing that indirect calls are costly these days, let's get rid of the callback and just call the right function directly. Has a side benefit of saner signatures... [ xiubli: a minor fix in the commit title ] Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Reviewed-by: Xiubo Li <xiubli@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent f6fb21b commit 2a965d1

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

fs/ceph/dir.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,10 +1593,12 @@ struct ceph_lease_walk_control {
15931593
unsigned long dir_lease_ttl;
15941594
};
15951595

1596+
static int __dir_lease_check(const struct dentry *, struct ceph_lease_walk_control *);
1597+
static int __dentry_lease_check(const struct dentry *);
1598+
15961599
static unsigned long
15971600
__dentry_leases_walk(struct ceph_mds_client *mdsc,
1598-
struct ceph_lease_walk_control *lwc,
1599-
int (*check)(struct dentry*, void*))
1601+
struct ceph_lease_walk_control *lwc)
16001602
{
16011603
struct ceph_dentry_info *di, *tmp;
16021604
struct dentry *dentry, *last = NULL;
@@ -1624,7 +1626,10 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
16241626
goto next;
16251627
}
16261628

1627-
ret = check(dentry, lwc);
1629+
if (lwc->dir_lease)
1630+
ret = __dir_lease_check(dentry, lwc);
1631+
else
1632+
ret = __dentry_lease_check(dentry);
16281633
if (ret & TOUCH) {
16291634
/* move it into tail of dir lease list */
16301635
__dentry_dir_lease_touch(mdsc, di);
@@ -1681,7 +1686,7 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
16811686
return freed;
16821687
}
16831688

1684-
static int __dentry_lease_check(struct dentry *dentry, void *arg)
1689+
static int __dentry_lease_check(const struct dentry *dentry)
16851690
{
16861691
struct ceph_dentry_info *di = ceph_dentry(dentry);
16871692
int ret;
@@ -1696,9 +1701,9 @@ static int __dentry_lease_check(struct dentry *dentry, void *arg)
16961701
return DELETE;
16971702
}
16981703

1699-
static int __dir_lease_check(struct dentry *dentry, void *arg)
1704+
static int __dir_lease_check(const struct dentry *dentry,
1705+
struct ceph_lease_walk_control *lwc)
17001706
{
1701-
struct ceph_lease_walk_control *lwc = arg;
17021707
struct ceph_dentry_info *di = ceph_dentry(dentry);
17031708

17041709
int ret = __dir_lease_try_check(dentry);
@@ -1737,7 +1742,7 @@ int ceph_trim_dentries(struct ceph_mds_client *mdsc)
17371742

17381743
lwc.dir_lease = false;
17391744
lwc.nr_to_scan = CEPH_CAPS_PER_RELEASE * 2;
1740-
freed = __dentry_leases_walk(mdsc, &lwc, __dentry_lease_check);
1745+
freed = __dentry_leases_walk(mdsc, &lwc);
17411746
if (!lwc.nr_to_scan) /* more invalid leases */
17421747
return -EAGAIN;
17431748

@@ -1747,7 +1752,7 @@ int ceph_trim_dentries(struct ceph_mds_client *mdsc)
17471752
lwc.dir_lease = true;
17481753
lwc.expire_dir_lease = freed < count;
17491754
lwc.dir_lease_ttl = mdsc->fsc->mount_options->caps_wanted_delay_max * HZ;
1750-
freed +=__dentry_leases_walk(mdsc, &lwc, __dir_lease_check);
1755+
freed +=__dentry_leases_walk(mdsc, &lwc);
17511756
if (!lwc.nr_to_scan) /* more to check */
17521757
return -EAGAIN;
17531758

0 commit comments

Comments
 (0)