@@ -461,7 +461,7 @@ int lprocfs_obd_setup(struct obd_device *obd, bool uuid_only);
int lprocfs_obd_cleanup(struct obd_device *obd);
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 */
int ldebugfs_uint(struct seq_file *m, void *data);
@@ -2020,7 +2020,8 @@ static int ll_rw_extents_stats_pp_seq_show(struct seq_file *seq, void *v)
}
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%");
@@ -2157,7 +2158,8 @@ static int ll_rw_extents_stats_seq_show(struct seq_file *seq, void *v)
}
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",
@@ -2341,7 +2343,7 @@ static int ll_rw_offset_stats_seq_show(struct seq_file *seq, void *v)
}
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");
@@ -513,7 +513,8 @@ static int mdc_stats_seq_show(struct seq_file *seq, void *v)
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",
@@ -1448,7 +1448,7 @@ int obd_mod_rpc_stats_seq_show(struct client_obd *cli, struct seq_file *seq)
spin_lock_irq(&cli->cl_mod_rpcs_waitq.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);
@@ -1373,21 +1373,40 @@ static void *lprocfs_stats_seq_next(struct seq_file *p, void *v, loff_t *pos)
return lprocfs_stats_seq_start(p, pos);
}
+/**
+ * print header of stats including snapshot_time, start_time and elapsed_time.
+ *
+ * @seq the file to print content to
+ * @now end time to calculate elapsed_time
+ * @ts_init start time to calculate elapsed_time
+ * @width the width of key to align them well
+ * @colon "" or ":"
+ * @show_units show units or not
+ * @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);
@@ -1400,7 +1419,8 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
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);
@@ -702,7 +702,8 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
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",
@@ -814,7 +815,8 @@ static int osc_stats_seq_show(struct seq_file *seq, void *v)
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",