From 47ccacd58dafb3d9a257c37a06b57a8bd19ff1ce Mon Sep 17 00:00:00 2001 From: Hongchao Zhang Date: Fri, 26 Jan 2024 21:43:36 +0800 Subject: [PATCH] LU-17471 osd: add symlink for brw_stats 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 Change-Id: Ie86b2b384e3b91f98ead00b6325ddeb020e47aa5 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/53829 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_lproc.c | 44 +++++++++++++++++++++++++++++++++++++++++ lustre/osd-zfs/osd_lproc.c | 45 ++++++++++++++++++++++++++++++++++++++++++ lustre/tests/sanity.sh | 14 +++++++++++++ 3 files changed, 103 insertions(+) diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c index f4a1fcc..21f3b8f 100644 --- a/lustre/osd-ldiskfs/osd_lproc.c +++ b/lustre/osd-ldiskfs/osd_lproc.c @@ -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); } diff --git a/lustre/osd-zfs/osd_lproc.c b/lustre/osd-zfs/osd_lproc.c index 48da973..05c3a27 100644 --- a/lustre/osd-zfs/osd_lproc.c +++ b/lustre/osd-zfs/osd_lproc.c @@ -43,6 +43,46 @@ #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; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index f396747..c8b00b6 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -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 -- 1.8.3.1