CEPH filesystem development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: ceph-devel@vger.kernel.org
Cc: pdonnell@redhat.com, Ilya Dryomov <idryomov@gmail.com>
Subject: Re: [PATCH] ceph: ensure we have Fs caps when fetching dir link count
Date: Tue, 10 Nov 2020 10:38:18 -0500	[thread overview]
Message-ID: <c2497a831c8c28b7f5acdc2bf5aee9812b6e5ce1.camel@kernel.org> (raw)
In-Reply-To: <20201110120302.13992-1-jlayton@kernel.org>

On Tue, 2020-11-10 at 07:03 -0500, Jeff Layton wrote:
> The link count for a directory is defined as inode->i_subdirs + 2,
> (for "." and ".."). i_subdirs is only populated when Fs caps are held.
> Ensure we grab Fs caps when fetching the link count for a directory.
> 
> URL: https://tracker.ceph.com/issues/48125
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/ceph/inode.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 7c22bc2ea076..9ba15ca6b010 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2343,15 +2343,22 @@ int ceph_permission(struct inode *inode, int mask)
>  }
>  
> 
> 
> 
>  /* Craft a mask of needed caps given a set of requested statx attrs. */
> -static int statx_to_caps(u32 want)
> +static int statx_to_caps(u32 want, umode_t mode)
>  {
>  	int mask = 0;
>  
> 
> 
> 
>  	if (want & (STATX_MODE|STATX_UID|STATX_GID|STATX_CTIME|STATX_BTIME))
>  		mask |= CEPH_CAP_AUTH_SHARED;
>  
> 
> 
> 
> -	if (want & (STATX_NLINK|STATX_CTIME))
> +	if (want & (STATX_NLINK|STATX_CTIME)) {
>  		mask |= CEPH_CAP_LINK_SHARED;
> +		/*
> +		 * The link count for directories depends on inode->i_subdirs,
> +		 * and that is only updated when Fs caps are held.
> +		 */
> +		if (S_ISDIR(mode))
> +			mask |= CEPH_CAP_FILE_SHARED;
> +	}

I think I'm going to make a small change here and make this not set the
Ls bit on directories. There really is no need for it since only care
about i_subdirs, and that might prevent having to do a synchronous call
to the MDS.

>  
> 
> 
> 
>  	if (want & (STATX_ATIME|STATX_MTIME|STATX_CTIME|STATX_SIZE|
>  		    STATX_BLOCKS))
> @@ -2377,7 +2384,7 @@ int ceph_getattr(const struct path *path, struct kstat *stat,
>  
> 
> 
> 
>  	/* Skip the getattr altogether if we're asked not to sync */
>  	if (!(flags & AT_STATX_DONT_SYNC)) {
> -		err = ceph_do_getattr(inode, statx_to_caps(request_mask),
> +		err = ceph_do_getattr(inode, statx_to_caps(request_mask, inode->i_mode),
>  				      flags & AT_STATX_FORCE_SYNC);
>  		if (err)
>  			return err;

-- 
Jeff Layton <jlayton@kernel.org>


      reply	other threads:[~2020-11-10 15:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 12:03 [PATCH] ceph: ensure we have Fs caps when fetching dir link count Jeff Layton
2020-11-10 15:38 ` 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=c2497a831c8c28b7f5acdc2bf5aee9812b6e5ce1.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=ceph-devel@vger.kernel.org \
    --cc=idryomov@gmail.com \
    --cc=pdonnell@redhat.com \
    /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