Requires: lustre-iokit
%endif
Requires: lustre-devel = %{version}
+%if 0%{?rhel} >= 8 || 0%{?suse_version} >= 1500
+Requires: python3 >= 3.6.0, python3-PyYAML
+%endif
%if %{with lustre_modules}
Requires: %{requires_kmod_name} = %{requires_kmod_version}
Requires: %{requires_kmod_tests_name} = %{requires_kmod_version}
void *data);
extern void lprocfs_stats_header(struct seq_file *seq, ktime_t now,
ktime_t ts_init, int width, const char *colon,
- bool show_units);
+ bool show_units, const char *prefix);
/* Generic callbacks */
extern int lprocfs_uuid_seq_show(struct seq_file *m, void *data);
}
spin_lock(&sbi->ll_pp_extent_lock);
- lprocfs_stats_header(seq, ktime_get(), rw_extents->pp_init, 25, ":", 1);
+ lprocfs_stats_header(seq, ktime_get(), rw_extents->pp_init, 25, ":",
+ true, "");
seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write");
seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n",
"extents", "calls", "%", "cum%", "calls", "%", "cum%");
}
spin_lock(&sbi->ll_lock);
- lprocfs_stats_header(seq, ktime_get(), rw_extents->pp_init, 25, ":", 1);
+ lprocfs_stats_header(seq, ktime_get(), rw_extents->pp_init, 25, ":",
+ true, "");
seq_printf(seq, "%15s %19s | %20s\n", " ", "read", "write");
seq_printf(seq, "%13s %14s %4s %4s | %14s %4s %4s\n",
spin_lock(&sbi->ll_process_lock);
lprocfs_stats_header(seq, ktime_get(), sbi->ll_process_stats_init, 25,
- ":", true);
+ ":", true, "");
seq_printf(seq, "%3s %10s %14s %14s %17s %17s %14s\n",
"R/W", "PID", "RANGE START", "RANGE END",
"SMALLEST EXTENT", "LARGEST EXTENT", "OFFSET");
struct obd_device *obd = seq->private;
struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
- lprocfs_stats_header(seq, ktime_get(), stats->os_init, 25, ":", true);
+ lprocfs_stats_header(seq, ktime_get(), stats->os_init, 25, ":", true,
+ "");
seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
stats->os_lockless_writes);
seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
tot = lprocfs_oh_sum(rs_hist);
if (tot > 0)
- seq_printf(seq, "- %s\n", name);
+ seq_printf(seq, "- %s:\n", name);
for (i = 0; i < OBD_HIST_MAX; i++) {
t = rs_hist->oh_buckets[i];
struct rename_stats *rename_stats)
{
/* this sampling races with updates */
- seq_puts(seq, "rename_stats:\n- ");
+ seq_puts(seq, "rename_stats:\n-\n");
lprocfs_stats_header(seq, ktime_get(), rename_stats->rs_init, 15, ":",
- false);
+ false, " ");
display_rename_stats(seq, "same_dir",
&rename_stats->rs_hist[RENAME_SAMEDIR_SIZE]);
spin_lock(&cli->cl_mod_rpcs_lock);
lprocfs_stats_header(seq, ktime_get(), cli->cl_mod_rpcs_init, 25,
- ":", true);
+ ":", true, "");
seq_printf(seq, "modify_RPCs_in_flight: %hu\n",
cli->cl_mod_rpcs_in_flight);
seq_printf(p, "- %-16s %s%*s%s\n",
"job_id:", quote, joblen, escaped, quote);
lprocfs_stats_header(p, job->js_time_latest, job->js_time_init, 16,
- ":", true);
+ ":", true, " ");
s = job->js_stats;
for (i = 0; i < s->ls_num; i++) {
return lprocfs_stats_seq_start(p, pos);
}
+/**
+ * print header of stats including snapshot_time, start_time and elapsed_time.
+ *
+ * \param seq the file to print content to
+ * \param now end time to calculate elapsed_time
+ * \param ts_init start time to calculate elapsed_time
+ * \param width the width of key to align them well
+ * \param colon "" or ":"
+ * \param show_units show units or not
+ * \param prefix prefix (indent) before printing each line of header
+ * to align them with other content
+ */
void lprocfs_stats_header(struct seq_file *seq, ktime_t now, ktime_t ts_init,
- int width, const char *colon, bool show_units)
+ int width, const char *colon, bool show_units,
+ const char *prefix)
{
const char *units = show_units ? " secs.nsecs" : "";
struct timespec64 ts;
+ const char *field;
+ field = (colon && colon[0]) ? "snapshot_time:" : "snapshot_time";
ts = ktime_to_timespec64(now);
- seq_printf(seq, "%-*s%s %llu.%09lu%s\n", width,
- "snapshot_time", colon, (s64)ts.tv_sec, ts.tv_nsec, units);
+ seq_printf(seq, "%s%-*s %llu.%09lu%s\n", prefix, width, field,
+ (s64)ts.tv_sec, ts.tv_nsec, units);
+
+ field = (colon && colon[0]) ? "start_time:" : "start_time";
ts = ktime_to_timespec64(ts_init);
- seq_printf(seq, "%-*s%s %llu.%09lu%s\n", width,
- "start_time", colon, (s64)ts.tv_sec, ts.tv_nsec, units);
+ seq_printf(seq, "%s%-*s %llu.%09lu%s\n", prefix, width, field,
+ (s64)ts.tv_sec, ts.tv_nsec, units);
+
+ field = (colon && colon[0]) ? "elapsed_time:" : "elapsed_time";
ts = ktime_to_timespec64(ktime_sub(now, ts_init));
- seq_printf(seq, "%-*s%s %llu.%09lu%s\n", width,
- "elapsed_time", colon, (s64)ts.tv_sec, ts.tv_nsec, units);
+ seq_printf(seq, "%s%-*s %llu.%09lu%s\n", prefix, width, field,
+ (s64)ts.tv_sec, ts.tv_nsec, units);
}
EXPORT_SYMBOL(lprocfs_stats_header);
int idx = *(loff_t *)v;
if (idx == 0)
- lprocfs_stats_header(p, ktime_get(), stats->ls_init, 25, "", 1);
+ lprocfs_stats_header(p, ktime_get(), stats->ls_init, 25, "",
+ true, "");
hdr = &stats->ls_cnt_header[idx];
lprocfs_stats_collect(stats, idx, &ctr);
int i;
/* this sampling races with updates */
- lprocfs_stats_header(seq, ktime_get(), brw_stats->bs_init, 25, ":", 1);
+ lprocfs_stats_header(seq, ktime_get(), brw_stats->bs_init, 25, ":",
+ true, "");
for (i = 0; i < ARRAY_SIZE(brw_stats->bs_props); i++) {
if (!brw_stats->bs_props[i].bsp_name)
spin_lock(&cli->cl_loi_list_lock);
- lprocfs_stats_header(seq, ktime_get(), cli->cl_stats_init, 25, ":", 1);
+ lprocfs_stats_header(seq, ktime_get(), cli->cl_stats_init, 25, ":",
+ true, "");
seq_printf(seq, "read RPCs in flight: %d\n",
cli->cl_r_in_flight);
seq_printf(seq, "write RPCs in flight: %d\n",
struct obd_device *obd = seq->private;
struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
- lprocfs_stats_header(seq, ktime_get(), stats->os_init, 25, ":", true);
+ lprocfs_stats_header(seq, ktime_get(), stats->os_init, 25, ":", true,
+ "");
seq_printf(seq, "lockless_write_bytes\t\t%llu\n",
stats->os_lockless_writes);
seq_printf(seq, "lockless_read_bytes\t\t%llu\n",
$CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
}
run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
+
test_24t() {
test_mkdir $DIR/R16a
test_mkdir $DIR/R16a/b
}
run_test 904 "virtual project ID xattr"
+test_907() {
+ local file=$DIR/$tdir/$tfile
+
+ (( $MDS1_VERSION >= $(version_code 2.15.1) )) ||
+ skip "need lustre >= 2.15.51"
+ (( $OST1_VERSION >= $(version_code 2.15.1) )) ||
+ skip "need lustre >= 2.15.51"
+ verify_yaml_available || skip_env "YAML verification not installed"
+
+ test_mkdir $DIR/$tdir
+ $LFS setstripe -E 1M -L mdt -E -1 $file || error "setstripe failed"
+
+ dd if=/dev/zero of=$file bs=1M count=10 conv=sync ||
+ error "failed to write data to $file"
+ mv $file $file.2
+
+ echo -n 'verify rename_stats...'
+ output=$(do_facet mds1 \
+ "$LCTL get_param -n mdt.$FSNAME-MDT0000.rename_stats")
+ verify_yaml "$output" || error "rename_stats is not valid YAML"
+ echo " OK"
+
+ echo -n 'verify mdt job_stats...'
+ output=$(do_facet mds1 \
+ "$LCTL get_param -n mdt.$FSNAME-MDT0000.job_stats")
+ verify_yaml "$output" || error "job_stats on mds1 is not valid YAML"
+ echo " OK"
+
+ echo -n 'verify ost job_stats...'
+ output=$(do_facet ost1 \
+ "$LCTL get_param -n obdfilter.$FSNAME-OST0000.job_stats")
+ verify_yaml "$output" || error "job_stats on ost1 is not valid YAML"
+ echo " OK"
+}
+run_test 907 "verify the format of some stats files"
+
complete $SECONDS
[ -f $EXT2_DEV ] && rm $EXT2_DEV || true
check_and_cleanup_lustre
done
sleep_maxage
}
+
+verify_yaml_available() {
+ python3 -c "import yaml; yaml.safe_load_all('''a: b''')"
+}
+
+verify_yaml() {
+ python3 -c "import yaml; yaml.safe_load_all('''$1''')"
+}