CEPH-Devel archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>, ceph-devel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [RFC][PATCH] get rid of passing callbacks to ceph __dentry_leases_walk()
Date: Mon, 30 Oct 2023 08:18:33 -0400	[thread overview]
Message-ID: <5cc3b0c8cf428c74c88ae87c6c5556561f40cdaa.camel@kernel.org> (raw)
In-Reply-To: <20231029204635.GV800259@ZenIV>

On Sun, 2023-10-29 at 20:46 +0000, Al Viro wrote:
> __dentry_leases_walk() is 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...
> 
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index 854cbdd66661..30b06d171a40 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -1550,10 +1550,12 @@ struct ceph_lease_walk_control {
>  	unsigned long dir_lease_ttl;
>  };
>  
> +static int __dir_lease_check(const struct dentry *, struct ceph_lease_walk_control *);
> +static int __dentry_lease_check(const struct dentry *);
> +
>  static unsigned long
>  __dentry_leases_walk(struct ceph_mds_client *mdsc,
> -		     struct ceph_lease_walk_control *lwc,
> -		     int (*check)(struct dentry*, void*))
> +		     struct ceph_lease_walk_control *lwc)
>  {
>  	struct ceph_dentry_info *di, *tmp;
>  	struct dentry *dentry, *last = NULL;
> @@ -1581,7 +1583,10 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
>  			goto next;
>  		}
>  
> -		ret = check(dentry, lwc);
> +		if (lwc->dir_lease)
> +			ret = __dir_lease_check(dentry, lwc);
> +		else
> +			ret = __dentry_lease_check(dentry);
>  		if (ret & TOUCH) {
>  			/* move it into tail of dir lease list */
>  			__dentry_dir_lease_touch(mdsc, di);
> @@ -1638,7 +1643,7 @@ __dentry_leases_walk(struct ceph_mds_client *mdsc,
>  	return freed;
>  }
>  
> -static int __dentry_lease_check(struct dentry *dentry, void *arg)
> +static int __dentry_lease_check(const struct dentry *dentry)
>  {
>  	struct ceph_dentry_info *di = ceph_dentry(dentry);
>  	int ret;
> @@ -1653,9 +1658,9 @@ static int __dentry_lease_check(struct dentry *dentry, void *arg)
>  	return DELETE;
>  }
>  
> -static int __dir_lease_check(struct dentry *dentry, void *arg)
> +static int __dir_lease_check(const struct dentry *dentry,
> +			     struct ceph_lease_walk_control *lwc)
>  {
> -	struct ceph_lease_walk_control *lwc = arg;
>  	struct ceph_dentry_info *di = ceph_dentry(dentry);
>  
>  	int ret = __dir_lease_try_check(dentry);
> @@ -1694,7 +1699,7 @@ int ceph_trim_dentries(struct ceph_mds_client *mdsc)
>  
>  	lwc.dir_lease = false;
>  	lwc.nr_to_scan  = CEPH_CAPS_PER_RELEASE * 2;
> -	freed = __dentry_leases_walk(mdsc, &lwc, __dentry_lease_check);
> +	freed = __dentry_leases_walk(mdsc, &lwc);
>  	if (!lwc.nr_to_scan) /* more invalid leases */
>  		return -EAGAIN;
>  
> @@ -1704,7 +1709,7 @@ int ceph_trim_dentries(struct ceph_mds_client *mdsc)
>  	lwc.dir_lease = true;
>  	lwc.expire_dir_lease = freed < count;
>  	lwc.dir_lease_ttl = mdsc->fsc->mount_options->caps_wanted_delay_max * HZ;
> -	freed +=__dentry_leases_walk(mdsc, &lwc, __dir_lease_check);
> +	freed +=__dentry_leases_walk(mdsc, &lwc);
>  	if (!lwc.nr_to_scan) /* more to check */
>  		return -EAGAIN;
>  
> 

Nice cleanup.

Reviewed-by: Jeff Layton <jlayton@kernel.org>

      reply	other threads:[~2023-10-30 12:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-29 20:46 [RFC][PATCH] get rid of passing callbacks to ceph __dentry_leases_walk() Al Viro
2023-10-30 12:18 ` Jeff Layton [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5cc3b0c8cf428c74c88ae87c6c5556561f40cdaa.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).