Commit 04fabb11 authored by Jeff Layton's avatar Jeff Layton Committed by Ilya Dryomov

ceph: ensure we have Fs caps when fetching dir link count

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.

[ idryomov: break unnecessarily long line ]

URL: https://tracker.ceph.com/issues/48125Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent 8ba3b8c7
...@@ -2340,15 +2340,23 @@ int ceph_permission(struct inode *inode, int mask) ...@@ -2340,15 +2340,23 @@ int ceph_permission(struct inode *inode, int mask)
} }
/* Craft a mask of needed caps given a set of requested statx attrs. */ /* 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; int mask = 0;
if (want & (STATX_MODE|STATX_UID|STATX_GID|STATX_CTIME|STATX_BTIME)) if (want & (STATX_MODE|STATX_UID|STATX_GID|STATX_CTIME|STATX_BTIME))
mask |= CEPH_CAP_AUTH_SHARED; 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;
else
mask |= CEPH_CAP_LINK_SHARED;
}
if (want & (STATX_ATIME|STATX_MTIME|STATX_CTIME|STATX_SIZE| if (want & (STATX_ATIME|STATX_MTIME|STATX_CTIME|STATX_SIZE|
STATX_BLOCKS)) STATX_BLOCKS))
...@@ -2374,8 +2382,9 @@ int ceph_getattr(const struct path *path, struct kstat *stat, ...@@ -2374,8 +2382,9 @@ int ceph_getattr(const struct path *path, struct kstat *stat,
/* Skip the getattr altogether if we're asked not to sync */ /* Skip the getattr altogether if we're asked not to sync */
if (!(flags & AT_STATX_DONT_SYNC)) { if (!(flags & AT_STATX_DONT_SYNC)) {
err = ceph_do_getattr(inode, statx_to_caps(request_mask), err = ceph_do_getattr(inode,
flags & AT_STATX_FORCE_SYNC); statx_to_caps(request_mask, inode->i_mode),
flags & AT_STATX_FORCE_SYNC);
if (err) if (err)
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment