Whamcloud - gitweb
LU-17471 osd: add symlink for brw_stats 29/53829/10
authorHongchao Zhang <hongchao@whamcloud.com>
Fri, 26 Jan 2024 13:43:36 +0000 (21:43 +0800)
committerOleg Drokin <green@whamcloud.com>
Thu, 15 Feb 2024 07:11:12 +0000 (07:11 +0000)
Add symlink at /proc/fs/lustre/osd-*/*/brw_stats to
/sys/kernel/debug/lustre/osd-*/*/brw_stats to fix
the compatible issue of the previous utils that are
still using the old proc entry.

Test-Parameters: testlist=sanity env=ONLY=0f serverversion=2.15.4
Fixes: 8a84c7f9c7d6 ("LU-14927 osd: share brw_stats code between OSD back ends.")
Signed-off-by: Hongchao Zhang <hongchao@whamcloud.com>
Change-Id: Ie86b2b384e3b91f98ead00b6325ddeb020e47aa5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53829
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_lproc.c
lustre/osd-zfs/osd_lproc.c
lustre/tests/sanity.sh

index f4a1fcc..21f3b8f 100644 (file)
@@ -56,6 +56,46 @@ void osd_brw_stats_update(struct osd_device *osd, struct osd_iobuf *iobuf)
                              iobuf->dr_pextents);
 }
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 17, 53, 0)
+static void osd_symlink_brw_stats(struct osd_device *osd)
+{
+       size_t len_root;
+       size_t len_path;
+       char *root;
+       char *s;
+       char *p;
+       char *path;
+
+       OBD_ALLOC(path, PATH_MAX);
+       if (path == NULL)
+               return;
+
+       p = dentry_path_raw(osd->od_dt_dev.dd_debugfs_entry, path, PATH_MAX);
+       if (IS_ERR(p))
+               goto out;
+
+       root = osd->od_dt_dev.dd_debugfs_entry->d_sb->s_fs_info;
+       len_root = strlen(root);
+       len_path = strlen(p);
+       if (len_root > (p - path) || len_root + len_path + 16 > PATH_MAX)
+               goto out;
+
+       strlcpy(path, root, len_root);
+       if (p > path + len_root) {
+               s = path + len_root;
+               while ((*s++ = *p++) != '\0');
+       }
+
+       *(path + len_root + len_path) = '\0';
+       strcat(path, "/brw_stats");
+       lprocfs_add_symlink("brw_stats", osd->od_proc_entry,
+                           "/sys/kernel/debug/%s", path);
+
+out:
+       OBD_FREE(path, PATH_MAX);
+}
+#endif
+
 static int osd_stats_init(struct osd_device *osd)
 {
        int result = -ENOMEM;
@@ -97,6 +137,10 @@ static int osd_stats_init(struct osd_device *osd)
        ldebugfs_register_osd_stats(osd->od_dt_dev.dd_debugfs_entry,
                                    &osd->od_brw_stats, osd->od_stats);
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 17, 53, 0)
+       osd_symlink_brw_stats(osd);
+#endif
+
        RETURN(result);
 }
 
index 48da973..05c3a27 100644 (file)
 
 #include "osd_internal.h"
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 17, 53, 0)
+static void osd_symlink_brw_stats(struct osd_device *osd)
+{
+       size_t len_root;
+       size_t len_path;
+       char *root;
+       char *s;
+       char *p;
+       char *path;
+
+       OBD_ALLOC(path, PATH_MAX);
+       if (path == NULL)
+               return;
+
+       p = dentry_path_raw(osd->od_dt_dev.dd_debugfs_entry, path, PATH_MAX);
+       if (IS_ERR(p))
+               goto out;
+
+       root = osd->od_dt_dev.dd_debugfs_entry->d_sb->s_fs_info;
+       len_root = strlen(root);
+       len_path = strlen(p);
+       if (len_root > (p - path) || len_root + len_path + 16 > PATH_MAX)
+               goto out;
+
+       strlcpy(path, root, len_root);
+       if (p > path + len_root) {
+               s = path + len_root;
+               while ((*s++ = *p++) != '\0');
+       }
+
+       *(path + len_root + len_path) = '\0';
+       strcat(path, "/brw_stats");
+       lprocfs_add_symlink("brw_stats", osd->od_proc_entry,
+                           "/sys/kernel/debug/%s", path);
+
+out:
+       OBD_FREE(path, PATH_MAX);
+}
+#endif
+
 static int osd_stats_init(struct osd_device *osd)
 {
        int result = -ENOMEM;
@@ -90,6 +130,11 @@ static int osd_stats_init(struct osd_device *osd)
 
        ldebugfs_register_osd_stats(osd->od_dt_dev.dd_debugfs_entry,
                                    &osd->od_brw_stats, osd->od_stats);
+
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 17, 53, 0)
+       osd_symlink_brw_stats(osd);
+#endif
+
        /* These fields are not supported for ZFS */
        osd->od_brw_stats.bs_props[BRW_R_DISCONT_BLOCKS / 2].bsp_name = NULL;
        osd->od_brw_stats.bs_props[BRW_R_DIO_FRAGS / 2].bsp_name = NULL;
index f396747..c8b00b6 100755 (executable)
@@ -279,6 +279,20 @@ test_0e() { # LU-13417
 }
 run_test 0e "Enable DNE MDT balancing for mkdir in the ROOT"
 
+test_0f() { # LU-17471
+       (( $MDS1_VERSION < $(version_code 2.17.53) )) ||
+               skip "MDS >= 2.17.53 removes /proc/.../brw_stats symlink"
+       (( $MDS1_VERSION < $(version_code 2.14.55-100-g8a84c7f9c7) ||
+          $MDS1_VERSION > $(version_code 2.15.60-25) )) ||
+               skip "MDS was missing /proc/.../brw_stats value"
+
+       local path="lustre/osd-$FSTYPE/$FSNAME-MDT0000/brw_stats"
+       local out_proc=$(do_facet mds1 grep snapshot_time /proc/fs/$path)
+
+       [[ -n "$out_proc" ]] || error "brw_stats /proc/fs/$path not found"
+}
+run_test 0f "Symlink to /sys/kernel/debug/*/*/brw_stats should work properly"
+
 test_1() {
        test_mkdir $DIR/$tdir
        test_mkdir $DIR/$tdir/d2