ceph: support getting ceph.dir.rsnaps vxattr
authorYanhu Cao <gmayyyha@gmail.com>
Fri, 28 Aug 2020 01:28:44 +0000 (09:28 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 27 Apr 2021 21:52:23 +0000 (23:52 +0200)
Add support for grabbing the rsnaps value out of the inode info in
traces, and exposing that via ceph.dir.rsnaps xattr.

Signed-off-by: Yanhu Cao <gmayyyha@gmail.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/inode.c
fs/ceph/mds_client.c
fs/ceph/mds_client.h
fs/ceph/super.h
fs/ceph/xattr.c

index 2fd1c48ac5d7ce733cdbc0329e6d649692193855..d6ff9b4585faee38da395dfa72583796ebccea0e 100644 (file)
@@ -895,6 +895,7 @@ int ceph_fill_inode(struct inode *inode, struct page *locked_page,
                        ci->i_rfiles = le64_to_cpu(info->rfiles);
                        ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
                        ci->i_dir_pin = iinfo->dir_pin;
+                       ci->i_rsnaps = iinfo->rsnaps;
                        ceph_decode_timespec64(&ci->i_rctime, &info->rctime);
                }
        }
index 73ecb7d128c91d314f0cf2bacc7ba130f9ff25d2..5c50f7986404432a42aa87270549eff3d50fc5ae 100644 (file)
@@ -176,6 +176,13 @@ static int parse_reply_info_in(void **p, void *end,
                        memset(&info->snap_btime, 0, sizeof(info->snap_btime));
                }
 
+               /* snapshot count, remains zero for v<=3 */
+               if (struct_v >= 4) {
+                       ceph_decode_64_safe(p, end, info->rsnaps, bad);
+               } else {
+                       info->rsnaps = 0;
+               }
+
                *p = end;
        } else {
                if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
@@ -214,7 +221,7 @@ static int parse_reply_info_in(void **p, void *end,
                }
 
                info->dir_pin = -ENODATA;
-               /* info->snap_btime remains zero */
+               /* info->snap_btime and info->rsnaps remain zero */
        }
        return 0;
 bad:
index eaa7c5422116a445494026ce2d454cb141cc7e5c..15c11a0f2caf8ef7b35d945e2ee331fd16be0751 100644 (file)
@@ -88,6 +88,7 @@ struct ceph_mds_reply_info_in {
        s32 dir_pin;
        struct ceph_timespec btime;
        struct ceph_timespec snap_btime;
+       u64 rsnaps;
        u64 change_attr;
 };
 
index 68dd6a8520ddf26aab2d31ff6dae8bb18ff8a59f..df0851b9240e62cfe0dd03ad63361cea30cb7b64 100644 (file)
@@ -334,7 +334,7 @@ struct ceph_inode_info {
 
        /* for dirs */
        struct timespec64 i_rctime;
-       u64 i_rbytes, i_rfiles, i_rsubdirs;
+       u64 i_rbytes, i_rfiles, i_rsubdirs, i_rsnaps;
        u64 i_files, i_subdirs;
 
        /* quotas */
index 02f59bcb4f27ad743a6bb043333764b099eec5eb..1242db8d3444acc523daf5cd7011aab22d8f28a7 100644 (file)
@@ -233,6 +233,12 @@ static ssize_t ceph_vxattrcb_dir_rsubdirs(struct ceph_inode_info *ci, char *val,
        return ceph_fmt_xattr(val, size, "%lld", ci->i_rsubdirs);
 }
 
+static ssize_t ceph_vxattrcb_dir_rsnaps(struct ceph_inode_info *ci, char *val,
+                                         size_t size)
+{
+       return ceph_fmt_xattr(val, size, "%lld", ci->i_rsnaps);
+}
+
 static ssize_t ceph_vxattrcb_dir_rbytes(struct ceph_inode_info *ci, char *val,
                                        size_t size)
 {
@@ -384,6 +390,7 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
        XATTR_RSTAT_FIELD(dir, rentries),
        XATTR_RSTAT_FIELD(dir, rfiles),
        XATTR_RSTAT_FIELD(dir, rsubdirs),
+       XATTR_RSTAT_FIELD(dir, rsnaps),
        XATTR_RSTAT_FIELD(dir, rbytes),
        XATTR_RSTAT_FIELD(dir, rctime),
        {