From: Jeff Layton Date: Fri, 20 Nov 2020 15:39:58 +0000 (-0500) Subject: client: ensure we take Fs caps when querying dirstat vxattrs X-Git-Tag: v16.1.0~232^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3db582b1416dc170a0e25c957166d7bdc58e4c67;p=ceph.git client: ensure we take Fs caps when querying dirstat vxattrs Dirstats values are only updated when Fs caps are held, so ensure that we request those caps in the _getattr call when querying for them. Drop the old XATTR_NAME_CEPH helper and rename XATTR_NAME_CEPH2 to XATTR_NAME_CEPH. Add a new VXATTR_DIRSTAT field and add that to all of the dirstats vxattrs. Fixes: https://tracker.ceph.com/issues/48313 Signed-off-by: Jeff Layton --- diff --git a/src/client/Client.cc b/src/client/Client.cc index aaf9db20c354..fc4e3487ef75 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -11819,6 +11819,9 @@ int Client::_getxattr(Inode *in, const char *name, void *value, size_t size, if (vxattr->flags & VXATTR_RSTAT) { flags |= CEPH_STAT_RSTAT; } + if (vxattr->flags & VXATTR_DIRSTAT) { + flags |= CEPH_CAP_FILE_SHARED; + } r = _getattr(in, flags | CEPH_STAT_CAP_XATTR, perms, true); if (r != 0) { // Error from getattr! @@ -12379,15 +12382,7 @@ size_t Client::_vxattrcb_mirror_info(Inode *in, char *val, size_t size) #define CEPH_XATTR_NAME(_type, _name) "ceph." #_type "." #_name #define CEPH_XATTR_NAME2(_type, _name, _name2) "ceph." #_type "." #_name "." #_name2 -#define XATTR_NAME_CEPH(_type, _name) \ -{ \ - name: CEPH_XATTR_NAME(_type, _name), \ - getxattr_cb: &Client::_vxattrcb_ ## _type ## _ ## _name, \ - readonly: true, \ - exists_cb: NULL, \ - flags: 0, \ -} -#define XATTR_NAME_CEPH2(_type, _name, _flags) \ +#define XATTR_NAME_CEPH(_type, _name, _flags) \ { \ name: CEPH_XATTR_NAME(_type, _name), \ getxattr_cb: &Client::_vxattrcb_ ## _type ## _ ## _name, \ @@ -12425,15 +12420,15 @@ const Client::VXattr Client::_dir_vxattrs[] = { XATTR_LAYOUT_FIELD(dir, layout, object_size), XATTR_LAYOUT_FIELD(dir, layout, pool), XATTR_LAYOUT_FIELD(dir, layout, pool_namespace), - XATTR_NAME_CEPH(dir, entries), - XATTR_NAME_CEPH(dir, files), - XATTR_NAME_CEPH(dir, subdirs), - XATTR_NAME_CEPH2(dir, rentries, VXATTR_RSTAT), - XATTR_NAME_CEPH2(dir, rfiles, VXATTR_RSTAT), - XATTR_NAME_CEPH2(dir, rsubdirs, VXATTR_RSTAT), - XATTR_NAME_CEPH2(dir, rsnaps, VXATTR_RSTAT), - XATTR_NAME_CEPH2(dir, rbytes, VXATTR_RSTAT), - XATTR_NAME_CEPH2(dir, rctime, VXATTR_RSTAT), + XATTR_NAME_CEPH(dir, entries, VXATTR_DIRSTAT), + XATTR_NAME_CEPH(dir, files, VXATTR_DIRSTAT), + XATTR_NAME_CEPH(dir, subdirs, VXATTR_DIRSTAT), + XATTR_NAME_CEPH(dir, rentries, VXATTR_RSTAT), + XATTR_NAME_CEPH(dir, rfiles, VXATTR_RSTAT), + XATTR_NAME_CEPH(dir, rsubdirs, VXATTR_RSTAT), + XATTR_NAME_CEPH(dir, rsnaps, VXATTR_RSTAT), + XATTR_NAME_CEPH(dir, rbytes, VXATTR_RSTAT), + XATTR_NAME_CEPH(dir, rctime, VXATTR_RSTAT), { name: "ceph.quota", getxattr_cb: &Client::_vxattrcb_quota, diff --git a/src/client/Client.h b/src/client/Client.h index 01f469ea1baa..52243efad89e 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -1164,6 +1164,7 @@ private: /* Flags for VXattr */ static const unsigned VXATTR_RSTAT = 0x1; + static const unsigned VXATTR_DIRSTAT = 0x2; static const VXattr _dir_vxattrs[]; static const VXattr _file_vxattrs[];