]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: ensure we take Fs caps when querying dirstat vxattrs
authorJeff Layton <jlayton@redhat.com>
Fri, 20 Nov 2020 15:39:58 +0000 (10:39 -0500)
committerVicente Cheng <freeze.bilsted@gmail.com>
Mon, 18 Jan 2021 14:36:38 +0000 (14:36 +0000)
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 <jlayton@redhat.com>
(cherry picked from commit 3db582b1416dc170a0e25c957166d7bdc58e4c67)

Conflicts:
src/client/Client.cc
  - keep hidden because we still need it in nautilus
  - drop some code because we did not introduce the
            following features: ceph.mirror.info and rsnaps

src/client/Client.cc
src/client/Client.h

index 2c56b9d3893540566b04aec959c2e5cdc68c4294..9e87d63d460613426df08c5f357a52b7720ebcff 100755 (executable)
@@ -11380,6 +11380,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, perms, true);
     if (r != 0) {
       // Error from getattr!
@@ -11941,16 +11944,7 @@ size_t Client::_vxattrcb_snap_btime(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,                                              \
-  hidden: false,                                               \
-  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,     \
@@ -11992,14 +11986,14 @@ 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, 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, rbytes, VXATTR_RSTAT),
+  XATTR_NAME_CEPH(dir, rctime, VXATTR_RSTAT),
   {
     name: "ceph.quota",
     getxattr_cb: &Client::_vxattrcb_quota,
index 9c4f02c04473c2ba643ed1d4bfe867bb236a2f55..844dcb4adc1674572c33685671a67fe11a764bfe 100644 (file)
@@ -1005,6 +1005,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[];