diff options
Diffstat (limited to 'sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch')
-rw-r--r-- | sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch | 1928 |
1 files changed, 1928 insertions, 0 deletions
diff --git a/sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch b/sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch new file mode 100644 index 000000000..e2891347a --- /dev/null +++ b/sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch @@ -0,0 +1,1928 @@ +From 075cf04c212e2bf0f38c94433a80bca2e5bb051e Mon Sep 17 00:00:00 2001 +From: James Simmons <uja.ornl@gmail.com> +Date: Fri, 31 Jan 2014 14:00:32 -0500 +Subject: [PATCH 09/13] LU-3319 procfs: move mdd/ofd proc handling to seq_files + +With 3.10 linux kernel and above proc handling now only +uses struct seq_files. This patch migrates the mdd/ofd +layer proc entries over to using seq_files. + +Signed-off-by: James Simmons <uja.ornl@gmail.com> +Change-Id: I61b7df6bfd5efd0f12e3ca1a1813b7b62d493168 +--- + lustre/include/lustre_lfsck.h | 6 +- + lustre/lfsck/lfsck_internal.h | 9 +- + lustre/lfsck/lfsck_layout.c | 66 ++---- + lustre/lfsck/lfsck_lib.c | 77 +++---- + lustre/lfsck/lfsck_namespace.c | 75 ++----- + lustre/mdd/mdd_device.c | 25 +-- + lustre/mdd/mdd_internal.h | 1 - + lustre/mdd/mdd_lproc.c | 293 ++++++++++++-------------- + lustre/obdclass/lprocfs_status.c | 9 +- + lustre/ofd/lproc_ofd.c | 436 ++++++++++++++++++++------------------- + lustre/ofd/ofd_dev.c | 48 ++--- + lustre/ofd/ofd_internal.h | 6 +- + lustre/osd-ldiskfs/osd_handler.c | 1 + + lustre/osd-zfs/osd_handler.c | 1 + + 14 files changed, 463 insertions(+), 590 deletions(-) + +diff --git a/lustre/include/lustre_lfsck.h b/lustre/include/lustre_lfsck.h +index 2e93420..0e578ac 100644 +--- a/lustre/include/lustre_lfsck.h ++++ b/lustre/include/lustre_lfsck.h +@@ -156,11 +156,11 @@ int lfsck_in_notify(const struct lu_env *env, struct dt_device *key, + int lfsck_query(const struct lu_env *env, struct dt_device *key, + struct lfsck_request *lr); + +-int lfsck_get_speed(struct dt_device *key, void *buf, int len); ++int lfsck_get_speed(struct seq_file *m, struct dt_device *key); + int lfsck_set_speed(struct dt_device *key, int val); +-int lfsck_get_windows(struct dt_device *key, void *buf, int len); ++int lfsck_get_windows(struct seq_file *m, struct dt_device *key); + int lfsck_set_windows(struct dt_device *key, int val); + +-int lfsck_dump(struct dt_device *key, void *buf, int len, enum lfsck_type type); ++int lfsck_dump(struct seq_file *m, struct dt_device *key, enum lfsck_type type); + + #endif /* _LUSTRE_LFSCK_H */ +diff --git a/lustre/lfsck/lfsck_internal.h b/lustre/lfsck/lfsck_internal.h +index 698fb5f..1893ccc 100644 +--- a/lustre/lfsck/lfsck_internal.h ++++ b/lustre/lfsck/lfsck_internal.h +@@ -288,8 +288,7 @@ struct lfsck_operations { + + int (*lfsck_dump)(const struct lu_env *env, + struct lfsck_component *com, +- char *buf, +- int len); ++ struct seq_file *m); + + int (*lfsck_double_scan)(const struct lu_env *env, + struct lfsck_component *com); +@@ -539,10 +538,10 @@ void lfsck_component_cleanup(const struct lu_env *env, + struct lfsck_component *com); + void lfsck_instance_cleanup(const struct lu_env *env, + struct lfsck_instance *lfsck); +-int lfsck_bits_dump(char **buf, int *len, int bits, const char *names[], ++int lfsck_bits_dump(struct seq_file *m, int bits, const char *names[], + const char *prefix); +-int lfsck_time_dump(char **buf, int *len, __u64 time, const char *prefix); +-int lfsck_pos_dump(char **buf, int *len, struct lfsck_position *pos, ++int lfsck_time_dump(struct seq_file *m, __u64 time, const char *prefix); ++int lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos, + const char *prefix); + void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck, + struct lfsck_position *pos, bool init); +diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c +index e7c12d2..8b9c43e 100644 +--- a/lustre/lfsck/lfsck_layout.c ++++ b/lustre/lfsck/lfsck_layout.c +@@ -2024,69 +2024,53 @@ static int lfsck_layout_slave_post(const struct lu_env *env, + } + + static int lfsck_layout_dump(const struct lu_env *env, +- struct lfsck_component *com, char *buf, int len) ++ struct lfsck_component *com, struct seq_file *m) + { + struct lfsck_instance *lfsck = com->lc_lfsck; + struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram; + struct lfsck_layout *lo = com->lc_file_ram; +- int save = len; +- int ret = -ENOSPC; + int rc; + + down_read(&com->lc_sem); +- rc = snprintf(buf, len, +- "name: lfsck_layout\n" ++ seq_printf(m, "name: lfsck_layout\n" + "magic: %#x\n" + "version: %d\n" + "status: %s\n", + lo->ll_magic, + bk->lb_version, + lfsck_status2names(lo->ll_status)); +- if (rc <= 0) +- goto out; + +- buf += rc; +- len -= rc; +- rc = lfsck_bits_dump(&buf, &len, lo->ll_flags, lfsck_flags_names, +- "flags"); ++ rc = lfsck_bits_dump(m, lo->ll_flags, lfsck_flags_names, "flags"); + if (rc < 0) + goto out; + +- rc = lfsck_bits_dump(&buf, &len, bk->lb_param, lfsck_param_names, +- "param"); ++ rc = lfsck_bits_dump(m, bk->lb_param, lfsck_param_names, "param"); + if (rc < 0) + goto out; + +- rc = lfsck_time_dump(&buf, &len, lo->ll_time_last_complete, ++ rc = lfsck_time_dump(m, lo->ll_time_last_complete, + "time_since_last_completed"); + if (rc < 0) + goto out; + +- rc = lfsck_time_dump(&buf, &len, lo->ll_time_latest_start, ++ rc = lfsck_time_dump(m, lo->ll_time_latest_start, + "time_since_latest_start"); + if (rc < 0) + goto out; + +- rc = lfsck_time_dump(&buf, &len, lo->ll_time_last_checkpoint, ++ rc = lfsck_time_dump(m, lo->ll_time_last_checkpoint, + "time_since_last_checkpoint"); + if (rc < 0) + goto out; + +- rc = snprintf(buf, len, +- "latest_start_position: "LPU64"\n" ++ seq_printf(m, "latest_start_position: "LPU64"\n" + "last_checkpoint_position: "LPU64"\n" + "first_failure_position: "LPU64"\n", + lo->ll_pos_latest_start, + lo->ll_pos_last_checkpoint, + lo->ll_pos_first_inconsistent); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; + +- rc = snprintf(buf, len, +- "success_count: %u\n" ++ seq_printf(m, "success_count: %u\n" + "repaired_dangling: "LPU64"\n" + "repaired_unmatched_pair: "LPU64"\n" + "repaired_multiple_referenced: "LPU64"\n" +@@ -2106,11 +2090,6 @@ static int lfsck_layout_dump(const struct lu_env *env, + lo->ll_objs_skipped, + lo->ll_objs_failed_phase1, + lo->ll_objs_failed_phase2); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; + + if (lo->ll_status == LS_SCANNING_PHASE1) { + __u64 pos; +@@ -2127,8 +2106,7 @@ static int lfsck_layout_dump(const struct lu_env *env, + do_div(new_checked, duration); + if (rtime != 0) + do_div(speed, rtime); +- rc = snprintf(buf, len, +- "checked_phase1: "LPU64"\n" ++ seq_printf(m, "checked_phase1: "LPU64"\n" + "checked_phase2: "LPU64"\n" + "run_time_phase1: %u seconds\n" + "run_time_phase2: %u seconds\n" +@@ -2142,11 +2120,6 @@ static int lfsck_layout_dump(const struct lu_env *env, + lo->ll_run_time_phase2, + speed, + new_checked); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; + + LASSERT(lfsck->li_di_oit != NULL); + +@@ -2159,12 +2132,7 @@ static int lfsck_layout_dump(const struct lu_env *env, + pos = iops->store(env, lfsck->li_di_oit); + if (!lfsck->li_current_oit_processed) + pos--; +- rc = snprintf(buf, len, "current_position: "LPU64"\n", pos); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; ++ seq_printf(m, "current_position: "LPU64"\n", pos); + } else { + /* XXX: LS_SCANNING_PHASE2 will be handled in the future. */ + __u64 speed1 = lo->ll_objs_checked_phase1; +@@ -2174,8 +2142,7 @@ static int lfsck_layout_dump(const struct lu_env *env, + do_div(speed1, lo->ll_run_time_phase1); + if (lo->ll_run_time_phase2 != 0) + do_div(speed2, lo->ll_run_time_phase2); +- rc = snprintf(buf, len, +- "checked_phase1: "LPU64"\n" ++ seq_printf(m, "checked_phase1: "LPU64"\n" + "checked_phase2: "LPU64"\n" + "run_time_phase1: %u seconds\n" + "run_time_phase2: %u seconds\n" +@@ -2190,18 +2157,11 @@ static int lfsck_layout_dump(const struct lu_env *env, + lo->ll_run_time_phase2, + speed1, + speed2); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; + } +- ret = save - len; +- + out: + up_read(&com->lc_sem); + +- return ret; ++ return rc; + } + + static int lfsck_layout_master_double_scan(const struct lu_env *env, +diff --git a/lustre/lfsck/lfsck_lib.c b/lustre/lfsck/lfsck_lib.c +index ad92e32..747e376 100644 +--- a/lustre/lfsck/lfsck_lib.c ++++ b/lustre/lfsck/lfsck_lib.c +@@ -424,77 +424,52 @@ static inline int lfsck_instance_add(struct lfsck_instance *lfsck) + return 0; + } + +-int lfsck_bits_dump(char **buf, int *len, int bits, const char *names[], ++int lfsck_bits_dump(struct seq_file *m, int bits, const char *names[], + const char *prefix) + { +- int save = *len; + int flag; +- int rc; + int i; + +- rc = snprintf(*buf, *len, "%s:%c", prefix, bits != 0 ? ' ' : '\n'); +- if (rc <= 0) +- return -ENOSPC; ++ seq_printf(m, "%s:%c", prefix, bits != 0 ? ' ' : '\n'); + +- *buf += rc; +- *len -= rc; + for (i = 0, flag = 1; bits != 0; i++, flag = 1 << i) { + if (flag & bits) { + bits &= ~flag; + if (names[i] != NULL) { +- rc = snprintf(*buf, *len, "%s%c", names[i], +- bits != 0 ? ',' : '\n'); +- if (rc <= 0) +- return -ENOSPC; +- +- *buf += rc; +- *len -= rc; ++ seq_printf(m, "%s%c", names[i], ++ bits != 0 ? ',' : '\n'); + } + } + } +- return save - *len; ++ return 0; + } + +-int lfsck_time_dump(char **buf, int *len, __u64 time, const char *prefix) ++int lfsck_time_dump(struct seq_file *m, __u64 time, const char *prefix) + { +- int rc; +- + if (time != 0) +- rc = snprintf(*buf, *len, "%s: "LPU64" seconds\n", prefix, +- cfs_time_current_sec() - time); ++ seq_printf(m, "%s: "LPU64" seconds\n", prefix, ++ cfs_time_current_sec() - time); + else +- rc = snprintf(*buf, *len, "%s: N/A\n", prefix); +- if (rc <= 0) +- return -ENOSPC; +- +- *buf += rc; +- *len -= rc; +- return rc; ++ seq_printf(m, "%s: N/A\n", prefix); ++ return 0; + } + +-int lfsck_pos_dump(char **buf, int *len, struct lfsck_position *pos, ++int lfsck_pos_dump(struct seq_file *m, struct lfsck_position *pos, + const char *prefix) + { +- int rc; +- + if (fid_is_zero(&pos->lp_dir_parent)) { + if (pos->lp_oit_cookie == 0) +- rc = snprintf(*buf, *len, "%s: N/A, N/A, N/A\n", +- prefix); ++ seq_printf(m, "%s: N/A, N/A, N/A\n", ++ prefix); + else +- rc = snprintf(*buf, *len, "%s: "LPU64", N/A, N/A\n", +- prefix, pos->lp_oit_cookie); ++ seq_printf(m, "%s: "LPU64", N/A, N/A\n", ++ prefix, pos->lp_oit_cookie); + } else { +- rc = snprintf(*buf, *len, "%s: "LPU64", "DFID", "LPU64"\n", +- prefix, pos->lp_oit_cookie, +- PFID(&pos->lp_dir_parent), pos->lp_dir_cookie); ++ seq_printf(m, "%s: "LPU64", "DFID", "LPU64"\n", ++ prefix, pos->lp_oit_cookie, ++ PFID(&pos->lp_dir_parent), pos->lp_dir_cookie); + } +- if (rc <= 0) +- return -ENOSPC; +- +- *buf += rc; +- *len -= rc; +- return rc; ++ return 0; + } + + void lfsck_pos_fill(const struct lu_env *env, struct lfsck_instance *lfsck, +@@ -1102,7 +1077,7 @@ int lfsck_async_request(const struct lu_env *env, struct obd_export *exp, + + /* external interfaces */ + +-int lfsck_get_speed(struct dt_device *key, void *buf, int len) ++int lfsck_get_speed(struct seq_file *m, struct dt_device *key) + { + struct lu_env env; + struct lfsck_instance *lfsck; +@@ -1115,8 +1090,7 @@ int lfsck_get_speed(struct dt_device *key, void *buf, int len) + + lfsck = lfsck_instance_find(key, true, false); + if (likely(lfsck != NULL)) { +- rc = snprintf(buf, len, "%u\n", +- lfsck->li_bookmark_ram.lb_speed_limit); ++ seq_printf(m, "%u\n", lfsck->li_bookmark_ram.lb_speed_limit); + lfsck_instance_put(&env, lfsck); + } else { + rc = -ENODEV; +@@ -1156,7 +1130,7 @@ int lfsck_set_speed(struct dt_device *key, int val) + } + EXPORT_SYMBOL(lfsck_set_speed); + +-int lfsck_get_windows(struct dt_device *key, void *buf, int len) ++int lfsck_get_windows(struct seq_file *m, struct dt_device *key) + { + struct lu_env env; + struct lfsck_instance *lfsck; +@@ -1169,8 +1143,7 @@ int lfsck_get_windows(struct dt_device *key, void *buf, int len) + + lfsck = lfsck_instance_find(key, true, false); + if (likely(lfsck != NULL)) { +- rc = snprintf(buf, len, "%u\n", +- lfsck->li_bookmark_ram.lb_async_windows); ++ seq_printf(m, "%u\n", lfsck->li_bookmark_ram.lb_async_windows); + lfsck_instance_put(&env, lfsck); + } else { + rc = -ENODEV; +@@ -1220,7 +1193,7 @@ int lfsck_set_windows(struct dt_device *key, int val) + } + EXPORT_SYMBOL(lfsck_set_windows); + +-int lfsck_dump(struct dt_device *key, void *buf, int len, enum lfsck_type type) ++int lfsck_dump(struct seq_file *m, struct dt_device *key, enum lfsck_type type) + { + struct lu_env env; + struct lfsck_instance *lfsck; +@@ -1236,7 +1209,7 @@ int lfsck_dump(struct dt_device *key, void *buf, int len, enum lfsck_type type) + if (likely(lfsck != NULL)) { + com = lfsck_component_find(lfsck, type); + if (likely(com != NULL)) { +- rc = com->lc_ops->lfsck_dump(&env, com, buf, len); ++ rc = com->lc_ops->lfsck_dump(&env, com, m); + lfsck_component_put(&env, com); + } else { + rc = -ENOTSUPP; +diff --git a/lustre/lfsck/lfsck_namespace.c b/lustre/lfsck/lfsck_namespace.c +index 6fc08fb..2abad67 100644 +--- a/lustre/lfsck/lfsck_namespace.c ++++ b/lustre/lfsck/lfsck_namespace.c +@@ -1088,65 +1088,56 @@ static int lfsck_namespace_post(const struct lu_env *env, + + static int + lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, +- char *buf, int len) ++ struct seq_file *m) + { + struct lfsck_instance *lfsck = com->lc_lfsck; + struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram; + struct lfsck_namespace *ns = com->lc_file_ram; +- int save = len; +- int ret = -ENOSPC; + int rc; + + down_read(&com->lc_sem); +- rc = snprintf(buf, len, +- "name: lfsck_namespace\n" +- "magic: %#x\n" +- "version: %d\n" +- "status: %s\n", +- ns->ln_magic, +- bk->lb_version, +- lfsck_status2names(ns->ln_status)); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; +- rc = lfsck_bits_dump(&buf, &len, ns->ln_flags, lfsck_flags_names, +- "flags"); ++ seq_printf(m, "name: lfsck_namespace\n" ++ "magic: %#x\n" ++ "version: %d\n" ++ "status: %s\n", ++ ns->ln_magic, ++ bk->lb_version, ++ lfsck_status2names(ns->ln_status)); ++ ++ rc = lfsck_bits_dump(m, ns->ln_flags, lfsck_flags_names, "flags"); + if (rc < 0) + goto out; + +- rc = lfsck_bits_dump(&buf, &len, bk->lb_param, lfsck_param_names, +- "param"); ++ rc = lfsck_bits_dump(m, bk->lb_param, lfsck_param_names, "param"); + if (rc < 0) + goto out; + +- rc = lfsck_time_dump(&buf, &len, ns->ln_time_last_complete, ++ rc = lfsck_time_dump(m, ns->ln_time_last_complete, + "time_since_last_completed"); + if (rc < 0) + goto out; + +- rc = lfsck_time_dump(&buf, &len, ns->ln_time_latest_start, ++ rc = lfsck_time_dump(m, ns->ln_time_latest_start, + "time_since_latest_start"); + if (rc < 0) + goto out; + +- rc = lfsck_time_dump(&buf, &len, ns->ln_time_last_checkpoint, ++ rc = lfsck_time_dump(m, ns->ln_time_last_checkpoint, + "time_since_last_checkpoint"); + if (rc < 0) + goto out; + +- rc = lfsck_pos_dump(&buf, &len, &ns->ln_pos_latest_start, ++ rc = lfsck_pos_dump(m, &ns->ln_pos_latest_start, + "latest_start_position"); + if (rc < 0) + goto out; + +- rc = lfsck_pos_dump(&buf, &len, &ns->ln_pos_last_checkpoint, ++ rc = lfsck_pos_dump(m, &ns->ln_pos_last_checkpoint, + "last_checkpoint_position"); + if (rc < 0) + goto out; + +- rc = lfsck_pos_dump(&buf, &len, &ns->ln_pos_first_inconsistent, ++ rc = lfsck_pos_dump(m, &ns->ln_pos_first_inconsistent, + "first_failure_position"); + if (rc < 0) + goto out; +@@ -1166,8 +1157,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, + do_div(new_checked, duration); + if (rtime != 0) + do_div(speed, rtime); +- rc = snprintf(buf, len, +- "checked_phase1: "LPU64"\n" ++ seq_printf(m, "checked_phase1: "LPU64"\n" + "checked_phase2: "LPU64"\n" + "updated_phase1: "LPU64"\n" + "updated_phase2: "LPU64"\n" +@@ -1199,11 +1189,6 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, + ns->ln_run_time_phase2, + speed, + new_checked); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; + + LASSERT(lfsck->li_di_oit != NULL); + +@@ -1232,9 +1217,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, + pos.lp_dir_cookie = 0; + } + spin_unlock(&lfsck->li_lock); +- rc = lfsck_pos_dump(&buf, &len, &pos, "current_position"); +- if (rc <= 0) +- goto out; ++ lfsck_pos_dump(m, &pos, "current_position"); + } else if (ns->ln_status == LS_SCANNING_PHASE2) { + cfs_duration_t duration = cfs_time_current() - + lfsck->li_time_last_checkpoint; +@@ -1252,8 +1235,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, + do_div(speed1, ns->ln_run_time_phase1); + if (rtime != 0) + do_div(speed2, rtime); +- rc = snprintf(buf, len, +- "checked_phase1: "LPU64"\n" ++ seq_printf(m, "checked_phase1: "LPU64"\n" + "checked_phase2: "LPU64"\n" + "updated_phase1: "LPU64"\n" + "updated_phase2: "LPU64"\n" +@@ -1288,11 +1270,6 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, + speed2, + new_checked, + PFID(&ns->ln_fid_latest_scanned_phase2)); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; + } else { + __u64 speed1 = ns->ln_items_checked; + __u64 speed2 = ns->ln_objs_checked_phase2; +@@ -1301,8 +1278,7 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, + do_div(speed1, ns->ln_run_time_phase1); + if (ns->ln_run_time_phase2 != 0) + do_div(speed2, ns->ln_run_time_phase2); +- rc = snprintf(buf, len, +- "checked_phase1: "LPU64"\n" ++ seq_printf(m, "checked_phase1: "LPU64"\n" + "checked_phase2: "LPU64"\n" + "updated_phase1: "LPU64"\n" + "updated_phase2: "LPU64"\n" +@@ -1335,17 +1311,10 @@ lfsck_namespace_dump(const struct lu_env *env, struct lfsck_component *com, + ns->ln_run_time_phase2, + speed1, + speed2); +- if (rc <= 0) +- goto out; +- +- buf += rc; +- len -= rc; + } +- ret = save - len; +- + out: + up_read(&com->lc_sem); +- return ret; ++ return 0; + } + + static int lfsck_namespace_double_scan_main(void *args) +diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c +index 40a4ee3..b0acecb 100644 +--- a/lustre/mdd/mdd_device.c ++++ b/lustre/mdd/mdd_device.c +@@ -812,16 +812,16 @@ static int mdd_process_config(const struct lu_env *env, + ENTRY; + + switch (cfg->lcfg_command) { +- case LCFG_PARAM: { +- struct lprocfs_static_vars lvars; +- +- lprocfs_mdd_init_vars(&lvars); +- rc = class_process_proc_param(PARAM_MDD, lvars.obd_vars, cfg,m); +- if (rc > 0 || rc == -ENOSYS) +- /* we don't understand; pass it on */ +- rc = next->ld_ops->ldo_process_config(env, next, cfg); +- break; +- } ++ case LCFG_PARAM: { ++ struct obd_device *obd = mdd2obd_dev(m); ++ ++ rc = class_process_proc_seq_param(PARAM_MDD, obd->obd_vars, ++ cfg, m); ++ if (rc > 0 || rc == -ENOSYS) ++ /* we don't understand; pass it on */ ++ rc = next->ld_ops->ldo_process_config(env, next, cfg); ++ break; ++ } + case LCFG_SETUP: + rc = next->ld_ops->ldo_process_config(env, next, cfg); + if (rc) +@@ -1497,11 +1497,8 @@ LU_CONTEXT_KEY_DEFINE(mdd, LCT_MD_THREAD); + + static int __init mdd_mod_init(void) + { +- struct lprocfs_static_vars lvars; + int rc; + +- lprocfs_mdd_init_vars(&lvars); +- + rc = lu_kmem_init(mdd_caches); + if (rc) + return rc; +@@ -1517,7 +1514,7 @@ static int __init mdd_mod_init(void) + + rc = class_register_type(&mdd_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lvars.module_vars, ++ NULL, + #endif + LUSTRE_MDD_NAME, &mdd_device_type); + if (rc) +diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h +index daa1dcb..5332b2c 100644 +--- a/lustre/mdd/mdd_internal.h ++++ b/lustre/mdd/mdd_internal.h +@@ -340,7 +340,6 @@ int orph_declare_index_delete(const struct lu_env *, struct mdd_object *, + struct thandle *); + + /* mdd_lproc.c */ +-void lprocfs_mdd_init_vars(struct lprocfs_static_vars *lvars); + int mdd_procfs_init(struct mdd_device *mdd, const char *name); + int mdd_procfs_fini(struct mdd_device *mdd); + +diff --git a/lustre/mdd/mdd_lproc.c b/lustre/mdd/mdd_lproc.c +index 2573e33..e20324c 100644 +--- a/lustre/mdd/mdd_lproc.c ++++ b/lustre/mdd/mdd_lproc.c +@@ -49,56 +49,14 @@ + #include <libcfs/libcfs_string.h> + #include "mdd_internal.h" + +-int mdd_procfs_init(struct mdd_device *mdd, const char *name) ++static ssize_t ++mdd_atime_diff_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct lprocfs_static_vars lvars; +- struct obd_type *type; +- int rc; +- ENTRY; +- +- /* at the moment there is no linkage between lu_type +- * and obd_type, so we lookup obd_type this way */ +- type = class_search_type(LUSTRE_MDD_NAME); +- +- LASSERT(name != NULL); +- LASSERT(type != NULL); +- +- /* Find the type procroot and add the proc entry for this device */ +- lprocfs_mdd_init_vars(&lvars); +- mdd->mdd_proc_entry = lprocfs_register(name, type->typ_procroot, +- lvars.obd_vars, mdd); +- if (IS_ERR(mdd->mdd_proc_entry)) { +- rc = PTR_ERR(mdd->mdd_proc_entry); +- CERROR("Error %d setting up lprocfs for %s\n", +- rc, name); +- mdd->mdd_proc_entry = NULL; +- GOTO(out, rc); +- } +- +- rc = 0; +- +- EXIT; +-out: +- if (rc) +- mdd_procfs_fini(mdd); +- return rc; +-} +- +-int mdd_procfs_fini(struct mdd_device *mdd) +-{ +- if (mdd->mdd_proc_entry) { +- lprocfs_remove(&mdd->mdd_proc_entry); +- mdd->mdd_proc_entry = NULL; +- } +- RETURN(0); +-} +- +-static int lprocfs_wr_atime_diff(struct file *file, const char *buffer, +- unsigned long count, void *data) +-{ +- struct mdd_device *mdd = data; +- char kernbuf[20], *end; +- unsigned long diff = 0; ++ struct seq_file *m = file->private_data; ++ struct mdd_device *mdd = m->private; ++ char kernbuf[20], *end; ++ unsigned long diff = 0; + + if (count > (sizeof(kernbuf) - 1)) + return -EINVAL; +@@ -116,37 +74,35 @@ static int lprocfs_wr_atime_diff(struct file *file, const char *buffer, + return count; + } + +-static int lprocfs_rd_atime_diff(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdd_atime_diff_seq_show(struct seq_file *m, void *data) + { +- struct mdd_device *mdd = data; ++ struct mdd_device *mdd = m->private; + +- *eof = 1; +- return snprintf(page, count, "%lu\n", mdd->mdd_atime_diff); ++ return seq_printf(m, "%lu\n", mdd->mdd_atime_diff); + } +- ++LPROC_SEQ_FOPS(mdd_atime_diff); + + /**** changelogs ****/ +-static int lprocfs_rd_changelog_mask(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdd_changelog_mask_seq_show(struct seq_file *m, void *data) + { +- struct mdd_device *mdd = data; +- int i = 0, rc = 0; +- +- *eof = 1; +- while (i < CL_LAST) { +- if (mdd->mdd_cl.mc_mask & (1 << i)) +- rc += snprintf(page + rc, count - rc, "%s ", +- changelog_type2str(i)); +- i++; +- } +- return rc; ++ struct mdd_device *mdd = m->private; ++ int i = 0; ++ ++ while (i < CL_LAST) { ++ if (mdd->mdd_cl.mc_mask & (1 << i)) ++ seq_printf(m, "%s ", changelog_type2str(i)); ++ i++; ++ } ++ seq_printf(m, "\n"); ++ return 0; + } + +-static int lprocfs_wr_changelog_mask(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdd_changelog_mask_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct mdd_device *mdd = data; ++ struct seq_file *m = file->private_data; ++ struct mdd_device *mdd = m->private; + char *kernbuf; + int rc; + ENTRY; +@@ -168,45 +124,32 @@ out: + OBD_FREE(kernbuf, PAGE_CACHE_SIZE); + return rc; + } +- +-struct cucb_data { +- char *page; +- int count; +- int idx; +-}; ++LPROC_SEQ_FOPS(mdd_changelog_mask); + + static int lprocfs_changelog_users_cb(const struct lu_env *env, + struct llog_handle *llh, + struct llog_rec_hdr *hdr, void *data) + { +- struct llog_changelog_user_rec *rec; +- struct cucb_data *cucb = (struct cucb_data *)data; +- +- LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN); ++ struct llog_changelog_user_rec *rec; ++ struct seq_file *m = data; + +- rec = (struct llog_changelog_user_rec *)hdr; ++ LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN); + +- cucb->idx += snprintf(cucb->page + cucb->idx, cucb->count - cucb->idx, +- CHANGELOG_USER_PREFIX"%-3d "LPU64"\n", +- rec->cur_id, rec->cur_endrec); +- if (cucb->idx >= cucb->count) +- return -ENOSPC; ++ rec = (struct llog_changelog_user_rec *)hdr; + +- return 0; ++ seq_printf(m, CHANGELOG_USER_PREFIX"%-3d "LPU64"\n", ++ rec->cur_id, rec->cur_endrec); ++ return 0; + } + +-static int lprocfs_rd_changelog_users(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdd_changelog_users_seq_show(struct seq_file *m, void *data) + { + struct lu_env env; +- struct mdd_device *mdd = data; ++ struct mdd_device *mdd = m->private; + struct llog_ctxt *ctxt; +- struct cucb_data cucb; + __u64 cur; + int rc; + +- *eof = 1; +- + ctxt = llog_get_context(mdd2obd_dev(mdd), + LLOG_CHANGELOG_USER_ORIG_CTXT); + if (ctxt == NULL) +@@ -223,37 +166,32 @@ static int lprocfs_rd_changelog_users(char *page, char **start, off_t off, + cur = mdd->mdd_cl.mc_index; + spin_unlock(&mdd->mdd_cl.mc_lock); + +- cucb.count = count; +- cucb.page = page; +- cucb.idx = 0; +- +- cucb.idx += snprintf(cucb.page + cucb.idx, cucb.count - cucb.idx, +- "current index: "LPU64"\n", cur); +- +- cucb.idx += snprintf(cucb.page + cucb.idx, cucb.count - cucb.idx, +- "%-5s %s\n", "ID", "index"); ++ seq_printf(m, "current index: "LPU64"\n", cur); ++ seq_printf(m, "%-5s %s\n", "ID", "index"); + + llog_cat_process(&env, ctxt->loc_handle, lprocfs_changelog_users_cb, +- &cucb, 0, 0); ++ &m, 0, 0); + + lu_env_fini(&env); + llog_ctxt_put(ctxt); +- return cucb.idx; ++ return 0; + } ++LPROC_SEQ_FOPS_RO(mdd_changelog_users); + +-static int lprocfs_rd_sync_perm(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdd_sync_perm_seq_show(struct seq_file *m, void *data) + { +- struct mdd_device *mdd = data; ++ struct mdd_device *mdd = m->private; + +- LASSERT(mdd != NULL); +- return snprintf(page, count, "%d\n", mdd->mdd_sync_permission); ++ LASSERT(mdd != NULL); ++ return seq_printf(m, "%d\n", mdd->mdd_sync_permission); + } + +-static int lprocfs_wr_sync_perm(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdd_sync_perm_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct mdd_device *mdd = data; ++ struct seq_file *m = file->private_data; ++ struct mdd_device *mdd = m->private; + int val, rc; + + LASSERT(mdd != NULL); +@@ -264,24 +202,22 @@ static int lprocfs_wr_sync_perm(struct file *file, const char *buffer, + mdd->mdd_sync_permission = !!val; + return count; + } ++LPROC_SEQ_FOPS(mdd_sync_perm); + +-static int lprocfs_rd_lfsck_speed_limit(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdd_lfsck_speed_limit_seq_show(struct seq_file *m, void *data) + { +- struct mdd_device *mdd = data; +- int rc; ++ struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); +- *eof = 1; +- +- rc = lfsck_get_speed(mdd->mdd_bottom, page, count); +- return rc != 0 ? rc : count; ++ return lfsck_get_speed(m, mdd->mdd_bottom); + } + +-static int lprocfs_wr_lfsck_speed_limit(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdd_lfsck_speed_limit_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct mdd_device *mdd = data; ++ struct seq_file *m = file->private_data; ++ struct mdd_device *mdd = m->private; + __u32 val; + int rc; + +@@ -293,25 +229,22 @@ static int lprocfs_wr_lfsck_speed_limit(struct file *file, const char *buffer, + rc = lfsck_set_speed(mdd->mdd_bottom, val); + return rc != 0 ? rc : count; + } ++LPROC_SEQ_FOPS(mdd_lfsck_speed_limit); + +-static int lprocfs_rd_lfsck_async_windows(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdd_lfsck_async_windows_seq_show(struct seq_file *m, void *data) + { +- struct mdd_device *mdd = data; +- int rc; ++ struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); +- *eof = 1; +- +- rc = lfsck_get_windows(mdd->mdd_bottom, page, count); +- +- return rc != 0 ? rc : count; ++ return lfsck_get_windows(m, mdd->mdd_bottom); + } + +-static int lprocfs_wr_lfsck_async_windows(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdd_lfsck_async_windows_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct mdd_device *mdd = data; ++ struct seq_file *m = file->private_data; ++ struct mdd_device *mdd = m->private; + __u32 val; + int rc; + +@@ -322,42 +255,76 @@ static int lprocfs_wr_lfsck_async_windows(struct file *file, const char *buffer, + + return rc != 0 ? rc : count; + } ++LPROC_SEQ_FOPS(mdd_lfsck_async_windows); + +-static int lprocfs_rd_lfsck_namespace(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdd_lfsck_namespace_seq_show(struct seq_file *m, void *data) + { +- struct mdd_device *mdd = data; +- int rc; ++ struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); +- *eof = 1; + +- rc = lfsck_dump(mdd->mdd_bottom, page, count, LT_NAMESPACE); +- return rc; ++ return lfsck_dump(m, mdd->mdd_bottom, LT_NAMESPACE); + } +- +-static struct lprocfs_vars lprocfs_mdd_obd_vars[] = { +- { "atime_diff", lprocfs_rd_atime_diff, lprocfs_wr_atime_diff, 0 }, +- { "changelog_mask", lprocfs_rd_changelog_mask, +- lprocfs_wr_changelog_mask, 0 }, +- { "changelog_users", lprocfs_rd_changelog_users, 0, 0}, +- { "sync_permission", lprocfs_rd_sync_perm, lprocfs_wr_sync_perm, 0 }, +- { "lfsck_speed_limit", lprocfs_rd_lfsck_speed_limit, +- lprocfs_wr_lfsck_speed_limit, 0 }, +- { "lfsck_async_windows", lprocfs_rd_lfsck_async_windows, +- lprocfs_wr_lfsck_async_windows, 0 }, +- { "lfsck_namespace", lprocfs_rd_lfsck_namespace, 0, 0 }, ++LPROC_SEQ_FOPS_RO(mdd_lfsck_namespace); ++ ++static struct lprocfs_seq_vars lprocfs_mdd_obd_vars[] = { ++ { .name = "atime_diff", ++ .fops = &mdd_atime_diff_fops }, ++ { .name = "changelog_mask", ++ .fops = &mdd_changelog_mask_fops }, ++ { .name = "changelog_users", ++ .fops = &mdd_changelog_users_fops }, ++ { .name = "sync_permission", ++ .fops = &mdd_sync_perm_fops }, ++ { .name = "lfsck_speed_limit", ++ .fops = &mdd_lfsck_speed_limit_fops }, ++ { .name = "lfsck_async_windows", ++ .fops = &mdd_lfsck_async_windows_fops }, ++ { .name = "lfsck_namespace", ++ .fops = &mdd_lfsck_namespace_fops }, + { 0 } + }; + +-static struct lprocfs_vars lprocfs_mdd_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, +- { 0 } +-}; +- +-void lprocfs_mdd_init_vars(struct lprocfs_static_vars *lvars) ++int mdd_procfs_init(struct mdd_device *mdd, const char *name) + { +- lvars->module_vars = lprocfs_mdd_module_vars; +- lvars->obd_vars = lprocfs_mdd_obd_vars; ++ struct obd_device *obd = class_name2obd(name); ++ struct obd_type *type; ++ int rc; ++ ENTRY; ++ ++ /* at the moment there is no linkage between lu_type ++ * and obd_type, so we lookup obd_type this way */ ++ type = class_search_type(LUSTRE_MDD_NAME); ++ ++ LASSERT(name != NULL); ++ LASSERT(type != NULL); ++ LASSERT(obd != NULL); ++ ++ /* Find the type procroot and add the proc entry for this device */ ++ obd->obd_vars = lprocfs_mdd_obd_vars; ++ mdd->mdd_proc_entry = lprocfs_seq_register(name, type->typ_procroot, ++ obd->obd_vars, mdd); ++ if (IS_ERR(mdd->mdd_proc_entry)) { ++ rc = PTR_ERR(mdd->mdd_proc_entry); ++ CERROR("Error %d setting up lprocfs for %s\n", ++ rc, name); ++ mdd->mdd_proc_entry = NULL; ++ GOTO(out, rc); ++ } ++ rc = 0; ++ ++ EXIT; ++out: ++ if (rc) ++ mdd_procfs_fini(mdd); ++ return rc; + } + ++int mdd_procfs_fini(struct mdd_device *mdd) ++{ ++ if (mdd->mdd_proc_entry) { ++ lprocfs_remove(&mdd->mdd_proc_entry); ++ mdd->mdd_proc_entry = NULL; ++ } ++ RETURN(0); ++} +diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c +index 63d01cc..abe5d71 100644 +--- a/lustre/obdclass/lprocfs_status.c ++++ b/lustre/obdclass/lprocfs_status.c +@@ -388,11 +388,10 @@ EXPORT_SYMBOL(lprocfs_evict_client_seq_write); + #undef BUFLEN + + struct file_operations lprocfs_evict_client_fops = { +- .owner = THIS_MODULE, +- .read = lprocfs_fops_read, +- .write = lprocfs_fops_write, +- .open = lprocfs_evict_client_open, +- .release = lprocfs_evict_client_release, ++ .owner = THIS_MODULE, ++ .open = lprocfs_evict_client_open, ++ .release = lprocfs_evict_client_release, ++ .write = lprocfs_evict_client_seq_write, + }; + EXPORT_SYMBOL(lprocfs_evict_client_fops); + #endif +diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c +index e303fd6..1759a7d 100644 +--- a/lustre/ofd/lproc_ofd.c ++++ b/lustre/ofd/lproc_ofd.c +@@ -47,80 +47,75 @@ + + #ifdef LPROCFS + +-static int lprocfs_ofd_rd_seqs(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_seqs_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + +- *eof = 1; +- return snprintf(page, count, "%u\n", ofd->ofd_seq_count); ++ return seq_printf(m, "%u\n", ofd->ofd_seq_count); + } ++LPROC_SEQ_FOPS_RO(ofd_seqs); + +-static int lprocfs_ofd_rd_tot_dirty(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_tot_dirty_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd; + + LASSERT(obd != NULL); + ofd = ofd_dev(obd->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, LPU64"\n", ofd->ofd_tot_dirty); ++ return seq_printf(m, LPU64"\n", ofd->ofd_tot_dirty); + } ++LPROC_SEQ_FOPS_RO(ofd_tot_dirty); + +-static int lprocfs_ofd_rd_tot_granted(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_tot_granted_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd; + + LASSERT(obd != NULL); + ofd = ofd_dev(obd->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, LPU64"\n", ofd->ofd_tot_granted); ++ return seq_printf(m, LPU64"\n", ofd->ofd_tot_granted); + } ++LPROC_SEQ_FOPS_RO(ofd_tot_granted); + +-static int lprocfs_ofd_rd_tot_pending(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_tot_pending_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd; + + LASSERT(obd != NULL); + ofd = ofd_dev(obd->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, LPU64"\n", ofd->ofd_tot_pending); ++ return seq_printf(m, LPU64"\n", ofd->ofd_tot_pending); + } ++LPROC_SEQ_FOPS_RO(ofd_tot_pending); + +-static int lprocfs_ofd_rd_grant_precreate(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_grant_precreate_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct obd_device *obd = m->private; + + LASSERT(obd != NULL); +- *eof = 1; +- return snprintf(page, count, "%ld\n", ++ return seq_printf(m, "%ld\n", + obd->obd_self_export->exp_filter_data.fed_grant); + } ++LPROC_SEQ_FOPS_RO(ofd_grant_precreate); + +-static int lprocfs_ofd_rd_grant_ratio(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_grant_ratio_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd; + + LASSERT(obd != NULL); + ofd = ofd_dev(obd->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%d%%\n", ++ return seq_printf(m, "%d%%\n", + (int) ofd_grant_reserved(ofd, 100)); + } + +-static int lprocfs_ofd_wr_grant_ratio(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_grant_ratio_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + int val; + int rc; +@@ -144,23 +139,24 @@ static int lprocfs_ofd_wr_grant_ratio(struct file *file, const char *buffer, + spin_unlock(&ofd->ofd_grant_lock); + return count; + } ++LPROC_SEQ_FOPS(ofd_grant_ratio); + +-static int lprocfs_ofd_rd_precreate_batch(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_precreate_batch_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd; + + LASSERT(obd != NULL); + ofd = ofd_dev(obd->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%d\n", ofd->ofd_precreate_batch); ++ return seq_printf(m, "%d\n", ofd->ofd_precreate_batch); + } + +-static int lprocfs_ofd_wr_precreate_batch(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_precreate_batch_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = (struct obd_device *)data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + int val; + int rc; +@@ -177,11 +173,11 @@ static int lprocfs_ofd_wr_precreate_batch(struct file *file, const char *buffer, + spin_unlock(&ofd->ofd_batch_lock); + return count; + } ++LPROC_SEQ_FOPS(ofd_precreate_batch); + +-static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_last_id_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd; + struct ofd_seq *oseq = NULL; + int retval = 0, rc; +@@ -199,35 +195,32 @@ static int lprocfs_ofd_rd_last_id(char *page, char **start, off_t off, + fid_idif_seq(ostid_id(&oseq->os_oi), + ofd->ofd_lut.lut_lsd.lsd_osd_index) : + ostid_seq(&oseq->os_oi); +- rc = snprintf(page, count, DOSTID"\n", seq, +- ostid_id(&oseq->os_oi)); ++ rc = seq_printf(m, DOSTID"\n", seq, ostid_id(&oseq->os_oi)); + if (rc < 0) { + retval = rc; + break; + } +- page += rc; +- count -= rc; + retval += rc; + } + read_unlock(&ofd->ofd_seq_list_lock); + return retval; + } ++LPROC_SEQ_FOPS_RO(ofd_last_id); + +-int lprocfs_ofd_rd_fmd_max_num(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_fmd_max_num_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); +- int rc; + +- rc = snprintf(page, count, "%u\n", ofd->ofd_fmd_max_num); +- return rc; ++ return seq_printf(m, "%u\n", ofd->ofd_fmd_max_num); + } + +-int lprocfs_ofd_wr_fmd_max_num(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_fmd_max_num_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + int val; + int rc; +@@ -242,22 +235,22 @@ int lprocfs_ofd_wr_fmd_max_num(struct file *file, const char *buffer, + ofd->ofd_fmd_max_num = val; + return count; + } ++LPROC_SEQ_FOPS(ofd_fmd_max_num); + +-int lprocfs_ofd_rd_fmd_max_age(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_fmd_max_age_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); +- int rc; + +- rc = snprintf(page, count, "%ld\n", ofd->ofd_fmd_max_age / HZ); +- return rc; ++ return seq_printf(m, "%ld\n", ofd->ofd_fmd_max_age / HZ); + } + +-int lprocfs_ofd_wr_fmd_max_age(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_fmd_max_age_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + int val; + int rc; +@@ -272,22 +265,22 @@ int lprocfs_ofd_wr_fmd_max_age(struct file *file, const char *buffer, + ofd->ofd_fmd_max_age = val * HZ; + return count; + } ++LPROC_SEQ_FOPS(ofd_fmd_max_age); + +-static int lprocfs_ofd_rd_capa(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_capa_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- int rc; ++ struct obd_device *obd = m->private; + +- rc = snprintf(page, count, "capability on: %s\n", +- obd->u.filter.fo_fl_oss_capa ? "oss" : ""); +- return rc; ++ return seq_printf(m, "capability on: %s\n", ++ obd->u.filter.fo_fl_oss_capa ? "oss" : ""); + } + +-static int lprocfs_ofd_wr_capa(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_capa_seq_write(struct file *file, const char *buffer, size_t count, ++ loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + int val, rc; + + rc = lprocfs_write_helper(buffer, count, &val); +@@ -306,28 +299,30 @@ static int lprocfs_ofd_wr_capa(struct file *file, const char *buffer, + val ? "enabled" : "disabled"); + return count; + } ++LPROC_SEQ_FOPS(ofd_capa); + +-static int lprocfs_ofd_rd_capa_count(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_capa_count_seq_show(struct seq_file *m, void *data) + { +- return snprintf(page, count, "%d %d\n", ++ return seq_printf(m, "%d %d\n", + capa_count[CAPA_SITE_CLIENT], + capa_count[CAPA_SITE_SERVER]); + } ++LPROC_SEQ_FOPS_RO(ofd_capa_count); + +-int lprocfs_ofd_rd_degraded(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_degraded_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%u\n", ofd->ofd_raid_degraded); ++ return seq_printf(m, "%u\n", ofd->ofd_raid_degraded); + } + +-int lprocfs_ofd_wr_degraded(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_degraded_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + int val, rc; + +@@ -338,38 +333,37 @@ int lprocfs_ofd_wr_degraded(struct file *file, const char *buffer, + spin_lock(&ofd->ofd_flags_lock); + ofd->ofd_raid_degraded = !!val; + spin_unlock(&ofd->ofd_flags_lock); +- + return count; + } ++LPROC_SEQ_FOPS(ofd_degraded); + +-int lprocfs_ofd_rd_fstype(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int ofd_fstype_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + struct lu_device *d; + + LASSERT(ofd->ofd_osd); + d = &ofd->ofd_osd->dd_lu_dev; + LASSERT(d->ld_type); +- return snprintf(page, count, "%s\n", d->ld_type->ldt_name); ++ return seq_printf(m, "%s\n", d->ld_type->ldt_name); + } ++LPROC_SEQ_FOPS_RO(ofd_fstype); + +-int lprocfs_ofd_rd_syncjournal(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_syncjournal_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); +- int rc; + +- rc = snprintf(page, count, "%u\n", ofd->ofd_syncjournal); +- return rc; ++ return seq_printf(m, "%u\n", ofd->ofd_syncjournal); + } + +-int lprocfs_ofd_wr_syncjournal(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_syncjournal_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + int val; + int rc; +@@ -388,27 +382,27 @@ int lprocfs_ofd_wr_syncjournal(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(ofd_syncjournal); + + static char *sync_on_cancel_states[] = {"never", + "blocking", + "always" }; + +-int lprocfs_ofd_rd_sync_lock_cancel(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_sync_lock_cancel_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct lu_target *tgt = obd->u.obt.obt_lut; +- int rc; + +- rc = snprintf(page, count, "%s\n", +- sync_on_cancel_states[tgt->lut_sync_lock_cancel]); +- return rc; ++ return seq_printf(m, "%s\n", ++ sync_on_cancel_states[tgt->lut_sync_lock_cancel]); + } + +-int lprocfs_ofd_wr_sync_lock_cancel(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_sync_lock_cancel_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct lu_target *tgt = obd->u.obt.obt_lut; + int val = -1; + int i; +@@ -436,22 +430,22 @@ int lprocfs_ofd_wr_sync_lock_cancel(struct file *file, const char *buffer, + spin_unlock(&tgt->lut_flags_lock); + return count; + } ++LPROC_SEQ_FOPS(ofd_sync_lock_cancel); + +-int lprocfs_ofd_rd_grant_compat_disable(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_grant_compat_disable_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); +- int rc; + +- rc = snprintf(page, count, "%u\n", ofd->ofd_grant_compat_disable); +- return rc; ++ return seq_printf(m, "%u\n", ofd->ofd_grant_compat_disable); + } + +-int lprocfs_ofd_wr_grant_compat_disable(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_grant_compat_disable_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + int val; + int rc; +@@ -469,41 +463,43 @@ int lprocfs_ofd_wr_grant_compat_disable(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(ofd_grant_compat_disable); + +-int lprocfs_ofd_rd_soft_sync_limit(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_soft_sync_limit_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + +- return lprocfs_rd_uint(page, start, off, count, eof, +- &ofd->ofd_soft_sync_limit); ++ return lprocfs_uint_seq_show(m, &ofd->ofd_soft_sync_limit); + } + +-int lprocfs_ofd_wr_soft_sync_limit(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_soft_sync_limit_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + +- return lprocfs_wr_uint(file, buffer, count, &ofd->ofd_soft_sync_limit); ++ return lprocfs_uint_seq_write(file, buffer, count, ++ (loff_t *) &ofd->ofd_soft_sync_limit); + } ++LPROC_SEQ_FOPS(ofd_soft_sync_limit); + +-static int lprocfs_rd_lfsck_speed_limit(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_lfsck_speed_limit_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + +- *eof = 1; +- +- return lfsck_get_speed(ofd->ofd_osd, page, count); ++ return lfsck_get_speed(m, ofd->ofd_osd); + } + +-static int lprocfs_wr_lfsck_speed_limit(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ofd_lfsck_speed_limit_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct seq_file *m = file->private_data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + __u32 val; + int rc; +@@ -516,84 +512,108 @@ static int lprocfs_wr_lfsck_speed_limit(struct file *file, const char *buffer, + + return rc != 0 ? rc : count; + } ++LPROC_SEQ_FOPS(ofd_lfsck_speed_limit); + +-static int lprocfs_rd_lfsck_layout(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ofd_lfsck_layout_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); + +- *eof = 1; +- +- return lfsck_dump(ofd->ofd_osd, page, count, LT_LAYOUT); +-} +- +-static struct lprocfs_vars lprocfs_ofd_obd_vars[] = { +- { "uuid", lprocfs_rd_uuid, 0, 0 }, +- { "blocksize", lprocfs_rd_blksize, 0, 0 }, +- { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 }, +- { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 }, +- { "kbytesavail", lprocfs_rd_kbytesavail, 0, 0 }, +- { "filestotal", lprocfs_rd_filestotal, 0, 0 }, +- { "filesfree", lprocfs_rd_filesfree, 0, 0 }, +- { "seqs_allocated", lprocfs_ofd_rd_seqs, 0, 0 }, +- { "fstype", lprocfs_ofd_rd_fstype, 0, 0 }, +- { "last_id", lprocfs_ofd_rd_last_id, 0, 0 }, +- { "tot_dirty", lprocfs_ofd_rd_tot_dirty, 0, 0 }, +- { "tot_pending", lprocfs_ofd_rd_tot_pending, 0, 0 }, +- { "tot_granted", lprocfs_ofd_rd_tot_granted, 0, 0 }, +- { "grant_precreate", lprocfs_ofd_rd_grant_precreate, 0, 0 }, +- { "grant_ratio", lprocfs_ofd_rd_grant_ratio, +- lprocfs_ofd_wr_grant_ratio, 0, 0 }, +- { "precreate_batch", lprocfs_ofd_rd_precreate_batch, +- lprocfs_ofd_wr_precreate_batch, 0 }, +- { "recovery_status", lprocfs_obd_rd_recovery_status, 0, 0 }, +- { "recovery_time_soft", lprocfs_obd_rd_recovery_time_soft, +- lprocfs_obd_wr_recovery_time_soft, 0}, +- { "recovery_time_hard", lprocfs_obd_rd_recovery_time_hard, +- lprocfs_obd_wr_recovery_time_hard, 0}, +- { "evict_client", 0, lprocfs_wr_evict_client, 0, +- &lprocfs_evict_client_fops}, +- { "num_exports", lprocfs_rd_num_exports, 0, 0 }, +- { "degraded", lprocfs_ofd_rd_degraded, +- lprocfs_ofd_wr_degraded, 0}, +- { "sync_journal", lprocfs_ofd_rd_syncjournal, +- lprocfs_ofd_wr_syncjournal, 0 }, +- { "sync_on_lock_cancel", lprocfs_ofd_rd_sync_lock_cancel, +- lprocfs_ofd_wr_sync_lock_cancel, 0 }, +- { "instance", lprocfs_target_rd_instance, 0 }, +- { "ir_factor", lprocfs_obd_rd_ir_factor, +- lprocfs_obd_wr_ir_factor, 0}, +- { "grant_compat_disable", lprocfs_ofd_rd_grant_compat_disable, +- lprocfs_ofd_wr_grant_compat_disable, 0 }, +- { "client_cache_count", lprocfs_ofd_rd_fmd_max_num, +- lprocfs_ofd_wr_fmd_max_num, 0 }, +- { "client_cache_seconds", lprocfs_ofd_rd_fmd_max_age, +- lprocfs_ofd_wr_fmd_max_age, 0 }, +- { "capa", lprocfs_ofd_rd_capa, +- lprocfs_ofd_wr_capa, 0 }, +- { "capa_count", lprocfs_ofd_rd_capa_count, 0, 0 }, +- { "job_cleanup_interval", lprocfs_rd_job_interval, +- lprocfs_wr_job_interval, 0}, +- { "soft_sync_limit", lprocfs_ofd_rd_soft_sync_limit, +- lprocfs_ofd_wr_soft_sync_limit, 0}, +- { "lfsck_speed_limit", lprocfs_rd_lfsck_speed_limit, +- lprocfs_wr_lfsck_speed_limit, 0 }, +- { "lfsck_layout", lprocfs_rd_lfsck_layout, 0, 0 }, +- { 0 } +-}; +- +-static struct lprocfs_vars lprocfs_ofd_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, ++ return lfsck_dump(m, ofd->ofd_osd, LT_LAYOUT); ++} ++LPROC_SEQ_FOPS_RO(ofd_lfsck_layout); ++ ++LPROC_SEQ_FOPS_RO_TYPE(ofd, uuid); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, blksize); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, kbytestotal); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, kbytesfree); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, kbytesavail); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, filestotal); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, filesfree); ++ ++LPROC_SEQ_FOPS_RO_TYPE(ofd, recovery_status); ++LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_soft); ++LPROC_SEQ_FOPS_RW_TYPE(ofd, recovery_time_hard); ++LPROC_SEQ_FOPS_WO_TYPE(ofd, evict_client); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, num_exports); ++LPROC_SEQ_FOPS_RO_TYPE(ofd, target_instance); ++LPROC_SEQ_FOPS_RW_TYPE(ofd, ir_factor); ++LPROC_SEQ_FOPS_RW_TYPE(ofd, job_interval); ++ ++struct lprocfs_seq_vars lprocfs_ofd_obd_vars[] = { ++ { .name = "uuid", ++ .fops = &ofd_uuid_fops }, ++ { .name = "blocksize", ++ .fops = &ofd_blksize_fops }, ++ { .name = "kbytestotal", ++ .fops = &ofd_kbytestotal_fops }, ++ { .name = "kbytesfree", ++ .fops = &ofd_kbytesfree_fops }, ++ { .name = "kbytesavail", ++ .fops = &ofd_kbytesavail_fops }, ++ { .name = "filestotal", ++ .fops = &ofd_filestotal_fops }, ++ { .name = "filesfree", ++ .fops = &ofd_filesfree_fops }, ++ { .name = "seqs_allocated", ++ .fops = &ofd_seqs_fops }, ++ { .name = "fstype", ++ .fops = &ofd_fstype_fops }, ++ { .name = "last_id", ++ .fops = &ofd_last_id_fops }, ++ { .name = "tot_dirty", ++ .fops = &ofd_tot_dirty_fops }, ++ { .name = "tot_pending", ++ .fops = &ofd_tot_pending_fops }, ++ { .name = "tot_granted", ++ .fops = &ofd_tot_granted_fops }, ++ { .name = "grant_precreate", ++ .fops = &ofd_grant_precreate_fops }, ++ { .name = "grant_ratio", ++ .fops = &ofd_grant_ratio_fops }, ++ { .name = "precreate_batch", ++ .fops = &ofd_precreate_batch_fops }, ++ { .name = "recovery_status", ++ .fops = &ofd_recovery_status_fops }, ++ { .name = "recovery_time_soft", ++ .fops = &ofd_recovery_time_soft_fops }, ++ { .name = "recovery_time_hard", ++ .fops = &ofd_recovery_time_hard_fops }, ++ { .name = "evict_client", ++ .fops = &ofd_evict_client_fops }, ++ { .name = "num_exports", ++ .fops = &ofd_num_exports_fops }, ++ { .name = "degraded", ++ .fops = &ofd_degraded_fops }, ++ { .name = "sync_journal", ++ .fops = &ofd_syncjournal_fops }, ++ { .name = "sync_on_lock_cancel", ++ .fops = &ofd_sync_lock_cancel_fops }, ++ { .name = "instance", ++ .fops = &ofd_target_instance_fops }, ++ { .name = "ir_factor", ++ .fops = &ofd_ir_factor_fops }, ++ { .name = "grant_compat_disable", ++ .fops = &ofd_grant_compat_disable_fops }, ++ { .name = "client_cache_count", ++ .fops = &ofd_fmd_max_num_fops }, ++ { .name = "client_cache_seconds", ++ .fops = &ofd_fmd_max_age_fops }, ++ { .name = "capa", ++ .fops = &ofd_capa_fops }, ++ { .name = "capa_count", ++ .fops = &ofd_capa_count_fops }, ++ { .name = "job_cleanup_interval", ++ .fops = &ofd_job_interval_fops }, ++ { .name = "soft_sync_limit", ++ .fops = &ofd_soft_sync_limit_fops }, ++ { .name = "lfsck_speed_limit", ++ .fops = &ofd_lfsck_speed_limit_fops }, ++ { .name = "lfsck_layout", ++ .fops = &ofd_lfsck_layout_fops }, + { 0 } + }; + +-void lprocfs_ofd_init_vars(struct lprocfs_static_vars *lvars) +-{ +- lvars->module_vars = lprocfs_ofd_module_vars; +- lvars->obd_vars = lprocfs_ofd_obd_vars; +-} +- + void ofd_stats_counter_init(struct lprocfs_stats *stats) + { + LASSERT(stats && stats->ls_num >= LPROC_OFD_STATS_LAST); +diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c +index 3559991..f59f843 100644 +--- a/lustre/ofd/ofd_dev.c ++++ b/lustre/ofd/ofd_dev.c +@@ -240,8 +240,7 @@ static int ofd_process_config(const struct lu_env *env, struct lu_device *d, + + switch (cfg->lcfg_command) { + case LCFG_PARAM: { +- struct lprocfs_static_vars lvars; +- ++ struct obd_device *obd = ofd_obd(m); + /* For interoperability */ + struct cfg_interop_param *ptr = NULL; + struct lustre_cfg *old_cfg = NULL; +@@ -279,8 +278,7 @@ static int ofd_process_config(const struct lu_env *env, struct lu_device *d, + break; + } + +- lprocfs_ofd_init_vars(&lvars); +- rc = class_process_proc_param(PARAM_OST, lvars.obd_vars, cfg, ++ rc = class_process_proc_seq_param(PARAM_OST, obd->obd_vars, cfg, + d->ld_obd); + if (rc > 0 || rc == -ENOSYS) { + CDEBUG(D_CONFIG, "pass param %s down the stack.\n", +@@ -492,9 +490,10 @@ static struct lu_device_operations ofd_lu_ops = { + .ldo_prepare = ofd_prepare, + }; + ++LPROC_SEQ_FOPS(lprocfs_nid_stats_clear); ++ + static int ofd_procfs_init(struct ofd_device *ofd) + { +- struct lprocfs_static_vars lvars; + struct obd_device *obd = ofd_obd(ofd); + cfs_proc_dir_entry_t *entry; + int rc = 0; +@@ -503,8 +502,8 @@ static int ofd_procfs_init(struct ofd_device *ofd) + + /* lprocfs must be setup before the ofd so state can be safely added + * to /proc incrementally as the ofd is setup */ +- lprocfs_ofd_init_vars(&lvars); +- rc = lprocfs_obd_setup(obd, lvars.obd_vars); ++ obd->obd_vars = lprocfs_ofd_obd_vars; ++ rc = lprocfs_seq_obd_setup(obd); + if (rc) { + CERROR("%s: lprocfs_obd_setup failed: %d.\n", + obd->obd_name, rc); +@@ -520,7 +519,7 @@ static int ofd_procfs_init(struct ofd_device *ofd) + + obd->obd_uses_nid_stats = 1; + +- entry = lprocfs_register("exports", obd->obd_proc_entry, NULL, NULL); ++ entry = lprocfs_seq_register("exports", obd->obd_proc_entry, NULL, NULL); + if (IS_ERR(entry)) { + rc = PTR_ERR(entry); + CERROR("%s: error %d setting up lprocfs for %s\n", +@@ -530,8 +529,10 @@ static int ofd_procfs_init(struct ofd_device *ofd) + obd->obd_proc_exports_entry = entry; + + entry = lprocfs_add_simple(obd->obd_proc_exports_entry, "clear", +- lprocfs_nid_stats_clear_read, +- lprocfs_nid_stats_clear_write, obd, NULL); ++#ifndef HAVE_ONLY_PROCFS_SEQ ++ NULL, NULL, ++#endif ++ obd, &lprocfs_nid_stats_clear_fops); + if (IS_ERR(entry)) { + rc = PTR_ERR(entry); + CERROR("%s: add proc entry 'clear' failed: %d.\n", +@@ -547,7 +548,7 @@ static int ofd_procfs_init(struct ofd_device *ofd) + GOTO(remove_entry_clear, rc); + RETURN(0); + remove_entry_clear: +- lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); ++ lprocfs_remove(&obd->obd_proc_exports_entry); + obd_cleanup: + lprocfs_obd_cleanup(obd); + lprocfs_free_obd_stats(obd); +@@ -560,29 +561,28 @@ static void ofd_procfs_add_brw_stats_symlink(struct ofd_device *ofd) + struct obd_device *obd = ofd_obd(ofd); + struct obd_device *osd_obd = ofd->ofd_osd_exp->exp_obd; + cfs_proc_dir_entry_t *osd_root = osd_obd->obd_type->typ_procroot; +- cfs_proc_dir_entry_t *osd_dir; ++ cfs_proc_dir_entry_t *osd_dir = osd_obd->obd_type->typ_procsym; + +- osd_dir = lprocfs_srch(osd_root, obd->obd_name); + if (osd_dir == NULL) + return; + +- if (lprocfs_srch(osd_dir, "brw_stats") != NULL) ++ //if (lprocfs_srch(osd_dir, "brw_stats") != NULL) + lprocfs_add_symlink("brw_stats", obd->obd_proc_entry, + "../../%s/%s/brw_stats", + osd_root->name, osd_dir->name); + +- if (lprocfs_srch(osd_dir, "read_cache_enable") != NULL) ++ //if (lprocfs_srch(osd_dir, "read_cache_enable") != NULL) + lprocfs_add_symlink("read_cache_enable", obd->obd_proc_entry, + "../../%s/%s/read_cache_enable", + osd_root->name, osd_dir->name); + +- if (lprocfs_srch(osd_dir, "readcache_max_filesize") != NULL) ++ //if (lprocfs_srch(osd_dir, "readcache_max_filesize") != NULL) + lprocfs_add_symlink("readcache_max_filesize", + obd->obd_proc_entry, + "../../%s/%s/readcache_max_filesize", + osd_root->name, osd_dir->name); + +- if (lprocfs_srch(osd_dir, "writethrough_cache_enable") != NULL) ++ //if (lprocfs_srch(osd_dir, "writethrough_cache_enable") != NULL) + lprocfs_add_symlink("writethrough_cache_enable", + obd->obd_proc_entry, + "../../%s/%s/writethrough_cache_enable", +@@ -593,13 +593,8 @@ static void ofd_procfs_fini(struct ofd_device *ofd) + { + struct obd_device *obd = ofd_obd(ofd); + +- lprocfs_remove_proc_entry("writethrough_cache_enable", +- obd->obd_proc_entry); +- lprocfs_remove_proc_entry("readcache_max_filesize", +- obd->obd_proc_entry); +- lprocfs_remove_proc_entry("read_cache_enable", obd->obd_proc_entry); +- lprocfs_remove_proc_entry("brw_stats", obd->obd_proc_entry); +- lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); ++ lprocfs_remove(&obd->obd_proc_exports_entry); ++ lprocfs_remove(&obd->obd_proc_entry); + lprocfs_free_per_client_stats(obd); + lprocfs_obd_cleanup(obd); + lprocfs_free_obd_stats(obd); +@@ -2363,7 +2358,6 @@ static struct lu_device_type ofd_device_type = { + + int __init ofd_init(void) + { +- struct lprocfs_static_vars lvars; + int rc; + + rc = lu_kmem_init(ofd_caches); +@@ -2376,11 +2370,9 @@ int __init ofd_init(void) + return(rc); + } + +- lprocfs_ofd_init_vars(&lvars); +- + rc = class_register_type(&ofd_obd_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lvars.module_vars, ++ NULL, + #endif + LUSTRE_OST_NAME, &ofd_device_type); + return rc; +diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h +index b22ceec..79dfaa9 100644 +--- a/lustre/ofd/ofd_internal.h ++++ b/lustre/ofd/ofd_internal.h +@@ -390,13 +390,9 @@ int ofd_txn_stop_cb(const struct lu_env *env, struct thandle *txn, + + /* lproc_ofd.c */ + #ifdef LPROCFS +-void lprocfs_ofd_init_vars(struct lprocfs_static_vars *lvars); ++extern struct lprocfs_seq_vars lprocfs_ofd_obd_vars[]; + void ofd_stats_counter_init(struct lprocfs_stats *stats); + #else +-static void lprocfs_ofd_init_vars(struct lprocfs_static_vars *lvars) +-{ +- memset(lvars, 0, sizeof(*lvars)); +-} + static inline void ofd_stats_counter_init(struct lprocfs_stats *stats) {} + #endif + +diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c +index 6f369d0..9027533 100644 +--- a/lustre/osd-ldiskfs/osd_handler.c ++++ b/lustre/osd-ldiskfs/osd_handler.c +@@ -5882,6 +5882,7 @@ static int osd_obd_connect(const struct lu_env *env, struct obd_export **exp, + osd->od_connects++; + spin_unlock(&osd->od_osfs_lock); + ++ obd->obd_type->typ_procsym = osd->od_proc_entry; + RETURN(0); + } + +diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c +index 36bf6a4..40d2c67 100644 +--- a/lustre/osd-zfs/osd_handler.c ++++ b/lustre/osd-zfs/osd_handler.c +@@ -813,6 +813,7 @@ static int osd_obd_connect(const struct lu_env *env, struct obd_export **exp, + osd->od_connects++; + spin_unlock(&osd->od_objset.lock); + ++ obd->obd_type->typ_procsym = osd->od_proc_entry; + RETURN(0); + } + +-- +1.8.5.3 + |