Whamcloud - gitweb
LU-17471 osd: add symlink for brw_stats
authorHongchao Zhang <hongchao@whamcloud.com>
Fri, 26 Jan 2024 13:43:36 +0000 (21:43 +0800)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 2 Feb 2024 16:05:53 +0000 (16:05 +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.

Lustre-change: https://review.whamcloud.com/53829
Lustre-commit: TBD (from 5fad20603098c55c0080548a177023a36e640e84)

Fixes: 8a84c7f9c7 ("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/ex/lustre-release/+/53858
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/osd-ldiskfs/osd_lproc.c
lustre/osd-zfs/osd_lproc.c
lustre/tests/sanity.sh

index e95aac8..feb8ad4 100644 (file)
@@ -76,6 +76,46 @@ void osd_brw_stats_update(struct osd_device *osd, struct osd_iobuf *iobuf)
        lprocfs_oh_tally(&bs->bs_hist[BRW_R_DISCONT_BLOCKS+rw], discont_blocks);
 }
 
+#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;
@@ -118,6 +158,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 b9a6363..b4f2d03 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;
@@ -91,6 +131,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 9cb3a42..c0559b5 100755 (executable)
@@ -284,6 +284,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.0-ddn109-5-gcee13e757f) ||
+          $MDS1_VERSION > $(version_code 2.14.0-ddn132) )) ||
+               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