From: Andreas Dilger Date: Mon, 31 Jul 2023 17:53:22 +0000 (-0600) Subject: LU-17005 obdclass: allow stats header to be disabled X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=5f9dd7b55274205bf054d023dc3d12c5fbf10b92;p=fs%2Flustre-release.git LU-17005 obdclass: allow stats header to be disabled Add a global "enable_stats_header" tunable parameter that can be set to enable/disable the "start_time" and "elapsed_time" fields in the standard lprocfs "stats" files. Default to disabled for EXA6.2.1, since this is new for this release. Lustre-change: https://review.whamcloud.com/51823 Lustre-commit: TBD (from 370a81bf07f3e3856f73900f276495fb7a2b5223) Test-Parameters: trivial Fixes: 5efb892396e3 ("LU-11407 obdclass: add start time to stats files") Signed-off-by: Andreas Dilger Change-Id: I460b957447bfb83e6d4fd7395b79ce994f3ebbe5 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/51824 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Feng Lei --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index 46b2c7c..ba17bf5 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -572,6 +572,7 @@ extern int lprocfs_obd_seq_create(struct obd_device *obd, const char *name, extern void lprocfs_stats_header(struct seq_file *seq, ktime_t now, ktime_t ts_init, int width, const char *colon, bool show_units, const char *prefix); +extern unsigned int obd_enable_stats_header; /* Generic callbacks */ extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 2411469..4df7d85 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -41,6 +41,9 @@ #ifdef CONFIG_PROC_FS +/* disable start/elapsed_time in stats headers by default for compatibility */ +unsigned int obd_enable_stats_header; + static int lprocfs_no_percpu_stats = 0; module_param(lprocfs_no_percpu_stats, int, 0644); MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats"); @@ -1407,6 +1410,9 @@ void lprocfs_stats_header(struct seq_file *seq, ktime_t now, seq_printf(seq, "%s%-*s %llu.%09lu%s\n", prefix, width, field, (s64)ts.tv_sec, ts.tv_nsec, units); + if (!obd_enable_stats_header) + return; + field = (colon && colon[0]) ? "start_time:" : "start_time"; ts = ktime_to_timespec64(ts_init); seq_printf(seq, "%s%-*s %llu.%09lu%s\n", prefix, width, field, diff --git a/lustre/obdclass/obd_sysfs.c b/lustre/obdclass/obd_sysfs.c index 8e4cae2..fb48554 100644 --- a/lustre/obdclass/obd_sysfs.c +++ b/lustre/obdclass/obd_sysfs.c @@ -121,6 +121,7 @@ LUSTRE_STATIC_UINT_ATTR(at_max, &at_max); LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra); LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin); LUSTRE_STATIC_UINT_ATTR(at_history, &at_history); +LUSTRE_STATIC_UINT_ATTR(enable_stats_header, &obd_enable_stats_header); LUSTRE_STATIC_UINT_ATTR(lbug_on_eviction, &obd_lbug_on_eviction); #ifdef HAVE_SERVER_SUPPORT @@ -399,6 +400,7 @@ LUSTRE_RW_ATTR(jobid_this_session); static struct attribute *lustre_attrs[] = { &lustre_attr_version.attr, &lustre_attr_pinger.attr, + &lustre_sattr_enable_stats_header.u.attr, &lustre_attr_health_check.attr, &lustre_attr_jobid_name.attr, &lustre_attr_jobid_var.attr, diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 93052ff..a6ac318 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -13418,6 +13418,9 @@ test_127a() { # bug 15521 local name count samp unit min max sum sumsq local tmpfile=$TMP/$tfile.tmp + # enable stats header if it is disabled + $LCTL set_param enable_stats_header=1 + $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed" echo "stats before reset" stack_trap "rm -f $tmpfile"