From 254e187c761ee0202bdd8d69475a412ee682de55 Mon Sep 17 00:00:00 2001 From: Alexey Shvetsov Date: Wed, 12 Feb 2014 10:41:36 +0400 Subject: Drop unneded patch Package-Manager: portage-2.2.8-r1 RepoMan-Options: --force --- sys-cluster/lustre/ChangeLog | 28 + ...ld-make-AC-check-for-linux-arch-sandbox-f.patch | 95 + ...4-lfsck-old-single-OI-MDT-always-scrubbed.patch | 41 - ...ld-make-AC-check-for-linux-arch-sandbox-f.patch | 95 - ...cfs-update-zfs-proc-handling-to-seq_files.patch | 207 +++ ...rocfs-move-mgs-proc-handling-to-seq_files.patch | 356 ++++ ...cfs-update-zfs-proc-handling-to-seq_files.patch | 207 --- .../0004-LU-3319-procfs-fix-symlink-handling.patch | 371 ++++ ...rocfs-move-mgs-proc-handling-to-seq_files.patch | 356 ---- .../0005-LU-3319-procfs-fix-symlink-handling.patch | 371 ---- ...rocfs-move-osp-proc-handling-to-seq_files.patch | 799 ++++++++ ...rocfs-move-lod-proc-handling-to-seq_files.patch | 597 ++++++ ...rocfs-move-osp-proc-handling-to-seq_files.patch | 799 -------- ...rocfs-move-lod-proc-handling-to-seq_files.patch | 597 ------ ...cfs-move-mdd-ofd-proc-handling-to-seq_fil.patch | 1941 ++++++++++++++++++++ ...cfs-move-mdd-ofd-proc-handling-to-seq_fil.patch | 1941 -------------------- ...cfs-move-mdt-mds-proc-handling-to-seq_fil.patch | 1553 ++++++++++++++++ ...cfs-move-mdt-mds-proc-handling-to-seq_fil.patch | 1553 ---------------- ...cfs-update-ldiskfs-proc-handling-to-seq_f.patch | 807 ++++++++ ...0010-LU-3319-lprocfs-client-side-cleanups.patch | 463 +++++ ...cfs-update-ldiskfs-proc-handling-to-seq_f.patch | 807 -------- ...0011-LU-3319-lprocfs-client-side-cleanups.patch | 463 ----- ...-LU-3974-llite-use-new-struct-dir_context.patch | 265 +++ ...-LU-3974-llite-invalidatepage-api-changed.patch | 134 ++ ...-LU-3974-llite-use-new-struct-dir_context.patch | 265 --- ...-LU-3974-llite-invalidatepage-api-changed.patch | 134 -- 26 files changed, 7616 insertions(+), 7629 deletions(-) create mode 100644 sys-cluster/lustre/files/0001-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch delete mode 100644 sys-cluster/lustre/files/0001-LU-4554-lfsck-old-single-OI-MDT-always-scrubbed.patch delete mode 100644 sys-cluster/lustre/files/0002-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch create mode 100644 sys-cluster/lustre/files/0002-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch create mode 100644 sys-cluster/lustre/files/0003-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch delete mode 100644 sys-cluster/lustre/files/0003-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch create mode 100644 sys-cluster/lustre/files/0004-LU-3319-procfs-fix-symlink-handling.patch delete mode 100644 sys-cluster/lustre/files/0004-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch delete mode 100644 sys-cluster/lustre/files/0005-LU-3319-procfs-fix-symlink-handling.patch create mode 100644 sys-cluster/lustre/files/0005-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch create mode 100644 sys-cluster/lustre/files/0006-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch delete mode 100644 sys-cluster/lustre/files/0006-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch delete mode 100644 sys-cluster/lustre/files/0007-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch create mode 100644 sys-cluster/lustre/files/0007-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch delete mode 100644 sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch create mode 100644 sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch delete mode 100644 sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch create mode 100644 sys-cluster/lustre/files/0009-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch create mode 100644 sys-cluster/lustre/files/0010-LU-3319-lprocfs-client-side-cleanups.patch delete mode 100644 sys-cluster/lustre/files/0010-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch delete mode 100644 sys-cluster/lustre/files/0011-LU-3319-lprocfs-client-side-cleanups.patch create mode 100644 sys-cluster/lustre/files/0011-LU-3974-llite-use-new-struct-dir_context.patch create mode 100644 sys-cluster/lustre/files/0012-LU-3974-llite-invalidatepage-api-changed.patch delete mode 100644 sys-cluster/lustre/files/0012-LU-3974-llite-use-new-struct-dir_context.patch delete mode 100644 sys-cluster/lustre/files/0013-LU-3974-llite-invalidatepage-api-changed.patch (limited to 'sys-cluster') diff --git a/sys-cluster/lustre/ChangeLog b/sys-cluster/lustre/ChangeLog index 53b8be5ce..dc604d084 100644 --- a/sys-cluster/lustre/ChangeLog +++ b/sys-cluster/lustre/ChangeLog @@ -2,6 +2,34 @@ # Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 # $Header: $ + 12 Feb 2014; Alexey Shvetsov + +files/0001-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch, + +files/0002-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch, + +files/0003-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch, + +files/0004-LU-3319-procfs-fix-symlink-handling.patch, + +files/0005-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch, + +files/0006-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch, + +files/0007-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch, + +files/0008-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch, + +files/0009-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch, + +files/0010-LU-3319-lprocfs-client-side-cleanups.patch, + +files/0011-LU-3974-llite-use-new-struct-dir_context.patch, + +files/0012-LU-3974-llite-invalidatepage-api-changed.patch, + -files/0001-LU-4554-lfsck-old-single-OI-MDT-always-scrubbed.patch, + -files/0002-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch, + -files/0003-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch, + -files/0004-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch, + -files/0005-LU-3319-procfs-fix-symlink-handling.patch, + -files/0006-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch, + -files/0007-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch, + -files/0008-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch, + -files/0009-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch, + -files/0010-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch, + -files/0011-LU-3319-lprocfs-client-side-cleanups.patch, + -files/0012-LU-3974-llite-use-new-struct-dir_context.patch, + -files/0013-LU-3974-llite-invalidatepage-api-changed.patch: + Drop unneded patch + 12 Feb 2014; Alexey Shvetsov +files/0001-LU-4554-lfsck-old-single-OI-MDT-always-scrubbed.patch, +files/0002-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch, diff --git a/sys-cluster/lustre/files/0001-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch b/sys-cluster/lustre/files/0001-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch new file mode 100644 index 000000000..caa6587f5 --- /dev/null +++ b/sys-cluster/lustre/files/0001-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch @@ -0,0 +1,95 @@ +From 247c87f4a981fd26bfaf219930193b1a35865736 Mon Sep 17 00:00:00 2001 +From: Alexey Shvetsov +Date: Mon, 18 Mar 2013 16:22:27 +0400 +Subject: [PATCH 01/12] LU-2982 build: make AC check for linux arch sandbox + friendly + +this commit makes AC check for linux kernel arch sandbox friendly + +Signed-off-by: Alexey Shvetsov +Change-Id: I173cd892bca5587519806cf6d300a5053dfb935f +Signed-off-by: Alexey Shvetsov +--- + config/lustre-build-linux.m4 | 66 ++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 58 insertions(+), 8 deletions(-) + +diff --git a/config/lustre-build-linux.m4 b/config/lustre-build-linux.m4 +index 894101c..8062ace 100644 +--- a/config/lustre-build-linux.m4 ++++ b/config/lustre-build-linux.m4 +@@ -394,14 +394,64 @@ rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest. + # Determine the kernel's idea of the current architecture + # + AC_DEFUN([LB_LINUX_ARCH], +- [AC_MSG_CHECKING([Linux kernel architecture]) +- AS_IF([rm -f $PWD/build/arch +- make -s --no-print-directory echoarch -f $PWD/build/Makefile \ +- LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $CROSS_VARS \ +- ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`], +- [AC_MSG_RESULT([$LINUX_ARCH])], +- [AC_MSG_ERROR([Could not determine the kernel architecture.])]) +- rm -f build/arch]) ++[LINUXARCH= ++rm -f build/conftest.i ++AC_MSG_CHECKING([Linux kernel architecture]) ++if test -s $LINUX_OBJ/include/$AUTOCONF_HDIR/compile.h ; then ++ LINUXARCHHEADER=$AUTOCONF_HDIR/compile.h ++else ++ LINUXARCHHEADER=linux/autoconf.h ++fi ++LB_LINUX_TRY_MAKE([ ++#include <$LINUXARCHHEADER> ++ ++#ifndef UTS_MACHINE ++ ++ #ifdef CONFIG_X86 ++ #ifdef CONFIG_X86_32 ++ #define UTS_MACHINE i386 ++ #endif ++ #ifdef CONFIG_X86_64 ++ #define UTS_MACHINE x86_64 ++ #endif ++ #endif ++ ++ #ifdef CONFIG_IA64 ++ #define UTS_MACHINE ia64 ++ #endif ++ ++ #ifdef CONFIG_PPC ++ #ifdef CONFIG_PPC32 ++ #define UTS_MACHINE ppc ++ #endif ++ #ifdef CONFIG_PPC64 ++ #define UTS_MACHINE ppc64 ++ #endif ++ #endif ++ ++#endif ++],[ ++ char *LINUXARCH; ++ LINUXARCH=UTS_MACHINE; ++],[ ++ $makerule LUSTRE_KERNEL_TEST=conftest.i ++],[ ++ test -s build/conftest.i ++],[ ++ # LINUXARCH="UTS_MACHINE" ++ eval $(grep "LINUXARCH=" build/conftest.i) ++],[ ++ AC_MSG_RESULT([unknown]) ++ AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.]) ++]) ++ rm -f build/conftest.i ++ if test x$LINUXARCH = x ; then ++ AC_MSG_RESULT([unknown]) ++ AC_MSG_ERROR([Could not determine Linux architecture from linux/version.h.]) ++ fi ++AC_MSG_RESULT([$LINUXARCH]) ++AC_SUBST(LINUXARCH) ++]) + + # + # LB_LINUX_TRY_COMPILE +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0001-LU-4554-lfsck-old-single-OI-MDT-always-scrubbed.patch b/sys-cluster/lustre/files/0001-LU-4554-lfsck-old-single-OI-MDT-always-scrubbed.patch deleted file mode 100644 index 18ec7cfe8..000000000 --- a/sys-cluster/lustre/files/0001-LU-4554-lfsck-old-single-OI-MDT-always-scrubbed.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 9e3436c298d65a5867920b0de0d3920972465407 Mon Sep 17 00:00:00 2001 -From: Ned Bass -Date: Thu, 30 Jan 2014 14:56:20 -0800 -Subject: [PATCH 01/13] LU-4554 lfsck: old single-OI MDT always scrubbed - -Old ldiskfs MDT's that contain a single OI container named "oi.16" -trigger an automatic OI scrub on each restart. This is because -osd_oi_table_open() gets ENOENT opening "oi.16.0" and consequently -sets bit 0 in scrub_file::sf_oi_bitmap. This bit indicates the OI -container 0 needs to be recreated, and it triggers a scrub in -osd_fid_lookup() for lookups that fail with ENOENT. Fix this by -clearing the bit in osd_oi_init() after a successful open of -"oi.16". - -Signed-off-by: Ned Bass -Change-Id: Ie69223d3f8289c90de46f9afe0a2de0e0625b0f6 -Reviewed-on: http://review.whamcloud.com/9067 -Tested-by: Jenkins -Reviewed-by: Andreas Dilger -Tested-by: Maloo -Reviewed-by: James Nunez -Reviewed-by: Fan Yong ---- - lustre/osd-ldiskfs/osd_oi.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/lustre/osd-ldiskfs/osd_oi.c b/lustre/osd-ldiskfs/osd_oi.c -index 6e690be..b4bfb9a 100644 ---- a/lustre/osd-ldiskfs/osd_oi.c -+++ b/lustre/osd-ldiskfs/osd_oi.c -@@ -368,6 +368,7 @@ int osd_oi_init(struct osd_thread_info *info, struct osd_device *osd) - /* if previous failed then try found single OI from old filesystem */ - rc = osd_oi_open(info, osd, OSD_OI_NAME_BASE, &oi[0], false); - if (rc == 0) { /* found single OI from old filesystem */ -+ ldiskfs_clear_bit(0, sf->sf_oi_bitmap); - if (sf->sf_success_count == 0) - /* XXX: There is one corner case that if the OI_scrub - * file crashed or lost and we regard it upgrade, --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0002-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch b/sys-cluster/lustre/files/0002-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch deleted file mode 100644 index f6b096528..000000000 --- a/sys-cluster/lustre/files/0002-LU-2982-build-make-AC-check-for-linux-arch-sandbox-f.patch +++ /dev/null @@ -1,95 +0,0 @@ -From 247c87f4a981fd26bfaf219930193b1a35865736 Mon Sep 17 00:00:00 2001 -From: Alexey Shvetsov -Date: Mon, 18 Mar 2013 16:22:27 +0400 -Subject: [PATCH 02/13] LU-2982 build: make AC check for linux arch sandbox - friendly - -this commit makes AC check for linux kernel arch sandbox friendly - -Signed-off-by: Alexey Shvetsov -Change-Id: I173cd892bca5587519806cf6d300a5053dfb935f -Signed-off-by: Alexey Shvetsov ---- - config/lustre-build-linux.m4 | 66 ++++++++++++++++++++++++++++++++++++++------ - 1 file changed, 58 insertions(+), 8 deletions(-) - -diff --git a/config/lustre-build-linux.m4 b/config/lustre-build-linux.m4 -index 894101c..8062ace 100644 ---- a/config/lustre-build-linux.m4 -+++ b/config/lustre-build-linux.m4 -@@ -394,14 +394,64 @@ rm -f build/conftest.o build/conftest.mod.c build/conftest.mod.o build/conftest. - # Determine the kernel's idea of the current architecture - # - AC_DEFUN([LB_LINUX_ARCH], -- [AC_MSG_CHECKING([Linux kernel architecture]) -- AS_IF([rm -f $PWD/build/arch -- make -s --no-print-directory echoarch -f $PWD/build/Makefile \ -- LUSTRE_LINUX_CONFIG=$LINUX_CONFIG -C $LINUX $CROSS_VARS \ -- ARCHFILE=$PWD/build/arch && LINUX_ARCH=`cat $PWD/build/arch`], -- [AC_MSG_RESULT([$LINUX_ARCH])], -- [AC_MSG_ERROR([Could not determine the kernel architecture.])]) -- rm -f build/arch]) -+[LINUXARCH= -+rm -f build/conftest.i -+AC_MSG_CHECKING([Linux kernel architecture]) -+if test -s $LINUX_OBJ/include/$AUTOCONF_HDIR/compile.h ; then -+ LINUXARCHHEADER=$AUTOCONF_HDIR/compile.h -+else -+ LINUXARCHHEADER=linux/autoconf.h -+fi -+LB_LINUX_TRY_MAKE([ -+#include <$LINUXARCHHEADER> -+ -+#ifndef UTS_MACHINE -+ -+ #ifdef CONFIG_X86 -+ #ifdef CONFIG_X86_32 -+ #define UTS_MACHINE i386 -+ #endif -+ #ifdef CONFIG_X86_64 -+ #define UTS_MACHINE x86_64 -+ #endif -+ #endif -+ -+ #ifdef CONFIG_IA64 -+ #define UTS_MACHINE ia64 -+ #endif -+ -+ #ifdef CONFIG_PPC -+ #ifdef CONFIG_PPC32 -+ #define UTS_MACHINE ppc -+ #endif -+ #ifdef CONFIG_PPC64 -+ #define UTS_MACHINE ppc64 -+ #endif -+ #endif -+ -+#endif -+],[ -+ char *LINUXARCH; -+ LINUXARCH=UTS_MACHINE; -+],[ -+ $makerule LUSTRE_KERNEL_TEST=conftest.i -+],[ -+ test -s build/conftest.i -+],[ -+ # LINUXARCH="UTS_MACHINE" -+ eval $(grep "LINUXARCH=" build/conftest.i) -+],[ -+ AC_MSG_RESULT([unknown]) -+ AC_MSG_ERROR([Could not preprocess test program. Consult config.log for details.]) -+]) -+ rm -f build/conftest.i -+ if test x$LINUXARCH = x ; then -+ AC_MSG_RESULT([unknown]) -+ AC_MSG_ERROR([Could not determine Linux architecture from linux/version.h.]) -+ fi -+AC_MSG_RESULT([$LINUXARCH]) -+AC_SUBST(LINUXARCH) -+]) - - # - # LB_LINUX_TRY_COMPILE --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0002-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0002-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch new file mode 100644 index 000000000..939f1fcc1 --- /dev/null +++ b/sys-cluster/lustre/files/0002-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch @@ -0,0 +1,207 @@ +From c05c0be01814527d8d3762963c7a6d4c28189d2d Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Fri, 3 Jan 2014 09:55:26 -0500 +Subject: [PATCH 02/12] LU-3319 procfs: update zfs proc handling to seq_files + +Migrate all zfs proc handling to using strictly seq_files. + +Signed-off-by: James Simmons +Change-Id: I6dc7e65c3e74e7934a17939815ec3c334fac58c7 +--- + lustre/osd-zfs/osd_handler.c | 13 ++++--- + lustre/osd-zfs/osd_internal.h | 3 -- + lustre/osd-zfs/osd_lproc.c | 88 ++++++++++++++++++++++++------------------- + 3 files changed, 57 insertions(+), 47 deletions(-) + +diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c +index d4193cd..36bf6a4 100644 +--- a/lustre/osd-zfs/osd_handler.c ++++ b/lustre/osd-zfs/osd_handler.c +@@ -745,6 +745,7 @@ static int osd_device_init(const struct lu_env *env, struct lu_device *d, + static int osd_process_config(const struct lu_env *env, + struct lu_device *d, struct lustre_cfg *cfg) + { ++ struct obd_device *obd = d->ld_obd; + struct osd_device *o = osd_dev(d); + int rc; + ENTRY; +@@ -758,12 +759,12 @@ static int osd_process_config(const struct lu_env *env, + break; + case LCFG_PARAM: { + LASSERT(&o->od_dt_dev); +- rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars, +- cfg, &o->od_dt_dev); ++ rc = class_process_proc_seq_param(PARAM_OSD, obd->obd_vars, ++ cfg, &o->od_dt_dev); + if (rc > 0 || rc == -ENOSYS) +- rc = class_process_proc_param(PARAM_OST, +- lprocfs_osd_obd_vars, +- cfg, &o->od_dt_dev); ++ rc = class_process_proc_seq_param(PARAM_OST, ++ obd->obd_vars, cfg, ++ &o->od_dt_dev); + break; + } + default: +@@ -911,7 +912,7 @@ int __init osd_init(void) + + rc = class_register_type(&osd_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lprocfs_osd_module_vars, ++ NULL, + #endif + LUSTRE_OSD_ZFS_NAME, &osd_device_type); + if (rc) +diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h +index bc51cb1..77b118f 100644 +--- a/lustre/osd-zfs/osd_internal.h ++++ b/lustre/osd-zfs/osd_internal.h +@@ -402,9 +402,6 @@ enum { + }; + + /* osd_lproc.c */ +-extern struct lprocfs_vars lprocfs_osd_obd_vars[]; +-extern struct lprocfs_vars lprocfs_osd_module_vars[]; +- + int osd_procfs_init(struct osd_device *osd, const char *name); + int osd_procfs_fini(struct osd_device *osd); + +diff --git a/lustre/osd-zfs/osd_lproc.c b/lustre/osd-zfs/osd_lproc.c +index 0854ce6..a7ce60d 100644 +--- a/lustre/osd-zfs/osd_lproc.c ++++ b/lustre/osd-zfs/osd_lproc.c +@@ -107,27 +107,26 @@ out: + RETURN(result); + } + +-static int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int zfs_osd_fstype_seq_show(struct seq_file *m, void *data) + { +- return snprintf(page, count, "zfs\n"); ++ return seq_printf(m, "zfs\n"); + } ++LPROC_SEQ_FOPS_RO(zfs_osd_fstype); + +-static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int zfs_osd_mntdev_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *osd = osd_dt_dev((struct dt_device *)data); ++ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); + + LASSERT(osd != NULL); +- *eof = 1; +- +- return snprintf(page, count, "%s\n", osd->od_mntdev); ++ return seq_printf(m, "%s\n", osd->od_mntdev); + } ++LPROC_SEQ_FOPS_RO(zfs_osd_mntdev); + +-static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lprocfs_osd_force_sync_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct dt_device *dt = data; ++ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; + struct lu_env env; + int rc; + +@@ -139,20 +138,21 @@ static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, + + return rc == 0 ? count : rc; + } ++LPROC_SEQ_FOPS_WO_TYPE(zfs, osd_force_sync); + +-static int lprocfs_osd_rd_iused_est(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int zfs_osd_iused_est_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *osd = osd_dt_dev((struct dt_device *)data); ++ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); + LASSERT(osd != NULL); + +- return snprintf(page, count, "%d\n", osd->od_quota_iused_est); ++ return seq_printf(m, "%d\n", osd->od_quota_iused_est); + } + +-static int lprocfs_osd_wr_iused_est(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t zfs_osd_iused_est_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct osd_device *osd = osd_dt_dev((struct dt_device *)data); ++ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; ++ struct osd_device *osd = osd_dt_dev(dt); + int rc, val; + + LASSERT(osd != NULL); +@@ -165,24 +165,36 @@ static int lprocfs_osd_wr_iused_est(struct file *file, const char *buffer, + + return count; + } +- +-struct lprocfs_vars lprocfs_osd_obd_vars[] = { +- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, +- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, +- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, +- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, +- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, +- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, +- { "fstype", lprocfs_osd_rd_fstype, 0, 0 }, +- { "mntdev", lprocfs_osd_rd_mntdev, 0, 0 }, +- { "force_sync", 0, lprocfs_osd_wr_force_sync }, +- { "quota_iused_estimate", lprocfs_osd_rd_iused_est, +- lprocfs_osd_wr_iused_est, 0, 0 }, +- { 0 } +-}; +- +-struct lprocfs_vars lprocfs_osd_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, ++LPROC_SEQ_FOPS(zfs_osd_iused_est); ++ ++LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_blksize); ++LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytestotal); ++LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesfree); ++LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesavail); ++LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filestotal); ++LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filesfree); ++ ++struct lprocfs_seq_vars lprocfs_osd_obd_vars[] = { ++ { .name = "blocksize", ++ .fops = &zfs_dt_blksize_fops }, ++ { .name = "kbytestotal", ++ .fops = &zfs_dt_kbytestotal_fops }, ++ { .name = "kbytesfree", ++ .fops = &zfs_dt_kbytesfree_fops }, ++ { .name = "kbytesavail", ++ .fops = &zfs_dt_kbytesavail_fops }, ++ { .name = "filestotal", ++ .fops = &zfs_dt_filestotal_fops }, ++ { .name = "filesfree", ++ .fops = &zfs_dt_filesfree_fops }, ++ { .name = "fstype", ++ .fops = &zfs_osd_fstype_fops }, ++ { .name = "mntdev", ++ .fops = &zfs_osd_mntdev_fops }, ++ { .name = "force_sync", ++ .fops = &zfs_osd_force_sync_fops }, ++ { .name = "quota_iused_estimate", ++ .fops = &zfs_osd_iused_est_fops }, + { 0 } + }; + +@@ -202,7 +214,7 @@ int osd_procfs_init(struct osd_device *osd, const char *name) + LASSERT(name != NULL); + LASSERT(type != NULL); + +- osd->od_proc_entry = lprocfs_register(name, type->typ_procroot, ++ osd->od_proc_entry = lprocfs_seq_register(name, type->typ_procroot, + lprocfs_osd_obd_vars, &osd->od_dt_dev); + if (IS_ERR(osd->od_proc_entry)) { + rc = PTR_ERR(osd->od_proc_entry); +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0003-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0003-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch new file mode 100644 index 000000000..756975ee9 --- /dev/null +++ b/sys-cluster/lustre/files/0003-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch @@ -0,0 +1,356 @@ +From b262846027fbf96a5a80b81cfe86da53ce6e6f9f Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Fri, 3 Jan 2014 09:58:53 -0500 +Subject: [PATCH 03/12] LU-3319 procfs: move mgs proc handling to seq_files + +With 3.10 linux kernel and above proc handling now only +uses struct seq_files. This patch migrates the mgs +layer proc entries over to using seq_files. + +Signed-off-by: James Simmons +Change-Id: I1a12dd9b1fc8f139116a8f3a684956a5ba88f055 +--- + lustre/mgs/lproc_mgs.c | 202 +++++++++++++++++++++++----------------------- + lustre/mgs/mgs_handler.c | 5 +- + lustre/mgs/mgs_internal.h | 13 +-- + lustre/mgs/mgs_nids.c | 11 ++- + 4 files changed, 110 insertions(+), 121 deletions(-) + +diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c +index ffa2d0d..f0ea956 100644 +--- a/lustre/mgs/lproc_mgs.c ++++ b/lustre/mgs/lproc_mgs.c +@@ -126,19 +126,110 @@ static int mgsself_srpc_seq_show(struct seq_file *seq, void *v) + + return 0; + } +- + LPROC_SEQ_FOPS_RO(mgsself_srpc); + ++static int mgs_live_seq_show(struct seq_file *seq, void *v) ++{ ++ struct fs_db *fsdb = seq->private; ++ struct mgs_tgt_srpc_conf *srpc_tgt; ++ int i; ++ ++ mutex_lock(&fsdb->fsdb_mutex); ++ ++ seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name); ++ seq_printf(seq, "flags: %#lx gen: %d\n", ++ fsdb->fsdb_flags, fsdb->fsdb_gen); ++ for (i = 0; i < INDEX_MAP_SIZE * 8; i++) ++ if (test_bit(i, fsdb->fsdb_mdt_index_map)) ++ seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i); ++ for (i = 0; i < INDEX_MAP_SIZE * 8; i++) ++ if (test_bit(i, fsdb->fsdb_ost_index_map)) ++ seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i); ++ ++ seq_printf(seq, "\nSecure RPC Config Rules:\n"); ++#if 0 ++ seq_printf(seq, "%s.%s=%s\n", fsdb->fsdb_name, ++ PARAM_SRPC_UDESC, fsdb->fsdb_srpc_fl_udesc ? "yes" : "no"); ++#endif ++ for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt; ++ srpc_tgt = srpc_tgt->mtsc_next) { ++ seq_show_srpc_rules(seq, srpc_tgt->mtsc_tgt, ++ &srpc_tgt->mtsc_rset); ++ } ++ seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); ++ ++ lprocfs_rd_ir_state(seq, fsdb); ++ ++ mutex_unlock(&fsdb->fsdb_mutex); ++ return 0; ++} ++ ++static ssize_t mgs_live_seq_write(struct file *file, const char *buf, ++ size_t len, loff_t *off) ++{ ++ struct seq_file *seq = file->private_data; ++ struct fs_db *fsdb = seq->private; ++ ssize_t rc; ++ ++ rc = lprocfs_wr_ir_state(file, buf, len, fsdb); ++ if (rc >= 0) ++ rc = len; ++ return rc; ++} ++LPROC_SEQ_FOPS(mgs_live); ++ ++int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) ++{ ++ int rc; ++ ++ if (!mgs->mgs_proc_live) ++ return 0; ++ rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644, ++ &mgs_live_fops, fsdb); ++ ++ return 0; ++} ++ ++int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) ++{ ++ if (!mgs->mgs_proc_live) ++ return 0; ++ ++ /* didn't create the proc file for MGSSELF_NAME */ ++ if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) ++ lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); ++ return 0; ++} ++ ++LPROC_SEQ_FOPS_RO_TYPE(mgs, uuid); ++LPROC_SEQ_FOPS_RO_TYPE(mgs, num_exports); ++LPROC_SEQ_FOPS_RO_TYPE(mgs, hash); ++LPROC_SEQ_FOPS_WO_TYPE(mgs, evict_client); ++LPROC_SEQ_FOPS_RW_TYPE(mgs, ir_timeout); ++ ++struct lprocfs_seq_vars lprocfs_mgs_obd_vars[] = { ++ { .name = "uuid", ++ .fops = &mgs_uuid_fops }, ++ { .name = "num_exports", ++ .fops = &mgs_num_exports_fops }, ++ { .name = "hash_stats", ++ .fops = &mgs_hash_fops }, ++ { .name = "evict_client", ++ .fops = &mgs_evict_client_fops }, ++ { .name = "ir_timeout", ++ .fops = &mgs_ir_timeout_fops }, ++ { 0 } ++}; ++ + int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name) + { + struct obd_device *obd = mgs->mgs_obd; + struct obd_device *osd_obd = mgs->mgs_bottom->dd_lu_dev.ld_obd; + int osd_len = strlen(osd_name) - strlen("-osd"); + int rc; +- struct lprocfs_static_vars lvars; + +- lprocfs_mgs_init_vars(&lvars); +- rc = lprocfs_obd_setup(obd, lvars.obd_vars); ++ obd->obd_vars = lprocfs_mgs_obd_vars; ++ rc = lprocfs_seq_obd_setup(obd); + if (rc != 0) + GOTO(out, rc); + +@@ -152,17 +243,17 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name) + if (rc != 0) + GOTO(out, rc); + +- mgs->mgs_proc_live = lprocfs_register("live", obd->obd_proc_entry, +- NULL, NULL); ++ mgs->mgs_proc_live = lprocfs_seq_register("live", obd->obd_proc_entry, ++ NULL, NULL); + if (IS_ERR(mgs->mgs_proc_live)) { + rc = PTR_ERR(mgs->mgs_proc_live); + mgs->mgs_proc_live = NULL; + GOTO(out, rc); + } + +- obd->obd_proc_exports_entry = lprocfs_register("exports", +- obd->obd_proc_entry, +- NULL, NULL); ++ obd->obd_proc_exports_entry = lprocfs_seq_register("exports", ++ obd->obd_proc_entry, ++ NULL, NULL); + if (IS_ERR(obd->obd_proc_exports_entry)) { + rc = PTR_ERR(obd->obd_proc_exports_entry); + obd->obd_proc_exports_entry = NULL; +@@ -215,7 +306,6 @@ void lproc_mgs_cleanup(struct mgs_device *mgs) + + if (mgs->mgs_proc_live != NULL) { + /* Should be no live entries */ +- LASSERT(mgs->mgs_proc_live->subdir == NULL); + lprocfs_remove(&mgs->mgs_proc_live); + mgs->mgs_proc_live = NULL; + } +@@ -226,92 +316,6 @@ void lproc_mgs_cleanup(struct mgs_device *mgs) + lprocfs_free_md_stats(obd); + } + +-static int mgs_live_seq_show(struct seq_file *seq, void *v) +-{ +- struct fs_db *fsdb = seq->private; +- struct mgs_tgt_srpc_conf *srpc_tgt; +- int i; +- +- mutex_lock(&fsdb->fsdb_mutex); +- +- seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name); +- seq_printf(seq, "flags: %#lx gen: %d\n", +- fsdb->fsdb_flags, fsdb->fsdb_gen); +- for (i = 0; i < INDEX_MAP_SIZE * 8; i++) +- if (test_bit(i, fsdb->fsdb_mdt_index_map)) +- seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i); +- for (i = 0; i < INDEX_MAP_SIZE * 8; i++) +- if (test_bit(i, fsdb->fsdb_ost_index_map)) +- seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i); +- +- seq_printf(seq, "\nSecure RPC Config Rules:\n"); +-#if 0 +- seq_printf(seq, "%s.%s=%s\n", fsdb->fsdb_name, +- PARAM_SRPC_UDESC, fsdb->fsdb_srpc_fl_udesc ? "yes" : "no"); +-#endif +- for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt; +- srpc_tgt = srpc_tgt->mtsc_next) { +- seq_show_srpc_rules(seq, srpc_tgt->mtsc_tgt, +- &srpc_tgt->mtsc_rset); +- } +- seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); +- +- lprocfs_rd_ir_state(seq, fsdb); +- +- mutex_unlock(&fsdb->fsdb_mutex); +- return 0; +-} +- +-static ssize_t mgs_live_seq_write(struct file *file, const char *buf, +- size_t len, loff_t *off) +-{ +- struct seq_file *seq = file->private_data; +- struct fs_db *fsdb = seq->private; +- ssize_t rc; +- +- rc = lprocfs_wr_ir_state(file, buf, len, fsdb); +- if (rc >= 0) +- rc = len; +- return rc; +-} +-LPROC_SEQ_FOPS(mgs_live); +- +-int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) +-{ +- int rc; +- +- if (!mgs->mgs_proc_live) +- return 0; +- rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644, +- &mgs_live_fops, fsdb); +- +- return 0; +-} +- +-int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) +-{ +- if (!mgs->mgs_proc_live) +- return 0; +- +- /* didn't create the proc file for MGSSELF_NAME */ +- if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) +- lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); +- return 0; +-} +- +-struct lprocfs_vars lprocfs_mgs_obd_vars[] = { +- { "uuid", lprocfs_rd_uuid, 0, 0 }, +- { "num_exports", lprocfs_rd_num_exports, 0, 0 }, +- { "hash_stats", lprocfs_obd_rd_hash, 0, 0 }, +- { "evict_client", 0, lprocfs_wr_evict_client, 0 }, +- { "ir_timeout", lprocfs_rd_ir_timeout, lprocfs_wr_ir_timeout, 0 }, +- { 0 } +-}; +- +-struct lprocfs_vars lprocfs_mgs_module_vars[] = { +- { 0 } +-}; +- + void mgs_counter_incr(struct obd_export *exp, int opcode) + { + lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode); +@@ -329,10 +333,4 @@ void mgs_stats_counter_init(struct lprocfs_stats *stats) + lprocfs_counter_init(stats, LPROC_MGS_TARGET_REG, 0, "tgtreg", "reqs"); + lprocfs_counter_init(stats, LPROC_MGS_TARGET_DEL, 0, "tgtdel", "reqs"); + } +- +-void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars) +-{ +- lvars->module_vars = lprocfs_mgs_module_vars; +- lvars->obd_vars = lprocfs_mgs_obd_vars; +-} + #endif +diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c +index 5be9040..4bb842c 100644 +--- a/lustre/mgs/mgs_handler.c ++++ b/lustre/mgs/mgs_handler.c +@@ -1434,12 +1434,9 @@ static struct obd_ops mgs_obd_device_ops = { + + static int __init mgs_init(void) + { +- struct lprocfs_static_vars lvars; +- +- lprocfs_mgs_init_vars(&lvars); + return class_register_type(&mgs_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lvars.module_vars, ++ NULL, + #endif + LUSTRE_MGS_NAME, &mgs_device_type); + } +diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h +index ca2846e..d3baacd 100644 +--- a/lustre/mgs/mgs_internal.h ++++ b/lustre/mgs/mgs_internal.h +@@ -229,10 +229,10 @@ int mgs_get_ir_logs(struct ptlrpc_request *req); + int lprocfs_wr_ir_state(struct file *file, const char *buffer, + unsigned long count, void *data); + int lprocfs_rd_ir_state(struct seq_file *seq, void *data); +-int lprocfs_wr_ir_timeout(struct file *file, const char *buffer, +- unsigned long count, void *data); +-int lprocfs_rd_ir_timeout(char *page, char **start, off_t off, int count, +- int *eof, void *data); ++ssize_t ++lprocfs_ir_timeout_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off); ++int lprocfs_ir_timeout_seq_show(struct seq_file *seq, void *data); + void mgs_fsc_cleanup(struct obd_export *exp); + void mgs_fsc_cleanup_by_fsdb(struct fs_db *fsdb); + int mgs_fsc_attach(const struct lu_env *env, struct obd_export *exp, +@@ -250,7 +250,6 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name); + void lproc_mgs_cleanup(struct mgs_device *mgs); + int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb); + int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb); +-void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars); + #else + static inline int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name) + {return 0;} +@@ -260,10 +259,6 @@ static inline int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) + {return 0;} + static inline int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) + {return 0;} +-static void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars) +-{ +- memset(lvars, 0, sizeof(*lvars)); +-} + #endif + + /* mgs/lproc_mgs.c */ +diff --git a/lustre/mgs/mgs_nids.c b/lustre/mgs/mgs_nids.c +index a2bae59..3248387 100644 +--- a/lustre/mgs/mgs_nids.c ++++ b/lustre/mgs/mgs_nids.c +@@ -838,15 +838,14 @@ int lprocfs_rd_ir_state(struct seq_file *seq, void *data) + return 0; + } + +-int lprocfs_rd_ir_timeout(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++int lprocfs_ir_timeout_seq_show(struct seq_file *m, void *data) + { +- *eof = 1; +- return snprintf(page, count, "%d\n", ir_timeout); ++ return lprocfs_uint_seq_show(m, &ir_timeout); + } + +-int lprocfs_wr_ir_timeout(struct file *file, const char *buffer, +- unsigned long count, void *data) ++ssize_t ++lprocfs_ir_timeout_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { + return lprocfs_wr_uint(file, buffer, count, &ir_timeout); + } +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0003-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0003-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch deleted file mode 100644 index a93c92a15..000000000 --- a/sys-cluster/lustre/files/0003-LU-3319-procfs-update-zfs-proc-handling-to-seq_files.patch +++ /dev/null @@ -1,207 +0,0 @@ -From c05c0be01814527d8d3762963c7a6d4c28189d2d Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Fri, 3 Jan 2014 09:55:26 -0500 -Subject: [PATCH 03/13] LU-3319 procfs: update zfs proc handling to seq_files - -Migrate all zfs proc handling to using strictly seq_files. - -Signed-off-by: James Simmons -Change-Id: I6dc7e65c3e74e7934a17939815ec3c334fac58c7 ---- - lustre/osd-zfs/osd_handler.c | 13 ++++--- - lustre/osd-zfs/osd_internal.h | 3 -- - lustre/osd-zfs/osd_lproc.c | 88 ++++++++++++++++++++++++------------------- - 3 files changed, 57 insertions(+), 47 deletions(-) - -diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c -index d4193cd..36bf6a4 100644 ---- a/lustre/osd-zfs/osd_handler.c -+++ b/lustre/osd-zfs/osd_handler.c -@@ -745,6 +745,7 @@ static int osd_device_init(const struct lu_env *env, struct lu_device *d, - static int osd_process_config(const struct lu_env *env, - struct lu_device *d, struct lustre_cfg *cfg) - { -+ struct obd_device *obd = d->ld_obd; - struct osd_device *o = osd_dev(d); - int rc; - ENTRY; -@@ -758,12 +759,12 @@ static int osd_process_config(const struct lu_env *env, - break; - case LCFG_PARAM: { - LASSERT(&o->od_dt_dev); -- rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars, -- cfg, &o->od_dt_dev); -+ rc = class_process_proc_seq_param(PARAM_OSD, obd->obd_vars, -+ cfg, &o->od_dt_dev); - if (rc > 0 || rc == -ENOSYS) -- rc = class_process_proc_param(PARAM_OST, -- lprocfs_osd_obd_vars, -- cfg, &o->od_dt_dev); -+ rc = class_process_proc_seq_param(PARAM_OST, -+ obd->obd_vars, cfg, -+ &o->od_dt_dev); - break; - } - default: -@@ -911,7 +912,7 @@ int __init osd_init(void) - - rc = class_register_type(&osd_obd_device_ops, NULL, NULL, - #ifndef HAVE_ONLY_PROCFS_SEQ -- lprocfs_osd_module_vars, -+ NULL, - #endif - LUSTRE_OSD_ZFS_NAME, &osd_device_type); - if (rc) -diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h -index bc51cb1..77b118f 100644 ---- a/lustre/osd-zfs/osd_internal.h -+++ b/lustre/osd-zfs/osd_internal.h -@@ -402,9 +402,6 @@ enum { - }; - - /* osd_lproc.c */ --extern struct lprocfs_vars lprocfs_osd_obd_vars[]; --extern struct lprocfs_vars lprocfs_osd_module_vars[]; -- - int osd_procfs_init(struct osd_device *osd, const char *name); - int osd_procfs_fini(struct osd_device *osd); - -diff --git a/lustre/osd-zfs/osd_lproc.c b/lustre/osd-zfs/osd_lproc.c -index 0854ce6..a7ce60d 100644 ---- a/lustre/osd-zfs/osd_lproc.c -+++ b/lustre/osd-zfs/osd_lproc.c -@@ -107,27 +107,26 @@ out: - RETURN(result); - } - --static int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int zfs_osd_fstype_seq_show(struct seq_file *m, void *data) - { -- return snprintf(page, count, "zfs\n"); -+ return seq_printf(m, "zfs\n"); - } -+LPROC_SEQ_FOPS_RO(zfs_osd_fstype); - --static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int zfs_osd_mntdev_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *osd = osd_dt_dev((struct dt_device *)data); -+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); - - LASSERT(osd != NULL); -- *eof = 1; -- -- return snprintf(page, count, "%s\n", osd->od_mntdev); -+ return seq_printf(m, "%s\n", osd->od_mntdev); - } -+LPROC_SEQ_FOPS_RO(zfs_osd_mntdev); - --static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lprocfs_osd_force_sync_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct dt_device *dt = data; -+ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; - struct lu_env env; - int rc; - -@@ -139,20 +138,21 @@ static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, - - return rc == 0 ? count : rc; - } -+LPROC_SEQ_FOPS_WO_TYPE(zfs, osd_force_sync); - --static int lprocfs_osd_rd_iused_est(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int zfs_osd_iused_est_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *osd = osd_dt_dev((struct dt_device *)data); -+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); - LASSERT(osd != NULL); - -- return snprintf(page, count, "%d\n", osd->od_quota_iused_est); -+ return seq_printf(m, "%d\n", osd->od_quota_iused_est); - } - --static int lprocfs_osd_wr_iused_est(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t zfs_osd_iused_est_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct osd_device *osd = osd_dt_dev((struct dt_device *)data); -+ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; -+ struct osd_device *osd = osd_dt_dev(dt); - int rc, val; - - LASSERT(osd != NULL); -@@ -165,24 +165,36 @@ static int lprocfs_osd_wr_iused_est(struct file *file, const char *buffer, - - return count; - } -- --struct lprocfs_vars lprocfs_osd_obd_vars[] = { -- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, -- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, -- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, -- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, -- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, -- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, -- { "fstype", lprocfs_osd_rd_fstype, 0, 0 }, -- { "mntdev", lprocfs_osd_rd_mntdev, 0, 0 }, -- { "force_sync", 0, lprocfs_osd_wr_force_sync }, -- { "quota_iused_estimate", lprocfs_osd_rd_iused_est, -- lprocfs_osd_wr_iused_est, 0, 0 }, -- { 0 } --}; -- --struct lprocfs_vars lprocfs_osd_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, -+LPROC_SEQ_FOPS(zfs_osd_iused_est); -+ -+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_blksize); -+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytestotal); -+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesfree); -+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_kbytesavail); -+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filestotal); -+LPROC_SEQ_FOPS_RO_TYPE(zfs, dt_filesfree); -+ -+struct lprocfs_seq_vars lprocfs_osd_obd_vars[] = { -+ { .name = "blocksize", -+ .fops = &zfs_dt_blksize_fops }, -+ { .name = "kbytestotal", -+ .fops = &zfs_dt_kbytestotal_fops }, -+ { .name = "kbytesfree", -+ .fops = &zfs_dt_kbytesfree_fops }, -+ { .name = "kbytesavail", -+ .fops = &zfs_dt_kbytesavail_fops }, -+ { .name = "filestotal", -+ .fops = &zfs_dt_filestotal_fops }, -+ { .name = "filesfree", -+ .fops = &zfs_dt_filesfree_fops }, -+ { .name = "fstype", -+ .fops = &zfs_osd_fstype_fops }, -+ { .name = "mntdev", -+ .fops = &zfs_osd_mntdev_fops }, -+ { .name = "force_sync", -+ .fops = &zfs_osd_force_sync_fops }, -+ { .name = "quota_iused_estimate", -+ .fops = &zfs_osd_iused_est_fops }, - { 0 } - }; - -@@ -202,7 +214,7 @@ int osd_procfs_init(struct osd_device *osd, const char *name) - LASSERT(name != NULL); - LASSERT(type != NULL); - -- osd->od_proc_entry = lprocfs_register(name, type->typ_procroot, -+ osd->od_proc_entry = lprocfs_seq_register(name, type->typ_procroot, - lprocfs_osd_obd_vars, &osd->od_dt_dev); - if (IS_ERR(osd->od_proc_entry)) { - rc = PTR_ERR(osd->od_proc_entry); --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0004-LU-3319-procfs-fix-symlink-handling.patch b/sys-cluster/lustre/files/0004-LU-3319-procfs-fix-symlink-handling.patch new file mode 100644 index 000000000..fc78c68c8 --- /dev/null +++ b/sys-cluster/lustre/files/0004-LU-3319-procfs-fix-symlink-handling.patch @@ -0,0 +1,371 @@ +From 8f24a0e29b5f4b18193742c9aecd960c6b6102ff Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Sun, 9 Feb 2014 09:37:44 -0500 +Subject: [PATCH 04/12] LU-3319 procfs: fix symlink handling + +While working on symlink handling for seq files I noticed a +long outstanding bug. Code was developed to link osc obds +to target_obds of the lov layer. The target_obds directory +was never created for the symlinks. This patches enables +this long forgotten feature. Also addressed is the race +condition experinced with server side code ported to +seq_files that used symlinks. To avoid the race the handle +obd_proc_private was moved from struct obd_device to +struct obd_type which now allows earlier registeration that +only happens once. + +Change-Id: Ib158ec4444ed7abc0f3c3e820ee4a333631a58d1 +Signed-off-by: James Simmons +--- + lustre/include/obd.h | 17 +++++---- + lustre/lmv/lmv_obd.c | 48 ++++++++--------------- + lustre/lov/lov_obd.c | 99 +++++++++++++++++++++++++++--------------------- + lustre/obdclass/genops.c | 17 +++++---- + 4 files changed, 91 insertions(+), 90 deletions(-) + +diff --git a/lustre/include/obd.h b/lustre/include/obd.h +index c18052b..8fd2ce7 100644 +--- a/lustre/include/obd.h ++++ b/lustre/include/obd.h +@@ -183,13 +183,15 @@ struct obd_info { + }; + + struct obd_type { +- cfs_list_t typ_chain; +- struct obd_ops *typ_dt_ops; +- struct md_ops *typ_md_ops; +- cfs_proc_dir_entry_t *typ_procroot; +- char *typ_name; +- int typ_refcnt; +- struct lu_device_type *typ_lu; ++ struct list_head typ_chain; ++ struct obd_ops *typ_dt_ops; ++ struct md_ops *typ_md_ops; ++ cfs_proc_dir_entry_t *typ_procroot; ++ cfs_proc_dir_entry_t *typ_procsym; ++ __u32 typ_sym_filter; ++ char *typ_name; ++ int typ_refcnt; ++ struct lu_device_type *typ_lu; + spinlock_t obd_type_lock; + }; + +@@ -825,7 +827,6 @@ struct obd_device { + + struct proc_dir_entry *obd_proc_entry; + struct proc_dir_entry *obd_proc_exports_entry; +- void *obd_proc_private; /* type private PDEs */ + struct proc_dir_entry *obd_svc_procroot; + struct lprocfs_stats *obd_svc_stats; + struct lprocfs_seq_vars *obd_vars; +diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c +index e0941c9..93db311 100644 +--- a/lustre/lmv/lmv_obd.c ++++ b/lustre/lmv/lmv_obd.c +@@ -242,9 +242,6 @@ static int lmv_connect(const struct lu_env *env, + struct obd_uuid *cluuid, struct obd_connect_data *data, + void *localdata) + { +-#ifdef __KERNEL__ +- struct proc_dir_entry *lmv_proc_dir; +-#endif + struct lmv_obd *lmv = &obd->u.lmv; + struct lustre_handle conn = { 0 }; + int rc = 0; +@@ -277,18 +274,15 @@ static int lmv_connect(const struct lu_env *env, + lmv->conn_data = *data; + + #ifdef __KERNEL__ +- if (obd->obd_proc_private != NULL) { +- lmv_proc_dir = obd->obd_proc_private; +- } else { +- lmv_proc_dir = lprocfs_seq_register("target_obds", +- obd->obd_proc_entry, +- NULL, NULL); +- if (IS_ERR(lmv_proc_dir)) { ++ if (obd->obd_type->typ_procsym == NULL) { ++ obd->obd_type->typ_procsym = lprocfs_seq_register("target_obds", ++ obd->obd_proc_entry, ++ NULL, NULL); ++ if (IS_ERR(obd->obd_type->typ_procsym)) { + CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.", + obd->obd_type->typ_name, obd->obd_name); +- lmv_proc_dir = NULL; ++ obd->obd_type->typ_procsym = NULL; + } +- obd->obd_proc_private = lmv_proc_dir; + } + #endif + +@@ -302,10 +296,8 @@ static int lmv_connect(const struct lu_env *env, + rc = lmv_check_connect(obd); + + #ifdef __KERNEL__ +- if (rc && lmv_proc_dir) { +- lprocfs_remove(&lmv_proc_dir); +- obd->obd_proc_private = NULL; +- } ++ if (rc && obd->obd_type->typ_procsym != NULL) ++ lprocfs_remove(&obd->obd_type->typ_procsym); + #endif + RETURN(rc); + } +@@ -384,9 +376,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, + + int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) + { +-#ifdef __KERNEL__ +- struct proc_dir_entry *lmv_proc_dir; +-#endif + struct lmv_obd *lmv = &obd->u.lmv; + struct obd_uuid *cluuid = &lmv->cluuid; + struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" }; +@@ -466,14 +455,13 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) + cfs_atomic_read(&obd->obd_refcount)); + + #ifdef __KERNEL__ +- lmv_proc_dir = obd->obd_proc_private; +- if (lmv_proc_dir) { ++ if (obd->obd_type->typ_procsym != NULL) { + struct proc_dir_entry *mdc_symlink; + + LASSERT(mdc_obd->obd_type != NULL); + LASSERT(mdc_obd->obd_type->typ_name != NULL); + mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name, +- lmv_proc_dir, ++ obd->obd_type->typ_procsym, + "../../../%s/%s", + mdc_obd->obd_type->typ_name, + mdc_obd->obd_name); +@@ -482,8 +470,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) + "/proc/fs/lustre/%s/%s/target_obds/%s.", + obd->obd_type->typ_name, obd->obd_name, + mdc_obd->obd_name); +- lprocfs_remove(&lmv_proc_dir); +- obd->obd_proc_private = NULL; ++ lprocfs_remove(&obd->obd_type->typ_procsym); + } + } + #endif +@@ -675,9 +662,6 @@ int lmv_check_connect(struct obd_device *obd) + + static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) + { +-#ifdef __KERNEL__ +- struct proc_dir_entry *lmv_proc_dir; +-#endif + struct lmv_obd *lmv = &obd->u.lmv; + struct obd_device *mdc_obd; + int rc; +@@ -695,9 +679,9 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) + } + + #ifdef __KERNEL__ +- lmv_proc_dir = obd->obd_proc_private; +- if (lmv_proc_dir) +- lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir); ++ if (obd->obd_type->typ_procsym != NULL) ++ lprocfs_remove_proc_entry(mdc_obd->obd_name, ++ obd->obd_type->typ_procsym); + #endif + rc = obd_fid_fini(tgt->ltd_exp->exp_obd); + if (rc) +@@ -747,8 +731,8 @@ static int lmv_disconnect(struct obd_export *exp) + } + + #ifdef __KERNEL__ +- if (obd->obd_proc_private) +- lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private); ++ if (obd->obd_type->typ_procsym != NULL) ++ lprocfs_remove(&obd->obd_type->typ_procsym); + else + CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", + obd->obd_type->typ_name, obd->obd_name); +diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c +index 286cd15..a3310fd 100644 +--- a/lustre/lov/lov_obd.c ++++ b/lustre/lov/lov_obd.c +@@ -127,19 +127,16 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, + int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, + struct obd_connect_data *data) + { +- struct lov_obd *lov = &obd->u.lov; +- struct obd_uuid *tgt_uuid; +- struct obd_device *tgt_obd; +- static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; +- struct obd_import *imp; +-#ifdef __KERNEL__ +- struct proc_dir_entry *lov_proc_dir; +-#endif +- int rc; +- ENTRY; ++ struct lov_obd *lov = &obd->u.lov; ++ struct obd_uuid *tgt_uuid; ++ struct obd_device *tgt_obd; ++ static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; ++ struct obd_import *imp; ++ int rc; ++ ENTRY; + +- if (!lov->lov_tgts[index]) +- RETURN(-EINVAL); ++ if (lov->lov_tgts[index] == NULL) ++ RETURN(-EINVAL); + + tgt_uuid = &lov->lov_tgts[index]->ltd_uuid; + tgt_obd = lov->lov_tgts[index]->ltd_obd; +@@ -195,27 +192,25 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, + obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); + + #ifdef __KERNEL__ +- lov_proc_dir = obd->obd_proc_private; +- if (lov_proc_dir) { +- struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; ++ if (obd->obd_type->typ_procsym != NULL) { ++ struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; + struct proc_dir_entry *osc_symlink; + +- LASSERT(osc_obd != NULL); +- LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); +- LASSERT(osc_obd->obd_type->typ_name != NULL); +- +- osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, +- lov_proc_dir, +- "../../../%s/%s", +- osc_obd->obd_type->typ_name, +- osc_obd->obd_name); +- if (osc_symlink == NULL) { +- CERROR("could not register LOV target " +- "/proc/fs/lustre/%s/%s/target_obds/%s.", +- obd->obd_type->typ_name, obd->obd_name, +- osc_obd->obd_name); +- lprocfs_remove(&lov_proc_dir); +- obd->obd_proc_private = NULL; ++ LASSERT(osc_obd != NULL); ++ LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); ++ LASSERT(osc_obd->obd_type->typ_name != NULL); ++ ++ osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, ++ obd->obd_type->typ_procsym, ++ "../../../%s/%s", ++ osc_obd->obd_type->typ_name, ++ osc_obd->obd_name); ++ if (osc_symlink == NULL) { ++ CERROR("could not register LOV target " ++ "/proc/fs/lustre/%s/%s/target_obds/%s.", ++ obd->obd_type->typ_name, obd->obd_name, ++ osc_obd->obd_name); ++ lprocfs_remove(&obd->obd_type->typ_procsym); + } + } + #endif +@@ -250,6 +245,17 @@ static int lov_connect(const struct lu_env *env, + if (data) + lov->lov_ocd = *data; + ++#ifdef __KERNEL__ ++ obd->obd_type->typ_procsym = lprocfs_seq_register("target_obds", ++ obd->obd_proc_entry, ++ NULL, NULL); ++ if (IS_ERR(obd->obd_type->typ_procsym)) { ++ CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.", ++ obd->obd_type->typ_name, obd->obd_name); ++ obd->obd_type->typ_procsym = NULL; ++ } ++#endif ++ + obd_getref(obd); + for (i = 0; i < lov->desc.ld_tgt_count; i++) { + tgt = lov->lov_tgts[i]; +@@ -280,7 +286,6 @@ static int lov_connect(const struct lu_env *env, + + static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) + { +- struct proc_dir_entry *lov_proc_dir; + struct lov_obd *lov = &obd->u.lov; + struct obd_device *osc_obd; + int rc; +@@ -296,18 +301,18 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) + tgt->ltd_exp->exp_obd->obd_inactive = 1; + } + +- lov_proc_dir = obd->obd_proc_private; +- if (lov_proc_dir) +- lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir); ++ if (obd->obd_type->typ_procsym) ++ lprocfs_remove_proc_entry(osc_obd->obd_name, ++ obd->obd_type->typ_procsym); + +- if (osc_obd) { +- /* Pass it on to our clients. +- * XXX This should be an argument to disconnect, +- * XXX not a back-door flag on the OBD. Ah well. +- */ +- osc_obd->obd_force = obd->obd_force; +- osc_obd->obd_fail = obd->obd_fail; +- osc_obd->obd_no_recov = obd->obd_no_recov; ++ if (osc_obd) { ++ /* Pass it on to our clients. ++ * XXX This should be an argument to disconnect, ++ * XXX not a back-door flag on the OBD. Ah well. ++ */ ++ osc_obd->obd_force = obd->obd_force; ++ osc_obd->obd_fail = obd->obd_fail; ++ osc_obd->obd_no_recov = obd->obd_no_recov; + } + + obd_register_observer(osc_obd, NULL); +@@ -353,6 +358,14 @@ static int lov_disconnect(struct obd_export *exp) + } + obd_putref(obd); + ++#ifdef __KERNEL__ ++ if (obd->obd_type->typ_procsym) ++ lprocfs_remove(&obd->obd_type->typ_procsym); ++ else ++ CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", ++ obd->obd_type->typ_name, obd->obd_name); ++#endif ++ + out: + rc = class_disconnect(exp); /* bz 9811 */ + RETURN(rc); +diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c +index c9d8a4e..a4a981c 100644 +--- a/lustre/obdclass/genops.c ++++ b/lustre/obdclass/genops.c +@@ -181,14 +181,15 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, + RETURN(-EEXIST); + } + +- rc = -ENOMEM; +- OBD_ALLOC(type, sizeof(*type)); +- if (type == NULL) +- RETURN(rc); ++ rc = -ENOMEM; ++ OBD_ALLOC(type, sizeof(*type)); ++ if (type == NULL) ++ RETURN(rc); ++ memset(type, 0, sizeof(*type)); + +- OBD_ALLOC_PTR(type->typ_dt_ops); +- OBD_ALLOC_PTR(type->typ_md_ops); +- OBD_ALLOC(type->typ_name, strlen(name) + 1); ++ OBD_ALLOC_PTR(type->typ_dt_ops); ++ OBD_ALLOC_PTR(type->typ_md_ops); ++ OBD_ALLOC(type->typ_name, strlen(name) + 1); + + if (type->typ_dt_ops == NULL || + type->typ_md_ops == NULL || +@@ -242,6 +243,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, + if (type->typ_dt_ops != NULL) + OBD_FREE_PTR(type->typ_dt_ops); + #ifdef LPROCFS ++ if (type->typ_procsym != NULL) ++ lprocfs_remove(&type->typ_procsym); + #ifndef HAVE_ONLY_PROCFS_SEQ + lprocfs_try_remove_proc_entry(type->typ_name, proc_lustre_root); + #else +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0004-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0004-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch deleted file mode 100644 index fe3241142..000000000 --- a/sys-cluster/lustre/files/0004-LU-3319-procfs-move-mgs-proc-handling-to-seq_files.patch +++ /dev/null @@ -1,356 +0,0 @@ -From b262846027fbf96a5a80b81cfe86da53ce6e6f9f Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Fri, 3 Jan 2014 09:58:53 -0500 -Subject: [PATCH 04/13] LU-3319 procfs: move mgs proc handling to seq_files - -With 3.10 linux kernel and above proc handling now only -uses struct seq_files. This patch migrates the mgs -layer proc entries over to using seq_files. - -Signed-off-by: James Simmons -Change-Id: I1a12dd9b1fc8f139116a8f3a684956a5ba88f055 ---- - lustre/mgs/lproc_mgs.c | 202 +++++++++++++++++++++++----------------------- - lustre/mgs/mgs_handler.c | 5 +- - lustre/mgs/mgs_internal.h | 13 +-- - lustre/mgs/mgs_nids.c | 11 ++- - 4 files changed, 110 insertions(+), 121 deletions(-) - -diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c -index ffa2d0d..f0ea956 100644 ---- a/lustre/mgs/lproc_mgs.c -+++ b/lustre/mgs/lproc_mgs.c -@@ -126,19 +126,110 @@ static int mgsself_srpc_seq_show(struct seq_file *seq, void *v) - - return 0; - } -- - LPROC_SEQ_FOPS_RO(mgsself_srpc); - -+static int mgs_live_seq_show(struct seq_file *seq, void *v) -+{ -+ struct fs_db *fsdb = seq->private; -+ struct mgs_tgt_srpc_conf *srpc_tgt; -+ int i; -+ -+ mutex_lock(&fsdb->fsdb_mutex); -+ -+ seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name); -+ seq_printf(seq, "flags: %#lx gen: %d\n", -+ fsdb->fsdb_flags, fsdb->fsdb_gen); -+ for (i = 0; i < INDEX_MAP_SIZE * 8; i++) -+ if (test_bit(i, fsdb->fsdb_mdt_index_map)) -+ seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i); -+ for (i = 0; i < INDEX_MAP_SIZE * 8; i++) -+ if (test_bit(i, fsdb->fsdb_ost_index_map)) -+ seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i); -+ -+ seq_printf(seq, "\nSecure RPC Config Rules:\n"); -+#if 0 -+ seq_printf(seq, "%s.%s=%s\n", fsdb->fsdb_name, -+ PARAM_SRPC_UDESC, fsdb->fsdb_srpc_fl_udesc ? "yes" : "no"); -+#endif -+ for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt; -+ srpc_tgt = srpc_tgt->mtsc_next) { -+ seq_show_srpc_rules(seq, srpc_tgt->mtsc_tgt, -+ &srpc_tgt->mtsc_rset); -+ } -+ seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); -+ -+ lprocfs_rd_ir_state(seq, fsdb); -+ -+ mutex_unlock(&fsdb->fsdb_mutex); -+ return 0; -+} -+ -+static ssize_t mgs_live_seq_write(struct file *file, const char *buf, -+ size_t len, loff_t *off) -+{ -+ struct seq_file *seq = file->private_data; -+ struct fs_db *fsdb = seq->private; -+ ssize_t rc; -+ -+ rc = lprocfs_wr_ir_state(file, buf, len, fsdb); -+ if (rc >= 0) -+ rc = len; -+ return rc; -+} -+LPROC_SEQ_FOPS(mgs_live); -+ -+int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) -+{ -+ int rc; -+ -+ if (!mgs->mgs_proc_live) -+ return 0; -+ rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644, -+ &mgs_live_fops, fsdb); -+ -+ return 0; -+} -+ -+int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) -+{ -+ if (!mgs->mgs_proc_live) -+ return 0; -+ -+ /* didn't create the proc file for MGSSELF_NAME */ -+ if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) -+ lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); -+ return 0; -+} -+ -+LPROC_SEQ_FOPS_RO_TYPE(mgs, uuid); -+LPROC_SEQ_FOPS_RO_TYPE(mgs, num_exports); -+LPROC_SEQ_FOPS_RO_TYPE(mgs, hash); -+LPROC_SEQ_FOPS_WO_TYPE(mgs, evict_client); -+LPROC_SEQ_FOPS_RW_TYPE(mgs, ir_timeout); -+ -+struct lprocfs_seq_vars lprocfs_mgs_obd_vars[] = { -+ { .name = "uuid", -+ .fops = &mgs_uuid_fops }, -+ { .name = "num_exports", -+ .fops = &mgs_num_exports_fops }, -+ { .name = "hash_stats", -+ .fops = &mgs_hash_fops }, -+ { .name = "evict_client", -+ .fops = &mgs_evict_client_fops }, -+ { .name = "ir_timeout", -+ .fops = &mgs_ir_timeout_fops }, -+ { 0 } -+}; -+ - int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name) - { - struct obd_device *obd = mgs->mgs_obd; - struct obd_device *osd_obd = mgs->mgs_bottom->dd_lu_dev.ld_obd; - int osd_len = strlen(osd_name) - strlen("-osd"); - int rc; -- struct lprocfs_static_vars lvars; - -- lprocfs_mgs_init_vars(&lvars); -- rc = lprocfs_obd_setup(obd, lvars.obd_vars); -+ obd->obd_vars = lprocfs_mgs_obd_vars; -+ rc = lprocfs_seq_obd_setup(obd); - if (rc != 0) - GOTO(out, rc); - -@@ -152,17 +243,17 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name) - if (rc != 0) - GOTO(out, rc); - -- mgs->mgs_proc_live = lprocfs_register("live", obd->obd_proc_entry, -- NULL, NULL); -+ mgs->mgs_proc_live = lprocfs_seq_register("live", obd->obd_proc_entry, -+ NULL, NULL); - if (IS_ERR(mgs->mgs_proc_live)) { - rc = PTR_ERR(mgs->mgs_proc_live); - mgs->mgs_proc_live = NULL; - GOTO(out, rc); - } - -- obd->obd_proc_exports_entry = lprocfs_register("exports", -- obd->obd_proc_entry, -- NULL, NULL); -+ obd->obd_proc_exports_entry = lprocfs_seq_register("exports", -+ obd->obd_proc_entry, -+ NULL, NULL); - if (IS_ERR(obd->obd_proc_exports_entry)) { - rc = PTR_ERR(obd->obd_proc_exports_entry); - obd->obd_proc_exports_entry = NULL; -@@ -215,7 +306,6 @@ void lproc_mgs_cleanup(struct mgs_device *mgs) - - if (mgs->mgs_proc_live != NULL) { - /* Should be no live entries */ -- LASSERT(mgs->mgs_proc_live->subdir == NULL); - lprocfs_remove(&mgs->mgs_proc_live); - mgs->mgs_proc_live = NULL; - } -@@ -226,92 +316,6 @@ void lproc_mgs_cleanup(struct mgs_device *mgs) - lprocfs_free_md_stats(obd); - } - --static int mgs_live_seq_show(struct seq_file *seq, void *v) --{ -- struct fs_db *fsdb = seq->private; -- struct mgs_tgt_srpc_conf *srpc_tgt; -- int i; -- -- mutex_lock(&fsdb->fsdb_mutex); -- -- seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name); -- seq_printf(seq, "flags: %#lx gen: %d\n", -- fsdb->fsdb_flags, fsdb->fsdb_gen); -- for (i = 0; i < INDEX_MAP_SIZE * 8; i++) -- if (test_bit(i, fsdb->fsdb_mdt_index_map)) -- seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i); -- for (i = 0; i < INDEX_MAP_SIZE * 8; i++) -- if (test_bit(i, fsdb->fsdb_ost_index_map)) -- seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i); -- -- seq_printf(seq, "\nSecure RPC Config Rules:\n"); --#if 0 -- seq_printf(seq, "%s.%s=%s\n", fsdb->fsdb_name, -- PARAM_SRPC_UDESC, fsdb->fsdb_srpc_fl_udesc ? "yes" : "no"); --#endif -- for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt; -- srpc_tgt = srpc_tgt->mtsc_next) { -- seq_show_srpc_rules(seq, srpc_tgt->mtsc_tgt, -- &srpc_tgt->mtsc_rset); -- } -- seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); -- -- lprocfs_rd_ir_state(seq, fsdb); -- -- mutex_unlock(&fsdb->fsdb_mutex); -- return 0; --} -- --static ssize_t mgs_live_seq_write(struct file *file, const char *buf, -- size_t len, loff_t *off) --{ -- struct seq_file *seq = file->private_data; -- struct fs_db *fsdb = seq->private; -- ssize_t rc; -- -- rc = lprocfs_wr_ir_state(file, buf, len, fsdb); -- if (rc >= 0) -- rc = len; -- return rc; --} --LPROC_SEQ_FOPS(mgs_live); -- --int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) --{ -- int rc; -- -- if (!mgs->mgs_proc_live) -- return 0; -- rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644, -- &mgs_live_fops, fsdb); -- -- return 0; --} -- --int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) --{ -- if (!mgs->mgs_proc_live) -- return 0; -- -- /* didn't create the proc file for MGSSELF_NAME */ -- if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) -- lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); -- return 0; --} -- --struct lprocfs_vars lprocfs_mgs_obd_vars[] = { -- { "uuid", lprocfs_rd_uuid, 0, 0 }, -- { "num_exports", lprocfs_rd_num_exports, 0, 0 }, -- { "hash_stats", lprocfs_obd_rd_hash, 0, 0 }, -- { "evict_client", 0, lprocfs_wr_evict_client, 0 }, -- { "ir_timeout", lprocfs_rd_ir_timeout, lprocfs_wr_ir_timeout, 0 }, -- { 0 } --}; -- --struct lprocfs_vars lprocfs_mgs_module_vars[] = { -- { 0 } --}; -- - void mgs_counter_incr(struct obd_export *exp, int opcode) - { - lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode); -@@ -329,10 +333,4 @@ void mgs_stats_counter_init(struct lprocfs_stats *stats) - lprocfs_counter_init(stats, LPROC_MGS_TARGET_REG, 0, "tgtreg", "reqs"); - lprocfs_counter_init(stats, LPROC_MGS_TARGET_DEL, 0, "tgtdel", "reqs"); - } -- --void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars) --{ -- lvars->module_vars = lprocfs_mgs_module_vars; -- lvars->obd_vars = lprocfs_mgs_obd_vars; --} - #endif -diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c -index 5be9040..4bb842c 100644 ---- a/lustre/mgs/mgs_handler.c -+++ b/lustre/mgs/mgs_handler.c -@@ -1434,12 +1434,9 @@ static struct obd_ops mgs_obd_device_ops = { - - static int __init mgs_init(void) - { -- struct lprocfs_static_vars lvars; -- -- lprocfs_mgs_init_vars(&lvars); - return class_register_type(&mgs_obd_device_ops, NULL, NULL, - #ifndef HAVE_ONLY_PROCFS_SEQ -- lvars.module_vars, -+ NULL, - #endif - LUSTRE_MGS_NAME, &mgs_device_type); - } -diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h -index ca2846e..d3baacd 100644 ---- a/lustre/mgs/mgs_internal.h -+++ b/lustre/mgs/mgs_internal.h -@@ -229,10 +229,10 @@ int mgs_get_ir_logs(struct ptlrpc_request *req); - int lprocfs_wr_ir_state(struct file *file, const char *buffer, - unsigned long count, void *data); - int lprocfs_rd_ir_state(struct seq_file *seq, void *data); --int lprocfs_wr_ir_timeout(struct file *file, const char *buffer, -- unsigned long count, void *data); --int lprocfs_rd_ir_timeout(char *page, char **start, off_t off, int count, -- int *eof, void *data); -+ssize_t -+lprocfs_ir_timeout_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off); -+int lprocfs_ir_timeout_seq_show(struct seq_file *seq, void *data); - void mgs_fsc_cleanup(struct obd_export *exp); - void mgs_fsc_cleanup_by_fsdb(struct fs_db *fsdb); - int mgs_fsc_attach(const struct lu_env *env, struct obd_export *exp, -@@ -250,7 +250,6 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name); - void lproc_mgs_cleanup(struct mgs_device *mgs); - int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb); - int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb); --void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars); - #else - static inline int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name) - {return 0;} -@@ -260,10 +259,6 @@ static inline int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) - {return 0;} - static inline int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) - {return 0;} --static void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars) --{ -- memset(lvars, 0, sizeof(*lvars)); --} - #endif - - /* mgs/lproc_mgs.c */ -diff --git a/lustre/mgs/mgs_nids.c b/lustre/mgs/mgs_nids.c -index a2bae59..3248387 100644 ---- a/lustre/mgs/mgs_nids.c -+++ b/lustre/mgs/mgs_nids.c -@@ -838,15 +838,14 @@ int lprocfs_rd_ir_state(struct seq_file *seq, void *data) - return 0; - } - --int lprocfs_rd_ir_timeout(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+int lprocfs_ir_timeout_seq_show(struct seq_file *m, void *data) - { -- *eof = 1; -- return snprintf(page, count, "%d\n", ir_timeout); -+ return lprocfs_uint_seq_show(m, &ir_timeout); - } - --int lprocfs_wr_ir_timeout(struct file *file, const char *buffer, -- unsigned long count, void *data) -+ssize_t -+lprocfs_ir_timeout_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { - return lprocfs_wr_uint(file, buffer, count, &ir_timeout); - } --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0005-LU-3319-procfs-fix-symlink-handling.patch b/sys-cluster/lustre/files/0005-LU-3319-procfs-fix-symlink-handling.patch deleted file mode 100644 index 533c4d925..000000000 --- a/sys-cluster/lustre/files/0005-LU-3319-procfs-fix-symlink-handling.patch +++ /dev/null @@ -1,371 +0,0 @@ -From 8f24a0e29b5f4b18193742c9aecd960c6b6102ff Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Sun, 9 Feb 2014 09:37:44 -0500 -Subject: [PATCH 05/13] LU-3319 procfs: fix symlink handling - -While working on symlink handling for seq files I noticed a -long outstanding bug. Code was developed to link osc obds -to target_obds of the lov layer. The target_obds directory -was never created for the symlinks. This patches enables -this long forgotten feature. Also addressed is the race -condition experinced with server side code ported to -seq_files that used symlinks. To avoid the race the handle -obd_proc_private was moved from struct obd_device to -struct obd_type which now allows earlier registeration that -only happens once. - -Change-Id: Ib158ec4444ed7abc0f3c3e820ee4a333631a58d1 -Signed-off-by: James Simmons ---- - lustre/include/obd.h | 17 +++++---- - lustre/lmv/lmv_obd.c | 48 ++++++++--------------- - lustre/lov/lov_obd.c | 99 +++++++++++++++++++++++++++--------------------- - lustre/obdclass/genops.c | 17 +++++---- - 4 files changed, 91 insertions(+), 90 deletions(-) - -diff --git a/lustre/include/obd.h b/lustre/include/obd.h -index c18052b..8fd2ce7 100644 ---- a/lustre/include/obd.h -+++ b/lustre/include/obd.h -@@ -183,13 +183,15 @@ struct obd_info { - }; - - struct obd_type { -- cfs_list_t typ_chain; -- struct obd_ops *typ_dt_ops; -- struct md_ops *typ_md_ops; -- cfs_proc_dir_entry_t *typ_procroot; -- char *typ_name; -- int typ_refcnt; -- struct lu_device_type *typ_lu; -+ struct list_head typ_chain; -+ struct obd_ops *typ_dt_ops; -+ struct md_ops *typ_md_ops; -+ cfs_proc_dir_entry_t *typ_procroot; -+ cfs_proc_dir_entry_t *typ_procsym; -+ __u32 typ_sym_filter; -+ char *typ_name; -+ int typ_refcnt; -+ struct lu_device_type *typ_lu; - spinlock_t obd_type_lock; - }; - -@@ -825,7 +827,6 @@ struct obd_device { - - struct proc_dir_entry *obd_proc_entry; - struct proc_dir_entry *obd_proc_exports_entry; -- void *obd_proc_private; /* type private PDEs */ - struct proc_dir_entry *obd_svc_procroot; - struct lprocfs_stats *obd_svc_stats; - struct lprocfs_seq_vars *obd_vars; -diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c -index e0941c9..93db311 100644 ---- a/lustre/lmv/lmv_obd.c -+++ b/lustre/lmv/lmv_obd.c -@@ -242,9 +242,6 @@ static int lmv_connect(const struct lu_env *env, - struct obd_uuid *cluuid, struct obd_connect_data *data, - void *localdata) - { --#ifdef __KERNEL__ -- struct proc_dir_entry *lmv_proc_dir; --#endif - struct lmv_obd *lmv = &obd->u.lmv; - struct lustre_handle conn = { 0 }; - int rc = 0; -@@ -277,18 +274,15 @@ static int lmv_connect(const struct lu_env *env, - lmv->conn_data = *data; - - #ifdef __KERNEL__ -- if (obd->obd_proc_private != NULL) { -- lmv_proc_dir = obd->obd_proc_private; -- } else { -- lmv_proc_dir = lprocfs_seq_register("target_obds", -- obd->obd_proc_entry, -- NULL, NULL); -- if (IS_ERR(lmv_proc_dir)) { -+ if (obd->obd_type->typ_procsym == NULL) { -+ obd->obd_type->typ_procsym = lprocfs_seq_register("target_obds", -+ obd->obd_proc_entry, -+ NULL, NULL); -+ if (IS_ERR(obd->obd_type->typ_procsym)) { - CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.", - obd->obd_type->typ_name, obd->obd_name); -- lmv_proc_dir = NULL; -+ obd->obd_type->typ_procsym = NULL; - } -- obd->obd_proc_private = lmv_proc_dir; - } - #endif - -@@ -302,10 +296,8 @@ static int lmv_connect(const struct lu_env *env, - rc = lmv_check_connect(obd); - - #ifdef __KERNEL__ -- if (rc && lmv_proc_dir) { -- lprocfs_remove(&lmv_proc_dir); -- obd->obd_proc_private = NULL; -- } -+ if (rc && obd->obd_type->typ_procsym != NULL) -+ lprocfs_remove(&obd->obd_type->typ_procsym); - #endif - RETURN(rc); - } -@@ -384,9 +376,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, - - int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) - { --#ifdef __KERNEL__ -- struct proc_dir_entry *lmv_proc_dir; --#endif - struct lmv_obd *lmv = &obd->u.lmv; - struct obd_uuid *cluuid = &lmv->cluuid; - struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" }; -@@ -466,14 +455,13 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) - cfs_atomic_read(&obd->obd_refcount)); - - #ifdef __KERNEL__ -- lmv_proc_dir = obd->obd_proc_private; -- if (lmv_proc_dir) { -+ if (obd->obd_type->typ_procsym != NULL) { - struct proc_dir_entry *mdc_symlink; - - LASSERT(mdc_obd->obd_type != NULL); - LASSERT(mdc_obd->obd_type->typ_name != NULL); - mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name, -- lmv_proc_dir, -+ obd->obd_type->typ_procsym, - "../../../%s/%s", - mdc_obd->obd_type->typ_name, - mdc_obd->obd_name); -@@ -482,8 +470,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) - "/proc/fs/lustre/%s/%s/target_obds/%s.", - obd->obd_type->typ_name, obd->obd_name, - mdc_obd->obd_name); -- lprocfs_remove(&lmv_proc_dir); -- obd->obd_proc_private = NULL; -+ lprocfs_remove(&obd->obd_type->typ_procsym); - } - } - #endif -@@ -675,9 +662,6 @@ int lmv_check_connect(struct obd_device *obd) - - static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) - { --#ifdef __KERNEL__ -- struct proc_dir_entry *lmv_proc_dir; --#endif - struct lmv_obd *lmv = &obd->u.lmv; - struct obd_device *mdc_obd; - int rc; -@@ -695,9 +679,9 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) - } - - #ifdef __KERNEL__ -- lmv_proc_dir = obd->obd_proc_private; -- if (lmv_proc_dir) -- lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir); -+ if (obd->obd_type->typ_procsym != NULL) -+ lprocfs_remove_proc_entry(mdc_obd->obd_name, -+ obd->obd_type->typ_procsym); - #endif - rc = obd_fid_fini(tgt->ltd_exp->exp_obd); - if (rc) -@@ -747,8 +731,8 @@ static int lmv_disconnect(struct obd_export *exp) - } - - #ifdef __KERNEL__ -- if (obd->obd_proc_private) -- lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private); -+ if (obd->obd_type->typ_procsym != NULL) -+ lprocfs_remove(&obd->obd_type->typ_procsym); - else - CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", - obd->obd_type->typ_name, obd->obd_name); -diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c -index 286cd15..a3310fd 100644 ---- a/lustre/lov/lov_obd.c -+++ b/lustre/lov/lov_obd.c -@@ -127,19 +127,16 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched, - int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, - struct obd_connect_data *data) - { -- struct lov_obd *lov = &obd->u.lov; -- struct obd_uuid *tgt_uuid; -- struct obd_device *tgt_obd; -- static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; -- struct obd_import *imp; --#ifdef __KERNEL__ -- struct proc_dir_entry *lov_proc_dir; --#endif -- int rc; -- ENTRY; -+ struct lov_obd *lov = &obd->u.lov; -+ struct obd_uuid *tgt_uuid; -+ struct obd_device *tgt_obd; -+ static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" }; -+ struct obd_import *imp; -+ int rc; -+ ENTRY; - -- if (!lov->lov_tgts[index]) -- RETURN(-EINVAL); -+ if (lov->lov_tgts[index] == NULL) -+ RETURN(-EINVAL); - - tgt_uuid = &lov->lov_tgts[index]->ltd_uuid; - tgt_obd = lov->lov_tgts[index]->ltd_obd; -@@ -195,27 +192,25 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate, - obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in"); - - #ifdef __KERNEL__ -- lov_proc_dir = obd->obd_proc_private; -- if (lov_proc_dir) { -- struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; -+ if (obd->obd_type->typ_procsym != NULL) { -+ struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd; - struct proc_dir_entry *osc_symlink; - -- LASSERT(osc_obd != NULL); -- LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); -- LASSERT(osc_obd->obd_type->typ_name != NULL); -- -- osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, -- lov_proc_dir, -- "../../../%s/%s", -- osc_obd->obd_type->typ_name, -- osc_obd->obd_name); -- if (osc_symlink == NULL) { -- CERROR("could not register LOV target " -- "/proc/fs/lustre/%s/%s/target_obds/%s.", -- obd->obd_type->typ_name, obd->obd_name, -- osc_obd->obd_name); -- lprocfs_remove(&lov_proc_dir); -- obd->obd_proc_private = NULL; -+ LASSERT(osc_obd != NULL); -+ LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC); -+ LASSERT(osc_obd->obd_type->typ_name != NULL); -+ -+ osc_symlink = lprocfs_add_symlink(osc_obd->obd_name, -+ obd->obd_type->typ_procsym, -+ "../../../%s/%s", -+ osc_obd->obd_type->typ_name, -+ osc_obd->obd_name); -+ if (osc_symlink == NULL) { -+ CERROR("could not register LOV target " -+ "/proc/fs/lustre/%s/%s/target_obds/%s.", -+ obd->obd_type->typ_name, obd->obd_name, -+ osc_obd->obd_name); -+ lprocfs_remove(&obd->obd_type->typ_procsym); - } - } - #endif -@@ -250,6 +245,17 @@ static int lov_connect(const struct lu_env *env, - if (data) - lov->lov_ocd = *data; - -+#ifdef __KERNEL__ -+ obd->obd_type->typ_procsym = lprocfs_seq_register("target_obds", -+ obd->obd_proc_entry, -+ NULL, NULL); -+ if (IS_ERR(obd->obd_type->typ_procsym)) { -+ CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.", -+ obd->obd_type->typ_name, obd->obd_name); -+ obd->obd_type->typ_procsym = NULL; -+ } -+#endif -+ - obd_getref(obd); - for (i = 0; i < lov->desc.ld_tgt_count; i++) { - tgt = lov->lov_tgts[i]; -@@ -280,7 +286,6 @@ static int lov_connect(const struct lu_env *env, - - static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) - { -- struct proc_dir_entry *lov_proc_dir; - struct lov_obd *lov = &obd->u.lov; - struct obd_device *osc_obd; - int rc; -@@ -296,18 +301,18 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt) - tgt->ltd_exp->exp_obd->obd_inactive = 1; - } - -- lov_proc_dir = obd->obd_proc_private; -- if (lov_proc_dir) -- lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir); -+ if (obd->obd_type->typ_procsym) -+ lprocfs_remove_proc_entry(osc_obd->obd_name, -+ obd->obd_type->typ_procsym); - -- if (osc_obd) { -- /* Pass it on to our clients. -- * XXX This should be an argument to disconnect, -- * XXX not a back-door flag on the OBD. Ah well. -- */ -- osc_obd->obd_force = obd->obd_force; -- osc_obd->obd_fail = obd->obd_fail; -- osc_obd->obd_no_recov = obd->obd_no_recov; -+ if (osc_obd) { -+ /* Pass it on to our clients. -+ * XXX This should be an argument to disconnect, -+ * XXX not a back-door flag on the OBD. Ah well. -+ */ -+ osc_obd->obd_force = obd->obd_force; -+ osc_obd->obd_fail = obd->obd_fail; -+ osc_obd->obd_no_recov = obd->obd_no_recov; - } - - obd_register_observer(osc_obd, NULL); -@@ -353,6 +358,14 @@ static int lov_disconnect(struct obd_export *exp) - } - obd_putref(obd); - -+#ifdef __KERNEL__ -+ if (obd->obd_type->typ_procsym) -+ lprocfs_remove(&obd->obd_type->typ_procsym); -+ else -+ CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n", -+ obd->obd_type->typ_name, obd->obd_name); -+#endif -+ - out: - rc = class_disconnect(exp); /* bz 9811 */ - RETURN(rc); -diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c -index c9d8a4e..a4a981c 100644 ---- a/lustre/obdclass/genops.c -+++ b/lustre/obdclass/genops.c -@@ -181,14 +181,15 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, - RETURN(-EEXIST); - } - -- rc = -ENOMEM; -- OBD_ALLOC(type, sizeof(*type)); -- if (type == NULL) -- RETURN(rc); -+ rc = -ENOMEM; -+ OBD_ALLOC(type, sizeof(*type)); -+ if (type == NULL) -+ RETURN(rc); -+ memset(type, 0, sizeof(*type)); - -- OBD_ALLOC_PTR(type->typ_dt_ops); -- OBD_ALLOC_PTR(type->typ_md_ops); -- OBD_ALLOC(type->typ_name, strlen(name) + 1); -+ OBD_ALLOC_PTR(type->typ_dt_ops); -+ OBD_ALLOC_PTR(type->typ_md_ops); -+ OBD_ALLOC(type->typ_name, strlen(name) + 1); - - if (type->typ_dt_ops == NULL || - type->typ_md_ops == NULL || -@@ -242,6 +243,8 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, - if (type->typ_dt_ops != NULL) - OBD_FREE_PTR(type->typ_dt_ops); - #ifdef LPROCFS -+ if (type->typ_procsym != NULL) -+ lprocfs_remove(&type->typ_procsym); - #ifndef HAVE_ONLY_PROCFS_SEQ - lprocfs_try_remove_proc_entry(type->typ_name, proc_lustre_root); - #else --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0005-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0005-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch new file mode 100644 index 000000000..7734600ca --- /dev/null +++ b/sys-cluster/lustre/files/0005-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch @@ -0,0 +1,799 @@ +From cfafe91ff9caf648f144c1a162112b7d1485aae4 Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Sun, 9 Feb 2014 17:10:18 -0500 +Subject: [PATCH 05/12] LU-3319 procfs: move osp proc handling to seq_files + +With 3.10 linux kernel and above proc handling now only +uses struct seq_files. This patch migrates the osp +layer proc entries over to using seq_files. + +Signed-off-by: James Simmons +Change-Id: Id8f77d72fd35755f1b7b1c17fcf27e0731bd5ac1 +--- + lustre/osp/lproc_osp.c | 373 ++++++++++++++++++++++++---------------------- + lustre/osp/lwp_dev.c | 18 +-- + lustre/osp/osp_dev.c | 48 +++--- + lustre/osp/osp_internal.h | 2 - + 4 files changed, 222 insertions(+), 219 deletions(-) + +diff --git a/lustre/osp/lproc_osp.c b/lustre/osp/lproc_osp.c +index 75ebeb1..1ec40fc 100644 +--- a/lustre/osp/lproc_osp.c ++++ b/lustre/osp/lproc_osp.c +@@ -45,24 +45,23 @@ + #include "osp_internal.h" + + #ifdef LPROCFS +-static int osp_rd_active(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_active_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + int rc; + + LPROCFS_CLIMP_CHECK(dev); +- rc = snprintf(page, count, "%d\n", +- !dev->u.cli.cl_import->imp_deactive); ++ rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive); + LPROCFS_CLIMP_EXIT(dev); + return rc; + } + +-static int osp_wr_active(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++osp_active_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = data; +- int val, rc; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; ++ int val, rc; + + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) +@@ -81,67 +80,60 @@ static int osp_wr_active(struct file *file, const char *buffer, + LPROCFS_CLIMP_EXIT(dev); + return count; + } ++LPROC_SEQ_FOPS(osp_active); + +-static int osp_rd_syn_in_flight(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%u\n", osp->opd_syn_rpc_in_flight); +- return rc; ++ return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_flight); + } ++LPROC_SEQ_FOPS_RO(osp_syn_in_flight); + +-static int osp_rd_syn_in_prog(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%u\n", osp->opd_syn_rpc_in_progress); +- return rc; ++ return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_progress); + } ++LPROC_SEQ_FOPS_RO(osp_syn_in_prog); + +-static int osp_rd_syn_changes(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_syn_changes_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%lu\n", osp->opd_syn_changes); +- return rc; ++ return seq_printf(m, "%lu\n", osp->opd_syn_changes); + } ++LPROC_SEQ_FOPS_RO(osp_syn_changes); + +-static int osp_rd_max_rpcs_in_flight(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%u\n", osp->opd_syn_max_rpc_in_flight); +- return rc; ++ return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight); + } + +-static int osp_wr_max_rpcs_in_flight(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++osp_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); + int val, rc; + +@@ -158,25 +150,24 @@ static int osp_wr_max_rpcs_in_flight(struct file *file, const char *buffer, + osp->opd_syn_max_rpc_in_flight = val; + return count; + } ++LPROC_SEQ_FOPS(osp_max_rpcs_in_flight); + +-static int osp_rd_max_rpcs_in_prog(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%u\n", osp->opd_syn_max_rpc_in_progress); +- return rc; ++ return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress); + } + +-static int osp_wr_max_rpcs_in_prog(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++osp_max_rpcs_in_prog_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); + int val, rc; + +@@ -194,23 +185,24 @@ static int osp_wr_max_rpcs_in_prog(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(osp_max_rpcs_in_prog); + +-static int osp_rd_create_count(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int osp_create_count_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + + if (osp == NULL || osp->opd_pre == NULL) + return 0; + +- return snprintf(page, count, "%d\n", osp->opd_pre_grow_count); ++ return seq_printf(m, "%d\n", osp->opd_pre_grow_count); + } + +-static int osp_wr_create_count(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++osp_create_count_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + int val, rc, i; + +@@ -242,23 +234,24 @@ static int osp_wr_create_count(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(osp_create_count); + +-static int osp_rd_max_create_count(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_max_create_count_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + + if (osp == NULL || osp->opd_pre == NULL) + return 0; + +- return snprintf(page, count, "%d\n", osp->opd_pre_max_grow_count); ++ return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count); + } + +-static int osp_wr_max_create_count(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++osp_max_create_count_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + int val, rc; + +@@ -281,89 +274,85 @@ static int osp_wr_max_create_count(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(osp_max_create_count); + +-static int osp_rd_prealloc_next_id(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + + if (osp == NULL || osp->opd_pre == NULL) + return 0; + +- return snprintf(page, count, "%u\n", +- fid_oid(&osp->opd_pre_used_fid) + 1); ++ return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1); + } ++LPROC_SEQ_FOPS_RO(osp_prealloc_next_id); + +-static int osp_rd_prealloc_last_id(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + + if (osp == NULL || osp->opd_pre == NULL) + return 0; + +- return snprintf(page, count, "%u\n", +- fid_oid(&osp->opd_pre_last_created_fid)); ++ return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid)); + } ++LPROC_SEQ_FOPS_RO(osp_prealloc_last_id); + +-static int osp_rd_prealloc_next_seq(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + + if (osp == NULL || osp->opd_pre == NULL) + return 0; + +- return snprintf(page, count, LPX64"\n", +- fid_seq(&osp->opd_pre_used_fid)); ++ return seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid)); + } ++LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq); + +-static int osp_rd_prealloc_last_seq(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + + if (osp == NULL || osp->opd_pre == NULL) + return 0; + +- return snprintf(page, count, LPX64"\n", ++ return seq_printf(m, LPX64"\n", + fid_seq(&osp->opd_pre_last_created_fid)); + } ++LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq); + +-static int osp_rd_prealloc_reserved(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); + + if (osp == NULL || osp->opd_pre == NULL) + return 0; + +- return snprintf(page, count, LPU64"\n", osp->opd_pre_reserved); ++ return seq_printf(m, LPU64"\n", osp->opd_pre_reserved); + } ++LPROC_SEQ_FOPS_RO(osp_prealloc_reserved); + +-static int osp_rd_maxage(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_maxage_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%u\n", osp->opd_statfs_maxage); +- return rc; ++ return seq_printf(m, "%u\n", osp->opd_statfs_maxage); + } + +-static int osp_wr_maxage(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++osp_maxage_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); + int val, rc; + +@@ -381,25 +370,23 @@ static int osp_wr_maxage(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(osp_maxage); + +-static int osp_rd_pre_status(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_pre_status_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL || osp->opd_pre == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%d\n", osp->opd_pre_status); +- return rc; ++ return seq_printf(m, "%d\n", osp->opd_pre_status); + } ++LPROC_SEQ_FOPS_RO(osp_pre_status); + +-static int osp_rd_destroys_in_flight(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); + + if (osp == NULL) +@@ -411,87 +398,126 @@ static int osp_rd_destroys_in_flight(char *page, char **start, off_t off, + * - sync changes are zero - no llog records + * - sync in progress are zero - no RPCs in flight + */ +- return snprintf(page, count, "%lu\n", ++ return seq_printf(m, "%lu\n", + osp->opd_syn_rpc_in_progress + osp->opd_syn_changes); + } ++LPROC_SEQ_FOPS_RO(osp_destroys_in_flight); + +-static int osp_rd_old_sync_processed(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *dev = data; ++ struct obd_device *dev = m->private; + struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); +- int rc; + + if (osp == NULL) + return -EINVAL; + +- rc = snprintf(page, count, "%d\n", osp->opd_syn_prev_done); +- return rc; ++ return seq_printf(m, "%d\n", osp->opd_syn_prev_done); + } ++LPROC_SEQ_FOPS_RO(osp_old_sync_processed); + +-static struct lprocfs_vars lprocfs_osp_obd_vars[] = { +- { "uuid", lprocfs_rd_uuid, 0, 0 }, +- { "ping", 0, lprocfs_wr_ping, 0, 0, 0222 }, +- { "connect_flags", lprocfs_rd_connect_flags, 0, 0 }, +- { "ost_server_uuid", lprocfs_rd_server_uuid, 0, 0 }, +- { "ost_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 }, +- { "active", osp_rd_active, osp_wr_active, 0 }, +- { "max_rpcs_in_flight", osp_rd_max_rpcs_in_flight, +- osp_wr_max_rpcs_in_flight, 0 }, +- { "max_rpcs_in_progress", osp_rd_max_rpcs_in_prog, +- osp_wr_max_rpcs_in_prog, 0 }, +- { "create_count", osp_rd_create_count, +- osp_wr_create_count, 0 }, +- { "max_create_count", osp_rd_max_create_count, +- osp_wr_max_create_count, 0 }, +- { "prealloc_next_id", osp_rd_prealloc_next_id, 0, 0 }, +- { "prealloc_next_seq", osp_rd_prealloc_next_seq, 0, 0 }, +- { "prealloc_last_id", osp_rd_prealloc_last_id, 0, 0 }, +- { "prealloc_last_seq", osp_rd_prealloc_last_seq, 0, 0 }, +- { "prealloc_reserved", osp_rd_prealloc_reserved, 0, 0 }, +- { "timeouts", lprocfs_rd_timeouts, 0, 0 }, +- { "import", lprocfs_rd_import, lprocfs_wr_import, 0 }, +- { "state", lprocfs_rd_state, 0, 0 }, +- { "maxage", osp_rd_maxage, osp_wr_maxage, 0 }, +- { "prealloc_status", osp_rd_pre_status, 0, 0 }, +- { "sync_changes", osp_rd_syn_changes, 0, 0 }, +- { "sync_in_flight", osp_rd_syn_in_flight, 0, 0 }, +- { "sync_in_progress", osp_rd_syn_in_prog, 0, 0 }, +- { "old_sync_processed", osp_rd_old_sync_processed, 0, 0 }, ++LPROC_SEQ_FOPS_WO_TYPE(osp, ping); ++LPROC_SEQ_FOPS_RO_TYPE(osp, uuid); ++LPROC_SEQ_FOPS_RO_TYPE(osp, connect_flags); ++LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid); ++LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid); + +- /* for compatibility reasons */ +- { "destroys_in_flight", osp_rd_destroys_in_flight, 0, 0 }, +- { 0 } +-}; ++static int osp_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) ++{ ++ return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private); ++} ++LPROC_SEQ_FOPS_RO(osp_max_pages_per_rpc); ++LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts); ++ ++LPROC_SEQ_FOPS_RW_TYPE(osp, import); ++LPROC_SEQ_FOPS_RO_TYPE(osp, state); ++ ++static struct lprocfs_seq_vars lprocfs_osp_obd_vars[] = { ++ { .name = "uuid", ++ .fops = &osp_uuid_fops }, ++ { .name = "ping", ++ .fops = &osp_ping_fops, ++ .proc_mode = 0222 }, ++ { .name = "connect_flags", ++ .fops = &osp_connect_flags_fops }, ++ { .name = "ost_server_uuid", ++ .fops = &osp_server_uuid_fops }, ++ { .name = "ost_conn_uuid", ++ .fops = &osp_conn_uuid_fops }, ++ { .name = "active", ++ .fops = &osp_active_fops }, ++ { .name = "max_rpcs_in_flight", ++ .fops = &osp_max_rpcs_in_flight_fops }, ++ { .name = "max_rpcs_in_progress", ++ .fops = &osp_max_rpcs_in_prog_fops }, ++ { .name = "create_count", ++ .fops = &osp_create_count_fops }, ++ { .name = "max_create_count", ++ .fops = &osp_max_create_count_fops }, ++ { .name = "prealloc_next_id", ++ .fops = &osp_prealloc_next_id_fops }, ++ { .name = "prealloc_next_seq", ++ .fops = &osp_prealloc_next_seq_fops }, ++ { .name = "prealloc_last_id", ++ .fops = &osp_prealloc_last_id_fops }, ++ { .name = "prealloc_last_seq", ++ .fops = &osp_prealloc_last_seq_fops }, ++ { .name = "prealloc_reserved", ++ .fops = &osp_prealloc_reserved_fops }, ++ { .name = "timeouts", ++ .fops = &osp_timeouts_fops }, ++ { .name = "import", ++ .fops = &osp_import_fops }, ++ { .name = "state", ++ .fops = &osp_state_fops }, ++ { .name = "maxage", ++ .fops = &osp_maxage_fops }, ++ { .name = "prealloc_status", ++ .fops = &osp_pre_status_fops }, ++ { .name = "sync_changes", ++ .fops = &osp_syn_changes_fops }, ++ { .name = "sync_in_flight", ++ .fops = &osp_syn_in_flight_fops }, ++ { .name = "sync_in_progress", ++ .fops = &osp_syn_in_prog_fops }, ++ { .name = "old_sync_processed", ++ .fops = &osp_old_sync_processed_fops }, + +-static struct lprocfs_vars lprocfs_osp_osd_vars[] = { +- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, +- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, +- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, +- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, +- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, +- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, ++ /* for compatibility reasons */ ++ { .name = "destroys_in_flight", ++ .fops = &osp_destroys_in_flight_fops }, + { 0 } + }; + +-static struct lprocfs_vars lprocfs_osp_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, ++LPROC_SEQ_FOPS_RO_TYPE(osp, dt_blksize); ++LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytestotal); ++LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesfree); ++LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesavail); ++LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filestotal); ++LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filesfree); ++ ++static struct lprocfs_seq_vars lprocfs_osp_osd_vars[] = { ++ { .name = "blocksize", ++ .fops = &osp_dt_blksize_fops }, ++ { .name = "kbytestotal", ++ .fops = &osp_dt_kbytestotal_fops }, ++ { .name = "kbytesfree", ++ .fops = &osp_dt_kbytesfree_fops }, ++ { .name = "kbytesavail", ++ .fops = &osp_dt_kbytesavail_fops }, ++ { .name = "filestotal", ++ .fops = &osp_dt_filestotal_fops }, ++ { .name = "filesfree", ++ .fops = &osp_dt_filesfree_fops }, + { 0 } + }; + +-void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars) +-{ +- lvars->module_vars = lprocfs_osp_module_vars; +- lvars->obd_vars = lprocfs_osp_obd_vars; +-} +- + void osp_lprocfs_init(struct osp_device *osp) + { + struct obd_device *obd = osp->opd_obd; +- struct proc_dir_entry *osc_proc_dir; ++ struct proc_dir_entry *symlink = NULL; + int rc; + +- obd->obd_proc_entry = lprocfs_register(obd->obd_name, ++ obd->obd_proc_entry = lprocfs_seq_register(obd->obd_name, + obd->obd_type->typ_procroot, + lprocfs_osp_osd_vars, + &osp->opd_dt_dev); +@@ -502,34 +528,29 @@ void osp_lprocfs_init(struct osp_device *osp) + return; + } + +- rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd); ++ rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd); + if (rc) { + CERROR("%s: can't register in lprocfs: %ld\n", + obd->obd_name, PTR_ERR(obd->obd_proc_entry)); + return; + } ++ obd->obd_vars = lprocfs_osp_obd_vars; + + ptlrpc_lprocfs_register_obd(obd); + ++ if (osp->opd_connect_mdt || obd->obd_type->typ_procsym == NULL || ++ !strstr(obd->obd_name, "osc")) ++ return; ++ + /* for compatibility we link old procfs's OSC entries to osp ones */ +- if (!osp->opd_connect_mdt) { +- osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc"); +- if (osc_proc_dir) { +- cfs_proc_dir_entry_t *symlink = NULL; +- char *name; +- +- OBD_ALLOC(name, strlen(obd->obd_name) + 1); +- if (name == NULL) +- return; +- +- strcpy(name, obd->obd_name); +- if (strstr(name, "osc")) +- symlink = lprocfs_add_symlink(name, +- osc_proc_dir, "../osp/%s", +- obd->obd_name); +- OBD_FREE(name, strlen(obd->obd_name) + 1); +- osp->opd_symlink = symlink; +- } ++ symlink = lprocfs_add_symlink(obd->obd_name, obd->obd_type->typ_procsym, ++ "../osp/%s", obd->obd_name); ++ if (symlink == NULL) { ++ CERROR("could not register OSC symlink for " ++ "/proc/fs/lustre/osp/%s.", obd->obd_name); ++ lprocfs_remove(&obd->obd_type->typ_procsym); ++ } else { ++ osp->opd_symlink = symlink; + } + } + +diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c +index 9560504..d6ae965 100644 +--- a/lustre/osp/lwp_dev.c ++++ b/lustre/osp/lwp_dev.c +@@ -186,25 +186,13 @@ const struct lu_device_operations lwp_lu_ops = { + .ldo_process_config = lwp_process_config, + }; + +-static struct lprocfs_vars lprocfs_lwp_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, ++static struct lprocfs_seq_vars lprocfs_lwp_obd_vars[] = { + { 0 } + }; + +-static struct lprocfs_vars lprocfs_lwp_obd_vars[] = { +- { 0 } +-}; +- +-void lprocfs_lwp_init_vars(struct lprocfs_static_vars *lvars) +-{ +- lvars->module_vars = lprocfs_lwp_module_vars; +- lvars->obd_vars = lprocfs_lwp_obd_vars; +-} +- + int lwp_init0(const struct lu_env *env, struct lwp_device *lwp, + struct lu_device_type *ldt, struct lustre_cfg *cfg) + { +- struct lprocfs_static_vars lvars = { 0 }; + int rc; + ENTRY; + +@@ -233,8 +221,8 @@ int lwp_init0(const struct lu_env *env, struct lwp_device *lwp, + RETURN(rc); + } + +- lprocfs_lwp_init_vars(&lvars); +- if (lprocfs_obd_setup(lwp->lpd_obd, lvars.obd_vars) == 0) ++ lwp->lpd_obd->obd_vars = lprocfs_lwp_obd_vars; ++ if (lprocfs_seq_obd_setup(lwp->lpd_obd) == 0) + ptlrpc_lprocfs_register_obd(lwp->lpd_obd); + + RETURN(0); +diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c +index 5828d88..7d45fa1 100644 +--- a/lustre/osp/osp_dev.c ++++ b/lustre/osp/osp_dev.c +@@ -371,7 +371,7 @@ static int osp_process_config(const struct lu_env *env, + struct lu_device *dev, struct lustre_cfg *lcfg) + { + struct osp_device *d = lu2osp_dev(dev); +- struct lprocfs_static_vars lvars = { 0 }; ++ struct obd_device *obd = d->opd_obd; + int rc; + + ENTRY; +@@ -385,11 +385,9 @@ static int osp_process_config(const struct lu_env *env, + rc = osp_shutdown(env, d); + break; + case LCFG_PARAM: +- lprocfs_osp_init_vars(&lvars); +- +- LASSERT(d->opd_obd); +- rc = class_process_proc_param(PARAM_OSC, lvars.obd_vars, +- lcfg, d->opd_obd); ++ LASSERT(obd); ++ rc = class_process_proc_seq_param(PARAM_OSC, obd->obd_vars, ++ lcfg, obd); + if (rc > 0) + rc = 0; + if (rc == -ENOSYS) { +@@ -842,6 +840,9 @@ static struct lu_device *osp_device_fini(const struct lu_env *env, + OBD_FREE_PTR(cli->cl_rpc_lock); + cli->cl_rpc_lock = NULL; + } ++ } else { ++ if (m->opd_obd->obd_type->typ_procsym != NULL) ++ lprocfs_remove(&m->opd_obd->obd_type->typ_procsym); + } + + rc = client_obd_cleanup(m->opd_obd); +@@ -1220,33 +1221,26 @@ struct llog_operations osp_mds_ost_orig_logops; + + static int __init osp_mod_init(void) + { +- struct lprocfs_static_vars lvars; +- cfs_proc_dir_entry_t *osc_proc_dir; +- int rc; ++ struct obd_type *type; ++ int rc; + + rc = lu_kmem_init(osp_caches); + if (rc) + return rc; + +- lprocfs_osp_init_vars(&lvars); +- + rc = class_register_type(&osp_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lvars.module_vars, ++ NULL, + #endif + LUSTRE_OSP_NAME, &osp_device_type); +- +- /* create "osc" entry in procfs for compatibility purposes */ + if (rc != 0) { + lu_kmem_fini(osp_caches); + return rc; + } + +- lprocfs_lwp_init_vars(&lvars); +- + rc = class_register_type(&lwp_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lvars.module_vars, ++ NULL, + #endif + LUSTRE_LWP_NAME, &lwp_device_type); + if (rc != 0) { +@@ -1260,21 +1254,23 @@ static int __init osp_mod_init(void) + osp_mds_ost_orig_logops.lop_add = llog_cat_add_rec; + osp_mds_ost_orig_logops.lop_declare_add = llog_cat_declare_add_rec; + +- osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc"); +- if (osc_proc_dir == NULL) { +- osc_proc_dir = lprocfs_register("osc", proc_lustre_root, NULL, +- NULL); +- if (IS_ERR(osc_proc_dir)) +- CERROR("osp: can't create compat entry \"osc\": %d\n", +- (int) PTR_ERR(osc_proc_dir)); ++ type = class_search_type(LUSTRE_OSC_NAME); ++ if (type) ++ return rc; ++ ++ type = class_search_type(LUSTRE_OSP_NAME); ++ type->typ_procsym = lprocfs_seq_register("osc", proc_lustre_root, ++ NULL, NULL); ++ if (IS_ERR(type->typ_procsym)) { ++ CERROR("osp: can't create compat entry \"osc\": %d\n", ++ (int) PTR_ERR(type->typ_procsym)); ++ type->typ_procsym = NULL; + } + return rc; + } + + static void __exit osp_mod_exit(void) + { +- lprocfs_try_remove_proc_entry("osc", proc_lustre_root); +- + class_unregister_type(LUSTRE_LWP_NAME); + class_unregister_type(LUSTRE_OSP_NAME); + lu_kmem_fini(osp_caches); +diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h +index 0871d8d..0cc608b 100644 +--- a/lustre/osp/osp_internal.h ++++ b/lustre/osp/osp_internal.h +@@ -433,7 +433,6 @@ int osp_write_last_oid_seq_files(struct lu_env *env, struct osp_device *osp, + int osp_init_pre_fid(struct osp_device *osp); + + /* lproc_osp.c */ +-void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars); + void osp_lprocfs_init(struct osp_device *osp); + + /* osp_sync.c */ +@@ -447,7 +446,6 @@ int osp_sync_fini(struct osp_device *d); + void __osp_sync_check_for_work(struct osp_device *d); + + /* lwp_dev.c */ +-void lprocfs_lwp_init_vars(struct lprocfs_static_vars *lvars); + extern struct obd_ops lwp_obd_device_ops; + extern struct lu_device_type lwp_device_type; + +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0006-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0006-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch new file mode 100644 index 000000000..1ca6b125d --- /dev/null +++ b/sys-cluster/lustre/files/0006-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch @@ -0,0 +1,597 @@ +From 82953bddbc3c7b9aa044d9eecc796bc12638f476 Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Sun, 9 Feb 2014 11:08:45 -0500 +Subject: [PATCH 06/12] LU-3319 procfs: move lod proc handling to seq_files + +With 3.10 linux kernel and above proc handling now only +uses struct seq_files. This patch migrates the lod +layer proc entries over to using seq_files. + +Signed-off-by: James Simmons +Change-Id: Iaa0f617fcd430e91f12afbc0faf6906fd275a7a5 +--- + lustre/lod/lod_dev.c | 39 ++++--- + lustre/lod/lod_internal.h | 1 - + lustre/lod/lod_pool.c | 7 +- + lustre/lod/lproc_lod.c | 251 ++++++++++++++++++++++++---------------------- + 4 files changed, 152 insertions(+), 146 deletions(-) + +diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c +index 02a1e1e..b0ad1fd 100644 +--- a/lustre/lod/lod_dev.c ++++ b/lustre/lod/lod_dev.c +@@ -297,12 +297,10 @@ static int lod_process_config(const struct lu_env *env, + } + + case LCFG_PARAM: { +- struct lprocfs_static_vars v = { 0 }; +- struct obd_device *obd = lod2obd(lod); ++ struct obd_device *obd = lod2obd(lod); + +- lprocfs_lod_init_vars(&v); +- +- rc = class_process_proc_param(PARAM_LOV, v.obd_vars, lcfg, obd); ++ rc = class_process_proc_seq_param(PARAM_LOV, obd->obd_vars, ++ lcfg, obd); + if (rc > 0) + rc = 0; + GOTO(out, rc); +@@ -916,19 +914,16 @@ static struct obd_ops lod_obd_device_ops = { + + static int __init lod_mod_init(void) + { +- struct lprocfs_static_vars lvars = { 0 }; +- cfs_proc_dir_entry_t *lov_proc_dir; +- int rc; ++ struct obd_type *lod, *lov; ++ int rc; + + rc = lu_kmem_init(lod_caches); + if (rc) + return rc; + +- lprocfs_lod_init_vars(&lvars); +- + rc = class_register_type(&lod_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lvars.module_vars, ++ NULL, + #endif + LUSTRE_LOD_NAME, &lod_device_type); + if (rc) { +@@ -937,23 +932,25 @@ static int __init lod_mod_init(void) + } + + /* create "lov" entry in procfs for compatibility purposes */ +- lov_proc_dir = lprocfs_srch(proc_lustre_root, "lov"); +- if (lov_proc_dir == NULL) { +- lov_proc_dir = lprocfs_register("lov", proc_lustre_root, +- NULL, NULL); +- if (IS_ERR(lov_proc_dir)) ++ lod = class_search_type(LUSTRE_LOD_NAME); ++ lov = class_search_type(LUSTRE_LOV_NAME); ++ if (lov == NULL) { ++ lod->typ_procsym = lprocfs_seq_register("lov", proc_lustre_root, ++ NULL, NULL); ++ if (IS_ERR(lod->typ_procsym)) { + CERROR("lod: can't create compat entry \"lov\": %d\n", +- (int)PTR_ERR(lov_proc_dir)); ++ (int)PTR_ERR(lod->typ_procsym)); ++ lod->typ_procsym = NULL; ++ } ++ } else { ++ /* Map lov proc root to lod symlink */ ++ lod->typ_procsym = lov->typ_procroot; + } +- + return rc; + } + + static void __exit lod_mod_exit(void) + { +- +- lprocfs_try_remove_proc_entry("lov", proc_lustre_root); +- + class_unregister_type(LUSTRE_LOD_NAME); + lu_kmem_fini(lod_caches); + } +diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h +index 6d99ad5..9299a91 100644 +--- a/lustre/lod/lod_internal.h ++++ b/lustre/lod/lod_internal.h +@@ -376,7 +376,6 @@ int qos_add_tgt(struct lod_device*, struct lod_tgt_desc *); + int qos_del_tgt(struct lod_device *, struct lod_tgt_desc *); + + /* lproc_lod.c */ +-void lprocfs_lod_init_vars(struct lprocfs_static_vars *lvars); + int lod_procfs_init(struct lod_device *lod); + void lod_procfs_fini(struct lod_device *lod); + +diff --git a/lustre/lod/lod_pool.c b/lustre/lod/lod_pool.c +index 98b2416..1849e5d 100644 +--- a/lustre/lod/lod_pool.c ++++ b/lustre/lod/lod_pool.c +@@ -283,7 +283,7 @@ static int pool_proc_open(struct inode *inode, struct file *file) + rc = seq_open(file, &pool_proc_ops); + if (!rc) { + struct seq_file *s = file->private_data; +- s->private = PROC_I(inode)->pde->data; ++ s->private = PDE_DATA(inode); + } + return rc; + } +@@ -462,7 +462,10 @@ int lod_pool_new(struct obd_device *obd, char *poolname) + #ifdef LPROCFS + lod_pool_getref(new_pool); + new_pool->pool_proc_entry = lprocfs_add_simple(lod->lod_pool_proc_entry, +- poolname, NULL, NULL, ++ poolname, ++#ifndef HAVE_ONLY_PROCFS_SEQ ++ NULL, NULL, ++#endif + new_pool, + &pool_proc_operations); + if (IS_ERR(new_pool->pool_proc_entry)) { +diff --git a/lustre/lod/lproc_lod.c b/lustre/lod/lproc_lod.c +index e976063..e420a5e 100644 +--- a/lustre/lod/lproc_lod.c ++++ b/lustre/lod/lproc_lod.c +@@ -42,23 +42,22 @@ + #include + + #ifdef LPROCFS +-static int lod_rd_stripesize(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_stripesize_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, LPU64"\n", ++ return seq_printf(m, LPU64"\n", + lod->lod_desc.ld_default_stripe_size); + } + +-static int lod_wr_stripesize(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lod_stripesize_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct lod_device *lod; + __u64 val; + int rc; +@@ -73,24 +72,24 @@ static int lod_wr_stripesize(struct file *file, const char *buffer, + lod->lod_desc.ld_default_stripe_size = val; + return count; + } ++LPROC_SEQ_FOPS(lod_stripesize); + +-static int lod_rd_stripeoffset(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_stripeoffset_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, LPU64"\n", ++ return seq_printf(m, LPU64"\n", + lod->lod_desc.ld_default_stripe_offset); + } + +-static int lod_wr_stripeoffset(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lod_stripeoffset_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct lod_device *lod; + __u64 val; + int rc; +@@ -104,23 +103,23 @@ static int lod_wr_stripeoffset(struct file *file, const char *buffer, + lod->lod_desc.ld_default_stripe_offset = val; + return count; + } ++LPROC_SEQ_FOPS(lod_stripeoffset); + +-static int lod_rd_stripetype(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_stripetype_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%u\n", lod->lod_desc.ld_pattern); ++ return seq_printf(m, "%u\n", lod->lod_desc.ld_pattern); + } + +-static int lod_wr_stripetype(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lod_stripetype_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct lod_device *lod; + int val, rc; + +@@ -134,24 +133,24 @@ static int lod_wr_stripetype(struct file *file, const char *buffer, + lod->lod_desc.ld_pattern = val; + return count; + } ++LPROC_SEQ_FOPS(lod_stripetype); + +-static int lod_rd_stripecount(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_stripecount_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%d\n", ++ return seq_printf(m, "%d\n", + (__s16)(lod->lod_desc.ld_default_stripe_count + 1) - 1); + } + +-static int lod_wr_stripecount(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lod_stripecount_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct lod_device *lod; + int val, rc; + +@@ -165,62 +164,57 @@ static int lod_wr_stripecount(struct file *file, const char *buffer, + lod->lod_desc.ld_default_stripe_count = val; + return count; + } ++LPROC_SEQ_FOPS(lod_stripecount); + +-static int lod_rd_numobd(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_numobd_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device*)data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%u\n", lod->lod_desc.ld_tgt_count); +- ++ return seq_printf(m, "%u\n", lod->lod_desc.ld_tgt_count); + } ++LPROC_SEQ_FOPS_RO(lod_numobd); + +-static int lod_rd_activeobd(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_activeobd_seq_show(struct seq_file *m, void *v) + { +- struct obd_device* dev = (struct obd_device*)data; ++ struct obd_device* dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%u\n", +- lod->lod_desc.ld_active_tgt_count); ++ return seq_printf(m, "%u\n", lod->lod_desc.ld_active_tgt_count); + } ++LPROC_SEQ_FOPS_RO(lod_activeobd); + +-static int lod_rd_desc_uuid(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_desc_uuid_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device*) data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%s\n", lod->lod_desc.ld_uuid.uuid); ++ return seq_printf(m, "%s\n", lod->lod_desc.ld_uuid.uuid); + } ++LPROC_SEQ_FOPS_RO(lod_desc_uuid); + + /* free priority (0-255): how badly user wants to choose empty osts */ +-static int lod_rd_qos_priofree(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_qos_priofree_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device*) data; ++ struct obd_device *dev = m->private; + struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev); + + LASSERT(lod != NULL); +- *eof = 1; +- return snprintf(page, count, "%d%%\n", ++ return seq_printf(m, "%d%%\n", + (lod->lod_qos.lq_prio_free * 100 + 255) >> 8); + } + +-static int lod_wr_qos_priofree(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lod_qos_priofree_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct lod_device *lod; + int val, rc; + +@@ -238,24 +232,24 @@ static int lod_wr_qos_priofree(struct file *file, const char *buffer, + lod->lod_qos.lq_reset = 1; + return count; + } ++LPROC_SEQ_FOPS(lod_qos_priofree); + +-static int lod_rd_qos_thresholdrr(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int lod_qos_thresholdrr_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device*) data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%d%%\n", ++ return seq_printf(m, "%d%%\n", + (lod->lod_qos.lq_threshold_rr * 100 + 255) >> 8); + } + +-static int lod_wr_qos_thresholdrr(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lod_qos_thresholdrr_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct lod_device *lod; + int val, rc; + +@@ -273,23 +267,23 @@ static int lod_wr_qos_thresholdrr(struct file *file, const char *buffer, + lod->lod_qos.lq_dirty = 1; + return count; + } ++LPROC_SEQ_FOPS(lod_qos_thresholdrr); + +-static int lod_rd_qos_maxage(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int lod_qos_maxage_seq_show(struct seq_file *m, void *v) + { +- struct obd_device *dev = (struct obd_device*) data; ++ struct obd_device *dev = m->private; + struct lod_device *lod; + + LASSERT(dev != NULL); + lod = lu2lod_dev(dev->obd_lu_dev); +- *eof = 1; +- return snprintf(page, count, "%u Sec\n", lod->lod_desc.ld_qos_maxage); ++ return seq_printf(m, "%u Sec\n", lod->lod_desc.ld_qos_maxage); + } + +-static int lod_wr_qos_maxage(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lod_qos_maxage_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *dev = (struct obd_device *)data; ++ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; + struct lustre_cfg_bufs bufs; + struct lod_device *lod; + struct lu_device *next; +@@ -327,6 +321,7 @@ static int lod_wr_qos_maxage(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(lod_qos_maxage); + + static void *lod_osts_seq_start(struct seq_file *p, loff_t *pos) + { +@@ -414,56 +409,63 @@ static const struct seq_operations lod_osts_sops = { + + static int lod_osts_seq_open(struct inode *inode, struct file *file) + { +- struct proc_dir_entry *dp = PDE(inode); + struct seq_file *seq; + int rc; + +- LPROCFS_ENTRY_CHECK(dp); + rc = seq_open(file, &lod_osts_sops); + if (rc) + return rc; + + seq = file->private_data; +- seq->private = dp->data; ++ seq->private = PDE_DATA(inode); + return 0; + } + +-static struct lprocfs_vars lprocfs_lod_obd_vars[] = { +- { "uuid", lprocfs_rd_uuid, 0, 0 }, +- { "stripesize", lod_rd_stripesize, lod_wr_stripesize, 0 }, +- { "stripeoffset", lod_rd_stripeoffset, lod_wr_stripeoffset, 0 }, +- { "stripecount", lod_rd_stripecount, lod_wr_stripecount, 0 }, +- { "stripetype", lod_rd_stripetype, lod_wr_stripetype, 0 }, +- { "numobd", lod_rd_numobd, 0, 0 }, +- { "activeobd", lod_rd_activeobd, 0, 0 }, +- { "desc_uuid", lod_rd_desc_uuid, 0, 0 }, +- { "qos_prio_free",lod_rd_qos_priofree, lod_wr_qos_priofree, 0 }, +- { "qos_threshold_rr", lod_rd_qos_thresholdrr, lod_wr_qos_thresholdrr, 0 }, +- { "qos_maxage", lod_rd_qos_maxage, lod_wr_qos_maxage, 0 }, ++LPROC_SEQ_FOPS_RO_TYPE(lod, uuid); ++ ++LPROC_SEQ_FOPS_RO_TYPE(lod, dt_blksize); ++LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytestotal); ++LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytesfree); ++LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytesavail); ++LPROC_SEQ_FOPS_RO_TYPE(lod, dt_filestotal); ++LPROC_SEQ_FOPS_RO_TYPE(lod, dt_filesfree); ++ ++static struct lprocfs_seq_vars lprocfs_lod_obd_vars[] = { ++ { .name = "uuid", ++ .fops = &lod_uuid_fops }, ++ { .name = "stripesize", ++ .fops = &lod_stripesize_fops }, ++ { .name = "stripeoffset", ++ .fops = &lod_stripeoffset_fops }, ++ { .name = "stripecount", ++ .fops = &lod_stripecount_fops }, ++ { .name = "stripetype", ++ .fops = &lod_stripetype_fops }, ++ { .name = "numobd", ++ .fops = &lod_numobd_fops }, ++ { .name = "activeobd", ++ .fops = &lod_activeobd_fops }, ++ { .name = "desc_uuid", ++ .fops = &lod_desc_uuid_fops }, ++ { .name = "qos_prio_free", ++ .fops = &lod_qos_priofree_fops }, ++ { .name = "qos_threshold_rr", ++ .fops = &lod_qos_thresholdrr_fops }, ++ { .name = "qos_maxage", ++ .fops = &lod_qos_maxage_fops }, + { 0 } + }; + +-static struct lprocfs_vars lprocfs_lod_osd_vars[] = { +- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, +- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, +- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, +- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, +- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, +- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, ++static struct lprocfs_seq_vars lprocfs_lod_osd_vars[] = { ++ { "blocksize", &lod_dt_blksize_fops }, ++ { "kbytestotal", &lod_dt_kbytestotal_fops }, ++ { "kbytesfree", &lod_dt_kbytesfree_fops }, ++ { "kbytesavail", &lod_dt_kbytesavail_fops }, ++ { "filestotal", &lod_dt_filestotal_fops }, ++ { "filesfree", &lod_dt_filesfree_fops }, + { 0 } + }; + +-static struct lprocfs_vars lprocfs_lod_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, +- { 0 } +-}; +- +-void lprocfs_lod_init_vars(struct lprocfs_static_vars *lvars) +-{ +- lvars->module_vars = lprocfs_lod_module_vars; +- lvars->obd_vars = lprocfs_lod_obd_vars; +-} +- + static const struct file_operations lod_proc_target_fops = { + .owner = THIS_MODULE, + .open = lod_osts_seq_open, +@@ -475,20 +477,18 @@ static const struct file_operations lod_proc_target_fops = { + int lod_procfs_init(struct lod_device *lod) + { + struct obd_device *obd = lod2obd(lod); +- struct lprocfs_static_vars lvars; +- cfs_proc_dir_entry_t *lov_proc_dir; + int rc; + +- lprocfs_lod_init_vars(&lvars); +- rc = lprocfs_obd_setup(obd, lvars.obd_vars); ++ obd->obd_vars = lprocfs_lod_obd_vars; ++ rc = lprocfs_seq_obd_setup(obd); + if (rc) { + CERROR("%s: cannot setup procfs entry: %d\n", + obd->obd_name, rc); + RETURN(rc); + } + +- rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_lod_osd_vars, +- &lod->lod_dt_dev); ++ rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_lod_osd_vars, ++ &lod->lod_dt_dev); + if (rc) { + CERROR("%s: cannot setup procfs entry: %d\n", + obd->obd_name, rc); +@@ -503,9 +503,9 @@ int lod_procfs_init(struct lod_device *lod) + GOTO(out, rc); + } + +- lod->lod_pool_proc_entry = lprocfs_register("pools", +- obd->obd_proc_entry, +- NULL, NULL); ++ lod->lod_pool_proc_entry = lprocfs_seq_register("pools", ++ obd->obd_proc_entry, ++ NULL, NULL); + if (IS_ERR(lod->lod_pool_proc_entry)) { + rc = PTR_ERR(lod->lod_pool_proc_entry); + lod->lod_pool_proc_entry = NULL; +@@ -514,14 +514,18 @@ int lod_procfs_init(struct lod_device *lod) + GOTO(out, rc); + } + +- /* for compatibility we link old procfs's OSC entries to osp ones */ +- lov_proc_dir = lprocfs_srch(proc_lustre_root, "lov"); +- if (lov_proc_dir != NULL && strstr(obd->obd_name, "lov") != NULL) ++ /* for compatibility we link old procfs's LOV entries to lod ones */ ++ if (obd->obd_type->typ_procsym != NULL) { + lod->lod_symlink = lprocfs_add_symlink(obd->obd_name, +- lov_proc_dir, +- "../lod/%s", +- obd->obd_name); +- ++ obd->obd_type->typ_procsym, ++ "../lod/%s", ++ obd->obd_name); ++ if (lod->lod_symlink == NULL) { ++ CERROR("could not register LOV symlink for " ++ "/proc/fs/lustre/lod/%s.", obd->obd_name); ++ lprocfs_remove(&obd->obd_type->typ_procsym); ++ } ++ } + RETURN(0); + + out: +@@ -542,6 +546,9 @@ void lod_procfs_fini(struct lod_device *lod) + lod->lod_pool_proc_entry = NULL; + } + ++ if (obd->obd_type->typ_procsym != NULL) ++ lprocfs_remove(&obd->obd_type->typ_procsym); ++ + lprocfs_obd_cleanup(obd); + } + +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0006-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0006-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch deleted file mode 100644 index 0ff28fd65..000000000 --- a/sys-cluster/lustre/files/0006-LU-3319-procfs-move-osp-proc-handling-to-seq_files.patch +++ /dev/null @@ -1,799 +0,0 @@ -From cfafe91ff9caf648f144c1a162112b7d1485aae4 Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Sun, 9 Feb 2014 17:10:18 -0500 -Subject: [PATCH 06/13] LU-3319 procfs: move osp proc handling to seq_files - -With 3.10 linux kernel and above proc handling now only -uses struct seq_files. This patch migrates the osp -layer proc entries over to using seq_files. - -Signed-off-by: James Simmons -Change-Id: Id8f77d72fd35755f1b7b1c17fcf27e0731bd5ac1 ---- - lustre/osp/lproc_osp.c | 373 ++++++++++++++++++++++++---------------------- - lustre/osp/lwp_dev.c | 18 +-- - lustre/osp/osp_dev.c | 48 +++--- - lustre/osp/osp_internal.h | 2 - - 4 files changed, 222 insertions(+), 219 deletions(-) - -diff --git a/lustre/osp/lproc_osp.c b/lustre/osp/lproc_osp.c -index 75ebeb1..1ec40fc 100644 ---- a/lustre/osp/lproc_osp.c -+++ b/lustre/osp/lproc_osp.c -@@ -45,24 +45,23 @@ - #include "osp_internal.h" - - #ifdef LPROCFS --static int osp_rd_active(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_active_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - int rc; - - LPROCFS_CLIMP_CHECK(dev); -- rc = snprintf(page, count, "%d\n", -- !dev->u.cli.cl_import->imp_deactive); -+ rc = seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive); - LPROCFS_CLIMP_EXIT(dev); - return rc; - } - --static int osp_wr_active(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+osp_active_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = data; -- int val, rc; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; -+ int val, rc; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) -@@ -81,67 +80,60 @@ static int osp_wr_active(struct file *file, const char *buffer, - LPROCFS_CLIMP_EXIT(dev); - return count; - } -+LPROC_SEQ_FOPS(osp_active); - --static int osp_rd_syn_in_flight(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_syn_in_flight_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%u\n", osp->opd_syn_rpc_in_flight); -- return rc; -+ return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_flight); - } -+LPROC_SEQ_FOPS_RO(osp_syn_in_flight); - --static int osp_rd_syn_in_prog(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int osp_syn_in_prog_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%u\n", osp->opd_syn_rpc_in_progress); -- return rc; -+ return seq_printf(m, "%u\n", osp->opd_syn_rpc_in_progress); - } -+LPROC_SEQ_FOPS_RO(osp_syn_in_prog); - --static int osp_rd_syn_changes(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_syn_changes_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%lu\n", osp->opd_syn_changes); -- return rc; -+ return seq_printf(m, "%lu\n", osp->opd_syn_changes); - } -+LPROC_SEQ_FOPS_RO(osp_syn_changes); - --static int osp_rd_max_rpcs_in_flight(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_max_rpcs_in_flight_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%u\n", osp->opd_syn_max_rpc_in_flight); -- return rc; -+ return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_flight); - } - --static int osp_wr_max_rpcs_in_flight(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+osp_max_rpcs_in_flight_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); - int val, rc; - -@@ -158,25 +150,24 @@ static int osp_wr_max_rpcs_in_flight(struct file *file, const char *buffer, - osp->opd_syn_max_rpc_in_flight = val; - return count; - } -+LPROC_SEQ_FOPS(osp_max_rpcs_in_flight); - --static int osp_rd_max_rpcs_in_prog(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_max_rpcs_in_prog_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%u\n", osp->opd_syn_max_rpc_in_progress); -- return rc; -+ return seq_printf(m, "%u\n", osp->opd_syn_max_rpc_in_progress); - } - --static int osp_wr_max_rpcs_in_prog(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+osp_max_rpcs_in_prog_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); - int val, rc; - -@@ -194,23 +185,24 @@ static int osp_wr_max_rpcs_in_prog(struct file *file, const char *buffer, - - return count; - } -+LPROC_SEQ_FOPS(osp_max_rpcs_in_prog); - --static int osp_rd_create_count(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int osp_create_count_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - - if (osp == NULL || osp->opd_pre == NULL) - return 0; - -- return snprintf(page, count, "%d\n", osp->opd_pre_grow_count); -+ return seq_printf(m, "%d\n", osp->opd_pre_grow_count); - } - --static int osp_wr_create_count(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+osp_create_count_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - int val, rc, i; - -@@ -242,23 +234,24 @@ static int osp_wr_create_count(struct file *file, const char *buffer, - - return count; - } -+LPROC_SEQ_FOPS(osp_create_count); - --static int osp_rd_max_create_count(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_max_create_count_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - - if (osp == NULL || osp->opd_pre == NULL) - return 0; - -- return snprintf(page, count, "%d\n", osp->opd_pre_max_grow_count); -+ return seq_printf(m, "%d\n", osp->opd_pre_max_grow_count); - } - --static int osp_wr_max_create_count(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+osp_max_create_count_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - int val, rc; - -@@ -281,89 +274,85 @@ static int osp_wr_max_create_count(struct file *file, const char *buffer, - - return count; - } -+LPROC_SEQ_FOPS(osp_max_create_count); - --static int osp_rd_prealloc_next_id(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_prealloc_next_id_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - - if (osp == NULL || osp->opd_pre == NULL) - return 0; - -- return snprintf(page, count, "%u\n", -- fid_oid(&osp->opd_pre_used_fid) + 1); -+ return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_used_fid) + 1); - } -+LPROC_SEQ_FOPS_RO(osp_prealloc_next_id); - --static int osp_rd_prealloc_last_id(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_prealloc_last_id_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - - if (osp == NULL || osp->opd_pre == NULL) - return 0; - -- return snprintf(page, count, "%u\n", -- fid_oid(&osp->opd_pre_last_created_fid)); -+ return seq_printf(m, "%u\n", fid_oid(&osp->opd_pre_last_created_fid)); - } -+LPROC_SEQ_FOPS_RO(osp_prealloc_last_id); - --static int osp_rd_prealloc_next_seq(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_prealloc_next_seq_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - - if (osp == NULL || osp->opd_pre == NULL) - return 0; - -- return snprintf(page, count, LPX64"\n", -- fid_seq(&osp->opd_pre_used_fid)); -+ return seq_printf(m, LPX64"\n", fid_seq(&osp->opd_pre_used_fid)); - } -+LPROC_SEQ_FOPS_RO(osp_prealloc_next_seq); - --static int osp_rd_prealloc_last_seq(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_prealloc_last_seq_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - - if (osp == NULL || osp->opd_pre == NULL) - return 0; - -- return snprintf(page, count, LPX64"\n", -+ return seq_printf(m, LPX64"\n", - fid_seq(&osp->opd_pre_last_created_fid)); - } -+LPROC_SEQ_FOPS_RO(osp_prealloc_last_seq); - --static int osp_rd_prealloc_reserved(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_prealloc_reserved_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct osp_device *osp = lu2osp_dev(obd->obd_lu_dev); - - if (osp == NULL || osp->opd_pre == NULL) - return 0; - -- return snprintf(page, count, LPU64"\n", osp->opd_pre_reserved); -+ return seq_printf(m, LPU64"\n", osp->opd_pre_reserved); - } -+LPROC_SEQ_FOPS_RO(osp_prealloc_reserved); - --static int osp_rd_maxage(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_maxage_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%u\n", osp->opd_statfs_maxage); -- return rc; -+ return seq_printf(m, "%u\n", osp->opd_statfs_maxage); - } - --static int osp_wr_maxage(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+osp_maxage_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); - int val, rc; - -@@ -381,25 +370,23 @@ static int osp_wr_maxage(struct file *file, const char *buffer, - - return count; - } -+LPROC_SEQ_FOPS(osp_maxage); - --static int osp_rd_pre_status(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_pre_status_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL || osp->opd_pre == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%d\n", osp->opd_pre_status); -- return rc; -+ return seq_printf(m, "%d\n", osp->opd_pre_status); - } -+LPROC_SEQ_FOPS_RO(osp_pre_status); - --static int osp_rd_destroys_in_flight(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_destroys_in_flight_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); - - if (osp == NULL) -@@ -411,87 +398,126 @@ static int osp_rd_destroys_in_flight(char *page, char **start, off_t off, - * - sync changes are zero - no llog records - * - sync in progress are zero - no RPCs in flight - */ -- return snprintf(page, count, "%lu\n", -+ return seq_printf(m, "%lu\n", - osp->opd_syn_rpc_in_progress + osp->opd_syn_changes); - } -+LPROC_SEQ_FOPS_RO(osp_destroys_in_flight); - --static int osp_rd_old_sync_processed(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int osp_old_sync_processed_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *dev = data; -+ struct obd_device *dev = m->private; - struct osp_device *osp = lu2osp_dev(dev->obd_lu_dev); -- int rc; - - if (osp == NULL) - return -EINVAL; - -- rc = snprintf(page, count, "%d\n", osp->opd_syn_prev_done); -- return rc; -+ return seq_printf(m, "%d\n", osp->opd_syn_prev_done); - } -+LPROC_SEQ_FOPS_RO(osp_old_sync_processed); - --static struct lprocfs_vars lprocfs_osp_obd_vars[] = { -- { "uuid", lprocfs_rd_uuid, 0, 0 }, -- { "ping", 0, lprocfs_wr_ping, 0, 0, 0222 }, -- { "connect_flags", lprocfs_rd_connect_flags, 0, 0 }, -- { "ost_server_uuid", lprocfs_rd_server_uuid, 0, 0 }, -- { "ost_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 }, -- { "active", osp_rd_active, osp_wr_active, 0 }, -- { "max_rpcs_in_flight", osp_rd_max_rpcs_in_flight, -- osp_wr_max_rpcs_in_flight, 0 }, -- { "max_rpcs_in_progress", osp_rd_max_rpcs_in_prog, -- osp_wr_max_rpcs_in_prog, 0 }, -- { "create_count", osp_rd_create_count, -- osp_wr_create_count, 0 }, -- { "max_create_count", osp_rd_max_create_count, -- osp_wr_max_create_count, 0 }, -- { "prealloc_next_id", osp_rd_prealloc_next_id, 0, 0 }, -- { "prealloc_next_seq", osp_rd_prealloc_next_seq, 0, 0 }, -- { "prealloc_last_id", osp_rd_prealloc_last_id, 0, 0 }, -- { "prealloc_last_seq", osp_rd_prealloc_last_seq, 0, 0 }, -- { "prealloc_reserved", osp_rd_prealloc_reserved, 0, 0 }, -- { "timeouts", lprocfs_rd_timeouts, 0, 0 }, -- { "import", lprocfs_rd_import, lprocfs_wr_import, 0 }, -- { "state", lprocfs_rd_state, 0, 0 }, -- { "maxage", osp_rd_maxage, osp_wr_maxage, 0 }, -- { "prealloc_status", osp_rd_pre_status, 0, 0 }, -- { "sync_changes", osp_rd_syn_changes, 0, 0 }, -- { "sync_in_flight", osp_rd_syn_in_flight, 0, 0 }, -- { "sync_in_progress", osp_rd_syn_in_prog, 0, 0 }, -- { "old_sync_processed", osp_rd_old_sync_processed, 0, 0 }, -+LPROC_SEQ_FOPS_WO_TYPE(osp, ping); -+LPROC_SEQ_FOPS_RO_TYPE(osp, uuid); -+LPROC_SEQ_FOPS_RO_TYPE(osp, connect_flags); -+LPROC_SEQ_FOPS_RO_TYPE(osp, server_uuid); -+LPROC_SEQ_FOPS_RO_TYPE(osp, conn_uuid); - -- /* for compatibility reasons */ -- { "destroys_in_flight", osp_rd_destroys_in_flight, 0, 0 }, -- { 0 } --}; -+static int osp_max_pages_per_rpc_seq_show(struct seq_file *m, void *v) -+{ -+ return lprocfs_obd_max_pages_per_rpc_seq_show(m, m->private); -+} -+LPROC_SEQ_FOPS_RO(osp_max_pages_per_rpc); -+LPROC_SEQ_FOPS_RO_TYPE(osp, timeouts); -+ -+LPROC_SEQ_FOPS_RW_TYPE(osp, import); -+LPROC_SEQ_FOPS_RO_TYPE(osp, state); -+ -+static struct lprocfs_seq_vars lprocfs_osp_obd_vars[] = { -+ { .name = "uuid", -+ .fops = &osp_uuid_fops }, -+ { .name = "ping", -+ .fops = &osp_ping_fops, -+ .proc_mode = 0222 }, -+ { .name = "connect_flags", -+ .fops = &osp_connect_flags_fops }, -+ { .name = "ost_server_uuid", -+ .fops = &osp_server_uuid_fops }, -+ { .name = "ost_conn_uuid", -+ .fops = &osp_conn_uuid_fops }, -+ { .name = "active", -+ .fops = &osp_active_fops }, -+ { .name = "max_rpcs_in_flight", -+ .fops = &osp_max_rpcs_in_flight_fops }, -+ { .name = "max_rpcs_in_progress", -+ .fops = &osp_max_rpcs_in_prog_fops }, -+ { .name = "create_count", -+ .fops = &osp_create_count_fops }, -+ { .name = "max_create_count", -+ .fops = &osp_max_create_count_fops }, -+ { .name = "prealloc_next_id", -+ .fops = &osp_prealloc_next_id_fops }, -+ { .name = "prealloc_next_seq", -+ .fops = &osp_prealloc_next_seq_fops }, -+ { .name = "prealloc_last_id", -+ .fops = &osp_prealloc_last_id_fops }, -+ { .name = "prealloc_last_seq", -+ .fops = &osp_prealloc_last_seq_fops }, -+ { .name = "prealloc_reserved", -+ .fops = &osp_prealloc_reserved_fops }, -+ { .name = "timeouts", -+ .fops = &osp_timeouts_fops }, -+ { .name = "import", -+ .fops = &osp_import_fops }, -+ { .name = "state", -+ .fops = &osp_state_fops }, -+ { .name = "maxage", -+ .fops = &osp_maxage_fops }, -+ { .name = "prealloc_status", -+ .fops = &osp_pre_status_fops }, -+ { .name = "sync_changes", -+ .fops = &osp_syn_changes_fops }, -+ { .name = "sync_in_flight", -+ .fops = &osp_syn_in_flight_fops }, -+ { .name = "sync_in_progress", -+ .fops = &osp_syn_in_prog_fops }, -+ { .name = "old_sync_processed", -+ .fops = &osp_old_sync_processed_fops }, - --static struct lprocfs_vars lprocfs_osp_osd_vars[] = { -- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, -- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, -- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, -- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, -- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, -- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, -+ /* for compatibility reasons */ -+ { .name = "destroys_in_flight", -+ .fops = &osp_destroys_in_flight_fops }, - { 0 } - }; - --static struct lprocfs_vars lprocfs_osp_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, -+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_blksize); -+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytestotal); -+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesfree); -+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_kbytesavail); -+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filestotal); -+LPROC_SEQ_FOPS_RO_TYPE(osp, dt_filesfree); -+ -+static struct lprocfs_seq_vars lprocfs_osp_osd_vars[] = { -+ { .name = "blocksize", -+ .fops = &osp_dt_blksize_fops }, -+ { .name = "kbytestotal", -+ .fops = &osp_dt_kbytestotal_fops }, -+ { .name = "kbytesfree", -+ .fops = &osp_dt_kbytesfree_fops }, -+ { .name = "kbytesavail", -+ .fops = &osp_dt_kbytesavail_fops }, -+ { .name = "filestotal", -+ .fops = &osp_dt_filestotal_fops }, -+ { .name = "filesfree", -+ .fops = &osp_dt_filesfree_fops }, - { 0 } - }; - --void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars) --{ -- lvars->module_vars = lprocfs_osp_module_vars; -- lvars->obd_vars = lprocfs_osp_obd_vars; --} -- - void osp_lprocfs_init(struct osp_device *osp) - { - struct obd_device *obd = osp->opd_obd; -- struct proc_dir_entry *osc_proc_dir; -+ struct proc_dir_entry *symlink = NULL; - int rc; - -- obd->obd_proc_entry = lprocfs_register(obd->obd_name, -+ obd->obd_proc_entry = lprocfs_seq_register(obd->obd_name, - obd->obd_type->typ_procroot, - lprocfs_osp_osd_vars, - &osp->opd_dt_dev); -@@ -502,34 +528,29 @@ void osp_lprocfs_init(struct osp_device *osp) - return; - } - -- rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd); -+ rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_osp_obd_vars, obd); - if (rc) { - CERROR("%s: can't register in lprocfs: %ld\n", - obd->obd_name, PTR_ERR(obd->obd_proc_entry)); - return; - } -+ obd->obd_vars = lprocfs_osp_obd_vars; - - ptlrpc_lprocfs_register_obd(obd); - -+ if (osp->opd_connect_mdt || obd->obd_type->typ_procsym == NULL || -+ !strstr(obd->obd_name, "osc")) -+ return; -+ - /* for compatibility we link old procfs's OSC entries to osp ones */ -- if (!osp->opd_connect_mdt) { -- osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc"); -- if (osc_proc_dir) { -- cfs_proc_dir_entry_t *symlink = NULL; -- char *name; -- -- OBD_ALLOC(name, strlen(obd->obd_name) + 1); -- if (name == NULL) -- return; -- -- strcpy(name, obd->obd_name); -- if (strstr(name, "osc")) -- symlink = lprocfs_add_symlink(name, -- osc_proc_dir, "../osp/%s", -- obd->obd_name); -- OBD_FREE(name, strlen(obd->obd_name) + 1); -- osp->opd_symlink = symlink; -- } -+ symlink = lprocfs_add_symlink(obd->obd_name, obd->obd_type->typ_procsym, -+ "../osp/%s", obd->obd_name); -+ if (symlink == NULL) { -+ CERROR("could not register OSC symlink for " -+ "/proc/fs/lustre/osp/%s.", obd->obd_name); -+ lprocfs_remove(&obd->obd_type->typ_procsym); -+ } else { -+ osp->opd_symlink = symlink; - } - } - -diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c -index 9560504..d6ae965 100644 ---- a/lustre/osp/lwp_dev.c -+++ b/lustre/osp/lwp_dev.c -@@ -186,25 +186,13 @@ const struct lu_device_operations lwp_lu_ops = { - .ldo_process_config = lwp_process_config, - }; - --static struct lprocfs_vars lprocfs_lwp_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, -+static struct lprocfs_seq_vars lprocfs_lwp_obd_vars[] = { - { 0 } - }; - --static struct lprocfs_vars lprocfs_lwp_obd_vars[] = { -- { 0 } --}; -- --void lprocfs_lwp_init_vars(struct lprocfs_static_vars *lvars) --{ -- lvars->module_vars = lprocfs_lwp_module_vars; -- lvars->obd_vars = lprocfs_lwp_obd_vars; --} -- - int lwp_init0(const struct lu_env *env, struct lwp_device *lwp, - struct lu_device_type *ldt, struct lustre_cfg *cfg) - { -- struct lprocfs_static_vars lvars = { 0 }; - int rc; - ENTRY; - -@@ -233,8 +221,8 @@ int lwp_init0(const struct lu_env *env, struct lwp_device *lwp, - RETURN(rc); - } - -- lprocfs_lwp_init_vars(&lvars); -- if (lprocfs_obd_setup(lwp->lpd_obd, lvars.obd_vars) == 0) -+ lwp->lpd_obd->obd_vars = lprocfs_lwp_obd_vars; -+ if (lprocfs_seq_obd_setup(lwp->lpd_obd) == 0) - ptlrpc_lprocfs_register_obd(lwp->lpd_obd); - - RETURN(0); -diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c -index 5828d88..7d45fa1 100644 ---- a/lustre/osp/osp_dev.c -+++ b/lustre/osp/osp_dev.c -@@ -371,7 +371,7 @@ static int osp_process_config(const struct lu_env *env, - struct lu_device *dev, struct lustre_cfg *lcfg) - { - struct osp_device *d = lu2osp_dev(dev); -- struct lprocfs_static_vars lvars = { 0 }; -+ struct obd_device *obd = d->opd_obd; - int rc; - - ENTRY; -@@ -385,11 +385,9 @@ static int osp_process_config(const struct lu_env *env, - rc = osp_shutdown(env, d); - break; - case LCFG_PARAM: -- lprocfs_osp_init_vars(&lvars); -- -- LASSERT(d->opd_obd); -- rc = class_process_proc_param(PARAM_OSC, lvars.obd_vars, -- lcfg, d->opd_obd); -+ LASSERT(obd); -+ rc = class_process_proc_seq_param(PARAM_OSC, obd->obd_vars, -+ lcfg, obd); - if (rc > 0) - rc = 0; - if (rc == -ENOSYS) { -@@ -842,6 +840,9 @@ static struct lu_device *osp_device_fini(const struct lu_env *env, - OBD_FREE_PTR(cli->cl_rpc_lock); - cli->cl_rpc_lock = NULL; - } -+ } else { -+ if (m->opd_obd->obd_type->typ_procsym != NULL) -+ lprocfs_remove(&m->opd_obd->obd_type->typ_procsym); - } - - rc = client_obd_cleanup(m->opd_obd); -@@ -1220,33 +1221,26 @@ struct llog_operations osp_mds_ost_orig_logops; - - static int __init osp_mod_init(void) - { -- struct lprocfs_static_vars lvars; -- cfs_proc_dir_entry_t *osc_proc_dir; -- int rc; -+ struct obd_type *type; -+ int rc; - - rc = lu_kmem_init(osp_caches); - if (rc) - return rc; - -- lprocfs_osp_init_vars(&lvars); -- - rc = class_register_type(&osp_obd_device_ops, NULL, NULL, - #ifndef HAVE_ONLY_PROCFS_SEQ -- lvars.module_vars, -+ NULL, - #endif - LUSTRE_OSP_NAME, &osp_device_type); -- -- /* create "osc" entry in procfs for compatibility purposes */ - if (rc != 0) { - lu_kmem_fini(osp_caches); - return rc; - } - -- lprocfs_lwp_init_vars(&lvars); -- - rc = class_register_type(&lwp_obd_device_ops, NULL, NULL, - #ifndef HAVE_ONLY_PROCFS_SEQ -- lvars.module_vars, -+ NULL, - #endif - LUSTRE_LWP_NAME, &lwp_device_type); - if (rc != 0) { -@@ -1260,21 +1254,23 @@ static int __init osp_mod_init(void) - osp_mds_ost_orig_logops.lop_add = llog_cat_add_rec; - osp_mds_ost_orig_logops.lop_declare_add = llog_cat_declare_add_rec; - -- osc_proc_dir = lprocfs_srch(proc_lustre_root, "osc"); -- if (osc_proc_dir == NULL) { -- osc_proc_dir = lprocfs_register("osc", proc_lustre_root, NULL, -- NULL); -- if (IS_ERR(osc_proc_dir)) -- CERROR("osp: can't create compat entry \"osc\": %d\n", -- (int) PTR_ERR(osc_proc_dir)); -+ type = class_search_type(LUSTRE_OSC_NAME); -+ if (type) -+ return rc; -+ -+ type = class_search_type(LUSTRE_OSP_NAME); -+ type->typ_procsym = lprocfs_seq_register("osc", proc_lustre_root, -+ NULL, NULL); -+ if (IS_ERR(type->typ_procsym)) { -+ CERROR("osp: can't create compat entry \"osc\": %d\n", -+ (int) PTR_ERR(type->typ_procsym)); -+ type->typ_procsym = NULL; - } - return rc; - } - - static void __exit osp_mod_exit(void) - { -- lprocfs_try_remove_proc_entry("osc", proc_lustre_root); -- - class_unregister_type(LUSTRE_LWP_NAME); - class_unregister_type(LUSTRE_OSP_NAME); - lu_kmem_fini(osp_caches); -diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h -index 0871d8d..0cc608b 100644 ---- a/lustre/osp/osp_internal.h -+++ b/lustre/osp/osp_internal.h -@@ -433,7 +433,6 @@ int osp_write_last_oid_seq_files(struct lu_env *env, struct osp_device *osp, - int osp_init_pre_fid(struct osp_device *osp); - - /* lproc_osp.c */ --void lprocfs_osp_init_vars(struct lprocfs_static_vars *lvars); - void osp_lprocfs_init(struct osp_device *osp); - - /* osp_sync.c */ -@@ -447,7 +446,6 @@ int osp_sync_fini(struct osp_device *d); - void __osp_sync_check_for_work(struct osp_device *d); - - /* lwp_dev.c */ --void lprocfs_lwp_init_vars(struct lprocfs_static_vars *lvars); - extern struct obd_ops lwp_obd_device_ops; - extern struct lu_device_type lwp_device_type; - --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0007-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch b/sys-cluster/lustre/files/0007-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch deleted file mode 100644 index dad3b481c..000000000 --- a/sys-cluster/lustre/files/0007-LU-3319-procfs-move-lod-proc-handling-to-seq_files.patch +++ /dev/null @@ -1,597 +0,0 @@ -From 82953bddbc3c7b9aa044d9eecc796bc12638f476 Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Sun, 9 Feb 2014 11:08:45 -0500 -Subject: [PATCH 07/13] LU-3319 procfs: move lod proc handling to seq_files - -With 3.10 linux kernel and above proc handling now only -uses struct seq_files. This patch migrates the lod -layer proc entries over to using seq_files. - -Signed-off-by: James Simmons -Change-Id: Iaa0f617fcd430e91f12afbc0faf6906fd275a7a5 ---- - lustre/lod/lod_dev.c | 39 ++++--- - lustre/lod/lod_internal.h | 1 - - lustre/lod/lod_pool.c | 7 +- - lustre/lod/lproc_lod.c | 251 ++++++++++++++++++++++++---------------------- - 4 files changed, 152 insertions(+), 146 deletions(-) - -diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c -index 02a1e1e..b0ad1fd 100644 ---- a/lustre/lod/lod_dev.c -+++ b/lustre/lod/lod_dev.c -@@ -297,12 +297,10 @@ static int lod_process_config(const struct lu_env *env, - } - - case LCFG_PARAM: { -- struct lprocfs_static_vars v = { 0 }; -- struct obd_device *obd = lod2obd(lod); -+ struct obd_device *obd = lod2obd(lod); - -- lprocfs_lod_init_vars(&v); -- -- rc = class_process_proc_param(PARAM_LOV, v.obd_vars, lcfg, obd); -+ rc = class_process_proc_seq_param(PARAM_LOV, obd->obd_vars, -+ lcfg, obd); - if (rc > 0) - rc = 0; - GOTO(out, rc); -@@ -916,19 +914,16 @@ static struct obd_ops lod_obd_device_ops = { - - static int __init lod_mod_init(void) - { -- struct lprocfs_static_vars lvars = { 0 }; -- cfs_proc_dir_entry_t *lov_proc_dir; -- int rc; -+ struct obd_type *lod, *lov; -+ int rc; - - rc = lu_kmem_init(lod_caches); - if (rc) - return rc; - -- lprocfs_lod_init_vars(&lvars); -- - rc = class_register_type(&lod_obd_device_ops, NULL, NULL, - #ifndef HAVE_ONLY_PROCFS_SEQ -- lvars.module_vars, -+ NULL, - #endif - LUSTRE_LOD_NAME, &lod_device_type); - if (rc) { -@@ -937,23 +932,25 @@ static int __init lod_mod_init(void) - } - - /* create "lov" entry in procfs for compatibility purposes */ -- lov_proc_dir = lprocfs_srch(proc_lustre_root, "lov"); -- if (lov_proc_dir == NULL) { -- lov_proc_dir = lprocfs_register("lov", proc_lustre_root, -- NULL, NULL); -- if (IS_ERR(lov_proc_dir)) -+ lod = class_search_type(LUSTRE_LOD_NAME); -+ lov = class_search_type(LUSTRE_LOV_NAME); -+ if (lov == NULL) { -+ lod->typ_procsym = lprocfs_seq_register("lov", proc_lustre_root, -+ NULL, NULL); -+ if (IS_ERR(lod->typ_procsym)) { - CERROR("lod: can't create compat entry \"lov\": %d\n", -- (int)PTR_ERR(lov_proc_dir)); -+ (int)PTR_ERR(lod->typ_procsym)); -+ lod->typ_procsym = NULL; -+ } -+ } else { -+ /* Map lov proc root to lod symlink */ -+ lod->typ_procsym = lov->typ_procroot; - } -- - return rc; - } - - static void __exit lod_mod_exit(void) - { -- -- lprocfs_try_remove_proc_entry("lov", proc_lustre_root); -- - class_unregister_type(LUSTRE_LOD_NAME); - lu_kmem_fini(lod_caches); - } -diff --git a/lustre/lod/lod_internal.h b/lustre/lod/lod_internal.h -index 6d99ad5..9299a91 100644 ---- a/lustre/lod/lod_internal.h -+++ b/lustre/lod/lod_internal.h -@@ -376,7 +376,6 @@ int qos_add_tgt(struct lod_device*, struct lod_tgt_desc *); - int qos_del_tgt(struct lod_device *, struct lod_tgt_desc *); - - /* lproc_lod.c */ --void lprocfs_lod_init_vars(struct lprocfs_static_vars *lvars); - int lod_procfs_init(struct lod_device *lod); - void lod_procfs_fini(struct lod_device *lod); - -diff --git a/lustre/lod/lod_pool.c b/lustre/lod/lod_pool.c -index 98b2416..1849e5d 100644 ---- a/lustre/lod/lod_pool.c -+++ b/lustre/lod/lod_pool.c -@@ -283,7 +283,7 @@ static int pool_proc_open(struct inode *inode, struct file *file) - rc = seq_open(file, &pool_proc_ops); - if (!rc) { - struct seq_file *s = file->private_data; -- s->private = PROC_I(inode)->pde->data; -+ s->private = PDE_DATA(inode); - } - return rc; - } -@@ -462,7 +462,10 @@ int lod_pool_new(struct obd_device *obd, char *poolname) - #ifdef LPROCFS - lod_pool_getref(new_pool); - new_pool->pool_proc_entry = lprocfs_add_simple(lod->lod_pool_proc_entry, -- poolname, NULL, NULL, -+ poolname, -+#ifndef HAVE_ONLY_PROCFS_SEQ -+ NULL, NULL, -+#endif - new_pool, - &pool_proc_operations); - if (IS_ERR(new_pool->pool_proc_entry)) { -diff --git a/lustre/lod/lproc_lod.c b/lustre/lod/lproc_lod.c -index e976063..e420a5e 100644 ---- a/lustre/lod/lproc_lod.c -+++ b/lustre/lod/lproc_lod.c -@@ -42,23 +42,22 @@ - #include - - #ifdef LPROCFS --static int lod_rd_stripesize(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_stripesize_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, LPU64"\n", -+ return seq_printf(m, LPU64"\n", - lod->lod_desc.ld_default_stripe_size); - } - --static int lod_wr_stripesize(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lod_stripesize_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lod_device *lod; - __u64 val; - int rc; -@@ -73,24 +72,24 @@ static int lod_wr_stripesize(struct file *file, const char *buffer, - lod->lod_desc.ld_default_stripe_size = val; - return count; - } -+LPROC_SEQ_FOPS(lod_stripesize); - --static int lod_rd_stripeoffset(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_stripeoffset_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, LPU64"\n", -+ return seq_printf(m, LPU64"\n", - lod->lod_desc.ld_default_stripe_offset); - } - --static int lod_wr_stripeoffset(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lod_stripeoffset_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lod_device *lod; - __u64 val; - int rc; -@@ -104,23 +103,23 @@ static int lod_wr_stripeoffset(struct file *file, const char *buffer, - lod->lod_desc.ld_default_stripe_offset = val; - return count; - } -+LPROC_SEQ_FOPS(lod_stripeoffset); - --static int lod_rd_stripetype(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_stripetype_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, "%u\n", lod->lod_desc.ld_pattern); -+ return seq_printf(m, "%u\n", lod->lod_desc.ld_pattern); - } - --static int lod_wr_stripetype(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lod_stripetype_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lod_device *lod; - int val, rc; - -@@ -134,24 +133,24 @@ static int lod_wr_stripetype(struct file *file, const char *buffer, - lod->lod_desc.ld_pattern = val; - return count; - } -+LPROC_SEQ_FOPS(lod_stripetype); - --static int lod_rd_stripecount(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_stripecount_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, "%d\n", -+ return seq_printf(m, "%d\n", - (__s16)(lod->lod_desc.ld_default_stripe_count + 1) - 1); - } - --static int lod_wr_stripecount(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lod_stripecount_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lod_device *lod; - int val, rc; - -@@ -165,62 +164,57 @@ static int lod_wr_stripecount(struct file *file, const char *buffer, - lod->lod_desc.ld_default_stripe_count = val; - return count; - } -+LPROC_SEQ_FOPS(lod_stripecount); - --static int lod_rd_numobd(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_numobd_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device*)data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, "%u\n", lod->lod_desc.ld_tgt_count); -- -+ return seq_printf(m, "%u\n", lod->lod_desc.ld_tgt_count); - } -+LPROC_SEQ_FOPS_RO(lod_numobd); - --static int lod_rd_activeobd(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_activeobd_seq_show(struct seq_file *m, void *v) - { -- struct obd_device* dev = (struct obd_device*)data; -+ struct obd_device* dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, "%u\n", -- lod->lod_desc.ld_active_tgt_count); -+ return seq_printf(m, "%u\n", lod->lod_desc.ld_active_tgt_count); - } -+LPROC_SEQ_FOPS_RO(lod_activeobd); - --static int lod_rd_desc_uuid(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_desc_uuid_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device*) data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, "%s\n", lod->lod_desc.ld_uuid.uuid); -+ return seq_printf(m, "%s\n", lod->lod_desc.ld_uuid.uuid); - } -+LPROC_SEQ_FOPS_RO(lod_desc_uuid); - - /* free priority (0-255): how badly user wants to choose empty osts */ --static int lod_rd_qos_priofree(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_qos_priofree_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device*) data; -+ struct obd_device *dev = m->private; - struct lod_device *lod = lu2lod_dev(dev->obd_lu_dev); - - LASSERT(lod != NULL); -- *eof = 1; -- return snprintf(page, count, "%d%%\n", -+ return seq_printf(m, "%d%%\n", - (lod->lod_qos.lq_prio_free * 100 + 255) >> 8); - } - --static int lod_wr_qos_priofree(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lod_qos_priofree_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lod_device *lod; - int val, rc; - -@@ -238,24 +232,24 @@ static int lod_wr_qos_priofree(struct file *file, const char *buffer, - lod->lod_qos.lq_reset = 1; - return count; - } -+LPROC_SEQ_FOPS(lod_qos_priofree); - --static int lod_rd_qos_thresholdrr(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int lod_qos_thresholdrr_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device*) data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, "%d%%\n", -+ return seq_printf(m, "%d%%\n", - (lod->lod_qos.lq_threshold_rr * 100 + 255) >> 8); - } - --static int lod_wr_qos_thresholdrr(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lod_qos_thresholdrr_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lod_device *lod; - int val, rc; - -@@ -273,23 +267,23 @@ static int lod_wr_qos_thresholdrr(struct file *file, const char *buffer, - lod->lod_qos.lq_dirty = 1; - return count; - } -+LPROC_SEQ_FOPS(lod_qos_thresholdrr); - --static int lod_rd_qos_maxage(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int lod_qos_maxage_seq_show(struct seq_file *m, void *v) - { -- struct obd_device *dev = (struct obd_device*) data; -+ struct obd_device *dev = m->private; - struct lod_device *lod; - - LASSERT(dev != NULL); - lod = lu2lod_dev(dev->obd_lu_dev); -- *eof = 1; -- return snprintf(page, count, "%u Sec\n", lod->lod_desc.ld_qos_maxage); -+ return seq_printf(m, "%u Sec\n", lod->lod_desc.ld_qos_maxage); - } - --static int lod_wr_qos_maxage(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lod_qos_maxage_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *dev = (struct obd_device *)data; -+ struct obd_device *dev = ((struct seq_file *)file->private_data)->private; - struct lustre_cfg_bufs bufs; - struct lod_device *lod; - struct lu_device *next; -@@ -327,6 +321,7 @@ static int lod_wr_qos_maxage(struct file *file, const char *buffer, - - return count; - } -+LPROC_SEQ_FOPS(lod_qos_maxage); - - static void *lod_osts_seq_start(struct seq_file *p, loff_t *pos) - { -@@ -414,56 +409,63 @@ static const struct seq_operations lod_osts_sops = { - - static int lod_osts_seq_open(struct inode *inode, struct file *file) - { -- struct proc_dir_entry *dp = PDE(inode); - struct seq_file *seq; - int rc; - -- LPROCFS_ENTRY_CHECK(dp); - rc = seq_open(file, &lod_osts_sops); - if (rc) - return rc; - - seq = file->private_data; -- seq->private = dp->data; -+ seq->private = PDE_DATA(inode); - return 0; - } - --static struct lprocfs_vars lprocfs_lod_obd_vars[] = { -- { "uuid", lprocfs_rd_uuid, 0, 0 }, -- { "stripesize", lod_rd_stripesize, lod_wr_stripesize, 0 }, -- { "stripeoffset", lod_rd_stripeoffset, lod_wr_stripeoffset, 0 }, -- { "stripecount", lod_rd_stripecount, lod_wr_stripecount, 0 }, -- { "stripetype", lod_rd_stripetype, lod_wr_stripetype, 0 }, -- { "numobd", lod_rd_numobd, 0, 0 }, -- { "activeobd", lod_rd_activeobd, 0, 0 }, -- { "desc_uuid", lod_rd_desc_uuid, 0, 0 }, -- { "qos_prio_free",lod_rd_qos_priofree, lod_wr_qos_priofree, 0 }, -- { "qos_threshold_rr", lod_rd_qos_thresholdrr, lod_wr_qos_thresholdrr, 0 }, -- { "qos_maxage", lod_rd_qos_maxage, lod_wr_qos_maxage, 0 }, -+LPROC_SEQ_FOPS_RO_TYPE(lod, uuid); -+ -+LPROC_SEQ_FOPS_RO_TYPE(lod, dt_blksize); -+LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytestotal); -+LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytesfree); -+LPROC_SEQ_FOPS_RO_TYPE(lod, dt_kbytesavail); -+LPROC_SEQ_FOPS_RO_TYPE(lod, dt_filestotal); -+LPROC_SEQ_FOPS_RO_TYPE(lod, dt_filesfree); -+ -+static struct lprocfs_seq_vars lprocfs_lod_obd_vars[] = { -+ { .name = "uuid", -+ .fops = &lod_uuid_fops }, -+ { .name = "stripesize", -+ .fops = &lod_stripesize_fops }, -+ { .name = "stripeoffset", -+ .fops = &lod_stripeoffset_fops }, -+ { .name = "stripecount", -+ .fops = &lod_stripecount_fops }, -+ { .name = "stripetype", -+ .fops = &lod_stripetype_fops }, -+ { .name = "numobd", -+ .fops = &lod_numobd_fops }, -+ { .name = "activeobd", -+ .fops = &lod_activeobd_fops }, -+ { .name = "desc_uuid", -+ .fops = &lod_desc_uuid_fops }, -+ { .name = "qos_prio_free", -+ .fops = &lod_qos_priofree_fops }, -+ { .name = "qos_threshold_rr", -+ .fops = &lod_qos_thresholdrr_fops }, -+ { .name = "qos_maxage", -+ .fops = &lod_qos_maxage_fops }, - { 0 } - }; - --static struct lprocfs_vars lprocfs_lod_osd_vars[] = { -- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, -- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, -- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, -- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, -- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, -- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, -+static struct lprocfs_seq_vars lprocfs_lod_osd_vars[] = { -+ { "blocksize", &lod_dt_blksize_fops }, -+ { "kbytestotal", &lod_dt_kbytestotal_fops }, -+ { "kbytesfree", &lod_dt_kbytesfree_fops }, -+ { "kbytesavail", &lod_dt_kbytesavail_fops }, -+ { "filestotal", &lod_dt_filestotal_fops }, -+ { "filesfree", &lod_dt_filesfree_fops }, - { 0 } - }; - --static struct lprocfs_vars lprocfs_lod_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, -- { 0 } --}; -- --void lprocfs_lod_init_vars(struct lprocfs_static_vars *lvars) --{ -- lvars->module_vars = lprocfs_lod_module_vars; -- lvars->obd_vars = lprocfs_lod_obd_vars; --} -- - static const struct file_operations lod_proc_target_fops = { - .owner = THIS_MODULE, - .open = lod_osts_seq_open, -@@ -475,20 +477,18 @@ static const struct file_operations lod_proc_target_fops = { - int lod_procfs_init(struct lod_device *lod) - { - struct obd_device *obd = lod2obd(lod); -- struct lprocfs_static_vars lvars; -- cfs_proc_dir_entry_t *lov_proc_dir; - int rc; - -- lprocfs_lod_init_vars(&lvars); -- rc = lprocfs_obd_setup(obd, lvars.obd_vars); -+ obd->obd_vars = lprocfs_lod_obd_vars; -+ rc = lprocfs_seq_obd_setup(obd); - if (rc) { - CERROR("%s: cannot setup procfs entry: %d\n", - obd->obd_name, rc); - RETURN(rc); - } - -- rc = lprocfs_add_vars(obd->obd_proc_entry, lprocfs_lod_osd_vars, -- &lod->lod_dt_dev); -+ rc = lprocfs_seq_add_vars(obd->obd_proc_entry, lprocfs_lod_osd_vars, -+ &lod->lod_dt_dev); - if (rc) { - CERROR("%s: cannot setup procfs entry: %d\n", - obd->obd_name, rc); -@@ -503,9 +503,9 @@ int lod_procfs_init(struct lod_device *lod) - GOTO(out, rc); - } - -- lod->lod_pool_proc_entry = lprocfs_register("pools", -- obd->obd_proc_entry, -- NULL, NULL); -+ lod->lod_pool_proc_entry = lprocfs_seq_register("pools", -+ obd->obd_proc_entry, -+ NULL, NULL); - if (IS_ERR(lod->lod_pool_proc_entry)) { - rc = PTR_ERR(lod->lod_pool_proc_entry); - lod->lod_pool_proc_entry = NULL; -@@ -514,14 +514,18 @@ int lod_procfs_init(struct lod_device *lod) - GOTO(out, rc); - } - -- /* for compatibility we link old procfs's OSC entries to osp ones */ -- lov_proc_dir = lprocfs_srch(proc_lustre_root, "lov"); -- if (lov_proc_dir != NULL && strstr(obd->obd_name, "lov") != NULL) -+ /* for compatibility we link old procfs's LOV entries to lod ones */ -+ if (obd->obd_type->typ_procsym != NULL) { - lod->lod_symlink = lprocfs_add_symlink(obd->obd_name, -- lov_proc_dir, -- "../lod/%s", -- obd->obd_name); -- -+ obd->obd_type->typ_procsym, -+ "../lod/%s", -+ obd->obd_name); -+ if (lod->lod_symlink == NULL) { -+ CERROR("could not register LOV symlink for " -+ "/proc/fs/lustre/lod/%s.", obd->obd_name); -+ lprocfs_remove(&obd->obd_type->typ_procsym); -+ } -+ } - RETURN(0); - - out: -@@ -542,6 +546,9 @@ void lod_procfs_fini(struct lod_device *lod) - lod->lod_pool_proc_entry = NULL; - } - -+ if (obd->obd_type->typ_procsym != NULL) -+ lprocfs_remove(&obd->obd_type->typ_procsym); -+ - lprocfs_obd_cleanup(obd); - } - --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0007-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch b/sys-cluster/lustre/files/0007-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch new file mode 100644 index 000000000..0e748e6cc --- /dev/null +++ b/sys-cluster/lustre/files/0007-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch @@ -0,0 +1,1941 @@ +From 2790709429e9aaf4b11fca12e3f2e9d70f6608ce Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Fri, 31 Jan 2014 14:00:32 -0500 +Subject: [PATCH 07/12] 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. + +Conflicts: + lustre/mdd/mdd_lproc.c + +Signed-off-by: James Simmons +Change-Id: I61b7df6bfd5efd0f12e3ca1a1813b7b62d493168 +Signed-off-by: Alexey Shvetsov +--- + 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 | 300 ++++++++++++--------------- + 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, 462 insertions(+), 598 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 01d3c60..fb98cf2 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); +@@ -546,10 +545,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 bdcd4c4..1295764 100644 +--- a/lustre/lfsck/lfsck_layout.c ++++ b/lustre/lfsck/lfsck_layout.c +@@ -2249,69 +2249,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" +@@ -2331,11 +2315,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; +@@ -2352,8 +2331,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" +@@ -2367,11 +2345,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); + +@@ -2384,12 +2357,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; +@@ -2399,8 +2367,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" +@@ -2415,18 +2382,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 3eb3a02..b949b8d 100644 +--- a/lustre/lfsck/lfsck_lib.c ++++ b/lustre/lfsck/lfsck_lib.c +@@ -425,77 +425,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, +@@ -1104,7 +1079,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; +@@ -1117,8 +1092,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; +@@ -1158,7 +1132,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; +@@ -1171,8 +1145,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; +@@ -1222,7 +1195,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; +@@ -1238,7 +1211,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 de379b3..5714ee6 100644 +--- a/lustre/mdd/mdd_lproc.c ++++ b/lustre/mdd/mdd_lproc.c +@@ -49,56 +49,14 @@ + #include + #include "mdd_internal.h" + +-int mdd_procfs_init(struct mdd_device *mdd, const char *name) +-{ +- 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) ++static ssize_t ++mdd_atime_diff_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- 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; ++ struct llog_changelog_user_rec *rec; ++ struct seq_file *m = data; + +- LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN); ++ LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN); + +- rec = (struct llog_changelog_user_rec *)hdr; ++ rec = (struct llog_changelog_user_rec *)hdr; + +- 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; +- +- 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,22 +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; ++ struct mdd_device *mdd = m->private; + + LASSERT(mdd != NULL); +- *eof = 1; +- +- return lfsck_get_speed(mdd->mdd_bottom, page, 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; + +@@ -291,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; + +@@ -320,54 +255,77 @@ 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 int lprocfs_rd_lfsck_layout(char *page, char **start, off_t off, +- int count, int *eof, void *data) +-{ +- struct mdd_device *mdd = data; ++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 } ++}; + +- LASSERT(mdd != NULL); +- *eof = 1; ++int mdd_procfs_init(struct mdd_device *mdd, const char *name) ++{ ++ struct obd_device *obd = class_name2obd(name); ++ struct obd_type *type; ++ int rc; ++ ENTRY; + +- return lfsck_dump(mdd->mdd_bottom, page, count, LT_LAYOUT); +-} ++ /* 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); + +-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 }, +- { "lfsck_layout", lprocfs_rd_lfsck_layout, 0, 0 }, +- { 0 } +-}; ++ 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; + +-static struct lprocfs_vars lprocfs_mdd_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, +- { 0 } +-}; ++ EXIT; ++out: ++ if (rc) ++ mdd_procfs_fini(mdd); ++ return rc; ++} + +-void lprocfs_mdd_init_vars(struct lprocfs_static_vars *lvars) ++int mdd_procfs_fini(struct mdd_device *mdd) + { +- lvars->module_vars = lprocfs_mdd_module_vars; +- lvars->obd_vars = lprocfs_mdd_obd_vars; ++ 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 7cd7870..f9cb944 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 6782e5d..1575972 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); +@@ -2364,7 +2359,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); +@@ -2377,11 +2371,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 + diff --git a/sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch b/sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch deleted file mode 100644 index 4019ae50c..000000000 --- a/sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdd-ofd-proc-handling-to-seq_fil.patch +++ /dev/null @@ -1,1941 +0,0 @@ -From 2790709429e9aaf4b11fca12e3f2e9d70f6608ce Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Fri, 31 Jan 2014 14:00:32 -0500 -Subject: [PATCH 08/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. - -Conflicts: - lustre/mdd/mdd_lproc.c - -Signed-off-by: James Simmons -Change-Id: I61b7df6bfd5efd0f12e3ca1a1813b7b62d493168 -Signed-off-by: Alexey Shvetsov ---- - 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 | 300 ++++++++++++--------------- - 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, 462 insertions(+), 598 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 01d3c60..fb98cf2 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); -@@ -546,10 +545,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 bdcd4c4..1295764 100644 ---- a/lustre/lfsck/lfsck_layout.c -+++ b/lustre/lfsck/lfsck_layout.c -@@ -2249,69 +2249,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" -@@ -2331,11 +2315,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; -@@ -2352,8 +2331,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" -@@ -2367,11 +2345,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); - -@@ -2384,12 +2357,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; -@@ -2399,8 +2367,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" -@@ -2415,18 +2382,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 3eb3a02..b949b8d 100644 ---- a/lustre/lfsck/lfsck_lib.c -+++ b/lustre/lfsck/lfsck_lib.c -@@ -425,77 +425,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, -@@ -1104,7 +1079,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; -@@ -1117,8 +1092,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; -@@ -1158,7 +1132,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; -@@ -1171,8 +1145,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; -@@ -1222,7 +1195,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; -@@ -1238,7 +1211,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 de379b3..5714ee6 100644 ---- a/lustre/mdd/mdd_lproc.c -+++ b/lustre/mdd/mdd_lproc.c -@@ -49,56 +49,14 @@ - #include - #include "mdd_internal.h" - --int mdd_procfs_init(struct mdd_device *mdd, const char *name) --{ -- 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) -+static ssize_t -+mdd_atime_diff_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- 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; -+ struct llog_changelog_user_rec *rec; -+ struct seq_file *m = data; - -- LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN); -+ LASSERT(llh->lgh_hdr->llh_flags & LLOG_F_IS_PLAIN); - -- rec = (struct llog_changelog_user_rec *)hdr; -+ rec = (struct llog_changelog_user_rec *)hdr; - -- 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; -- -- 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,22 +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; -+ struct mdd_device *mdd = m->private; - - LASSERT(mdd != NULL); -- *eof = 1; -- -- return lfsck_get_speed(mdd->mdd_bottom, page, 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; - -@@ -291,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; - -@@ -320,54 +255,77 @@ 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 int lprocfs_rd_lfsck_layout(char *page, char **start, off_t off, -- int count, int *eof, void *data) --{ -- struct mdd_device *mdd = data; -+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 } -+}; - -- LASSERT(mdd != NULL); -- *eof = 1; -+int mdd_procfs_init(struct mdd_device *mdd, const char *name) -+{ -+ struct obd_device *obd = class_name2obd(name); -+ struct obd_type *type; -+ int rc; -+ ENTRY; - -- return lfsck_dump(mdd->mdd_bottom, page, count, LT_LAYOUT); --} -+ /* 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); - --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 }, -- { "lfsck_layout", lprocfs_rd_lfsck_layout, 0, 0 }, -- { 0 } --}; -+ 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; - --static struct lprocfs_vars lprocfs_mdd_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, -- { 0 } --}; -+ EXIT; -+out: -+ if (rc) -+ mdd_procfs_fini(mdd); -+ return rc; -+} - --void lprocfs_mdd_init_vars(struct lprocfs_static_vars *lvars) -+int mdd_procfs_fini(struct mdd_device *mdd) - { -- lvars->module_vars = lprocfs_mdd_module_vars; -- lvars->obd_vars = lprocfs_mdd_obd_vars; -+ 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 7cd7870..f9cb944 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 6782e5d..1575972 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); -@@ -2364,7 +2359,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); -@@ -2377,11 +2371,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 - diff --git a/sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch b/sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch new file mode 100644 index 000000000..a6a425b5b --- /dev/null +++ b/sys-cluster/lustre/files/0008-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch @@ -0,0 +1,1553 @@ +From 1013b4b997343de8530c4d4ef5380220d57f155a Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Sun, 9 Feb 2014 11:04:31 -0500 +Subject: [PATCH 08/12] LU-3319 procfs: move mdt/mds proc handling to seq_files + +With 3.10 linux kernel and above proc handling now only +uses struct seq_files. This patch migrates the mdt/mds +layer proc entries over to using seq_files. + +Signed-off-by: James Simmons +Change-Id: Icbafdcd2c2fe3959a51dda3f9c715b0ff8d95742 +--- + lustre/mdt/mdt_coordinator.c | 259 +++++++-------- + lustre/mdt/mdt_handler.c | 16 +- + lustre/mdt/mdt_hsm_cdt_actions.c | 5 +- + lustre/mdt/mdt_hsm_cdt_agent.c | 5 +- + lustre/mdt/mdt_hsm_cdt_requests.c | 5 +- + lustre/mdt/mdt_internal.h | 14 +- + lustre/mdt/mdt_lproc.c | 639 ++++++++++++++++++-------------------- + lustre/mdt/mdt_mds.c | 12 +- + 8 files changed, 442 insertions(+), 513 deletions(-) + +diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c +index 037bcbd..9bbcbd4 100644 +--- a/lustre/mdt/mdt_coordinator.c ++++ b/lustre/mdt/mdt_coordinator.c +@@ -46,7 +46,7 @@ + #include + #include "mdt_internal.h" + +-static struct lprocfs_vars lprocfs_mdt_hsm_vars[]; ++static struct lprocfs_seq_vars lprocfs_mdt_hsm_vars[]; + + /** + * get obj and HSM attributes on a fid +@@ -393,7 +393,7 @@ int hsm_cdt_procfs_init(struct mdt_device *mdt) + ENTRY; + + /* init /proc entries, failure is not critical */ +- cdt->cdt_proc_dir = lprocfs_register("hsm", ++ cdt->cdt_proc_dir = lprocfs_seq_register("hsm", + mdt2obd_dev(mdt)->obd_proc_entry, + lprocfs_mdt_hsm_vars, mdt); + if (IS_ERR(cdt->cdt_proc_dir)) { +@@ -425,7 +425,7 @@ void hsm_cdt_procfs_fini(struct mdt_device *mdt) + * \param none + * \retval var vector + */ +-struct lprocfs_vars *hsm_cdt_get_proc_vars(void) ++struct lprocfs_seq_vars *hsm_cdt_get_proc_vars(void) + { + return lprocfs_mdt_hsm_vars; + } +@@ -1786,22 +1786,17 @@ static __u64 hsm_policy_str2bit(const char *name) + * \param hexa [IN] print mask before bit names + * \param buffer [OUT] string + * \param count [IN] size of buffer +- * \retval size filled in buffer + */ +-static int hsm_policy_bit2str(const __u64 mask, const bool hexa, char *buffer, +- int count) ++static void hsm_policy_bit2str(struct seq_file *m, const __u64 mask, ++ const bool hexa) + { +- int i, j, sz; +- char *ptr; ++ int i, j; + __u64 bit; + ENTRY; + +- ptr = buffer; +- if (hexa) { +- sz = snprintf(buffer, count, "("LPX64") ", mask); +- ptr += sz; +- count -= sz; +- } ++ if (hexa) ++ seq_printf(m, "("LPX64") ", mask); ++ + for (i = 0; i < CDT_POLICY_SHIFT_COUNT; i++) { + bit = (1ULL << i); + +@@ -1810,48 +1805,34 @@ static int hsm_policy_bit2str(const __u64 mask, const bool hexa, char *buffer, + break; + } + if (bit & mask) +- sz = snprintf(ptr, count, "[%s] ", +- hsm_policy_names[j].name); ++ seq_printf(m, "[%s] ", hsm_policy_names[j].name); + else +- sz = snprintf(ptr, count, "%s ", +- hsm_policy_names[j].name); +- +- ptr += sz; +- count -= sz; ++ seq_printf(m, "%s ", hsm_policy_names[j].name); + } +- /* remove last ' ' */ +- *ptr = '\0'; +- ptr--; +- RETURN(ptr - buffer); + } + + /* methods to read/write HSM policy flags */ +-static int lprocfs_rd_hsm_policy(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_hsm_policy_seq_show(struct seq_file *m, void *data) + { +- struct mdt_device *mdt = data; ++ struct mdt_device *mdt = m->private; + struct coordinator *cdt = &mdt->mdt_coordinator; +- int sz; + ENTRY; + +- sz = hsm_policy_bit2str(cdt->cdt_policy, false, page, count); +- page[sz] = '\n'; +- sz++; +- page[sz] = '\0'; +- *eof = 1; +- RETURN(sz); ++ hsm_policy_bit2str(m, cdt->cdt_policy, false); ++ RETURN(0); + } + +-static int lprocfs_wr_hsm_policy(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_hsm_policy_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct mdt_device *mdt = data; ++ struct seq_file *m = file->private_data; ++ struct mdt_device *mdt = m->private; + struct coordinator *cdt = &mdt->mdt_coordinator; + char *start, *token, sign; + char *buf; + __u64 policy; + __u64 add_mask, remove_mask, set_mask; +- int sz; + int rc; + ENTRY; + +@@ -1884,18 +1865,10 @@ static int lprocfs_wr_hsm_policy(struct file *file, const char *buffer, + + policy = hsm_policy_str2bit(token); + if (policy == 0) { +- char *msg; +- +- sz = PAGE_SIZE; +- OBD_ALLOC(msg, sz); +- if (!msg) +- GOTO(out, rc = -ENOMEM); +- +- hsm_policy_bit2str(0, false, msg, sz); + CWARN("%s: '%s' is unknown, " +- "supported policies are: %s\n", mdt_obd_name(mdt), +- token, msg); +- OBD_FREE(msg, sz); ++ "supported policies are: \n", mdt_obd_name(mdt), ++ token); ++ hsm_policy_bit2str(m, 0, false); + GOTO(out, rc = -EINVAL); + } + switch (sign) { +@@ -1934,25 +1907,24 @@ out: + OBD_FREE(buf, count + 1); + RETURN(rc); + } ++LPROC_SEQ_FOPS(mdt_hsm_policy); + + #define GENERATE_PROC_METHOD(VAR) \ +-static int lprocfs_rd_hsm_##VAR(char *page, char **start, off_t off, \ +- int count, int *eof, void *data) \ ++static int mdt_hsm_##VAR##_seq_show(struct seq_file *m, void *data) \ + { \ +- struct mdt_device *mdt = data; \ ++ struct mdt_device *mdt = m->private; \ + struct coordinator *cdt = &mdt->mdt_coordinator; \ +- int sz; \ + ENTRY; \ + \ +- sz = snprintf(page, count, LPU64"\n", (__u64)cdt->VAR); \ +- *eof = 1; \ +- RETURN(sz); \ ++ seq_printf(m, LPU64"\n", (__u64)cdt->VAR); \ ++ RETURN(0); \ + } \ +-static int lprocfs_wr_hsm_##VAR(struct file *file, const char *buffer, \ +- unsigned long count, void *data) \ ++static ssize_t \ ++mdt_hsm_##VAR##_seq_write(struct file *file, const char *buffer, \ ++ size_t count, loff_t *off) \ + \ + { \ +- struct mdt_device *mdt = data; \ ++ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private;\ + struct coordinator *cdt = &mdt->mdt_coordinator; \ + int val; \ + int rc; \ +@@ -1966,7 +1938,7 @@ static int lprocfs_wr_hsm_##VAR(struct file *file, const char *buffer, \ + RETURN(count); \ + } \ + RETURN(-EINVAL); \ +-} ++} \ + + GENERATE_PROC_METHOD(cdt_loop_period) + GENERATE_PROC_METHOD(cdt_grace_delay) +@@ -1984,10 +1956,11 @@ GENERATE_PROC_METHOD(cdt_default_archive_id) + #define CDT_PURGE_CMD "purge" + #define CDT_HELP_CMD "help" + +-int lprocfs_wr_hsm_cdt_control(struct file *file, const char *buffer, +- unsigned long count, void *data) ++ssize_t ++mdt_hsm_cdt_control_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + struct coordinator *cdt = &(mdt->mdt_coordinator); + int rc, usage = 0; +@@ -2041,83 +2014,71 @@ int lprocfs_wr_hsm_cdt_control(struct file *file, const char *buffer, + RETURN(count); + } + +-int lprocfs_rd_hsm_cdt_control(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++int mdt_hsm_cdt_control_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct coordinator *cdt; +- int sz; + ENTRY; + + cdt = &(mdt_dev(obd->obd_lu_dev)->mdt_coordinator); +- *eof = 1; + + if (cdt->cdt_state == CDT_INIT) +- sz = snprintf(page, count, "init\n"); ++ seq_printf(m, "init\n"); + else if (cdt->cdt_state == CDT_RUNNING) +- sz = snprintf(page, count, "enabled\n"); ++ seq_printf(m, "enabled\n"); + else if (cdt->cdt_state == CDT_STOPPING) +- sz = snprintf(page, count, "stopping\n"); ++ seq_printf(m, "stopping\n"); + else if (cdt->cdt_state == CDT_STOPPED) +- sz = snprintf(page, count, "stopped\n"); ++ seq_printf(m, "stopped\n"); + else if (cdt->cdt_state == CDT_DISABLE) +- sz = snprintf(page, count, "disabled\n"); ++ seq_printf(m, "disabled\n"); + else +- sz = snprintf(page, count, "unknown\n"); ++ seq_printf(m, "unknown\n"); + +- RETURN(sz); ++ RETURN(0); + } + + static int +-lprocfs_rd_hsm_request_mask(char *page, char **start, off_t off, +- int count, int *eof, __u64 mask) ++mdt_hsm_request_mask_show(struct seq_file *m, __u64 mask) + { + int i, rc = 0; + ENTRY; + + for (i = 0; i < 8 * sizeof(mask); i++) { + if (mask & (1UL << i)) +- rc += snprintf(page + rc, count - rc, "%s%s", +- rc == 0 ? "" : " ", +- hsm_copytool_action2name(i)); ++ rc += seq_printf(m, "%s%s", rc == 0 ? "" : " ", ++ hsm_copytool_action2name(i)); + } +- +- rc += snprintf(page + rc, count - rc, "\n"); ++ rc += seq_printf(m, "\n"); + + RETURN(rc); + } + + static int +-lprocfs_rd_hsm_user_request_mask(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++mdt_hsm_user_request_mask_seq_show(struct seq_file *m, void *data) + { +- struct mdt_device *mdt = data; ++ struct mdt_device *mdt = m->private; + struct coordinator *cdt = &mdt->mdt_coordinator; + +- return lprocfs_rd_hsm_request_mask(page, start, off, count, eof, +- cdt->cdt_user_request_mask); ++ return mdt_hsm_request_mask_show(m, cdt->cdt_user_request_mask); + } + + static int +-lprocfs_rd_hsm_group_request_mask(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++mdt_hsm_group_request_mask_seq_show(struct seq_file *m, void *data) + { +- struct mdt_device *mdt = data; ++ struct mdt_device *mdt = m->private; + struct coordinator *cdt = &mdt->mdt_coordinator; + +- return lprocfs_rd_hsm_request_mask(page, start, off, count, eof, +- cdt->cdt_group_request_mask); ++ return mdt_hsm_request_mask_show(m, cdt->cdt_group_request_mask); + } + + static int +-lprocfs_rd_hsm_other_request_mask(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++mdt_hsm_other_request_mask_seq_show(struct seq_file *m, void *data) + { +- struct mdt_device *mdt = data; ++ struct mdt_device *mdt = m->private; + struct coordinator *cdt = &mdt->mdt_coordinator; + +- return lprocfs_rd_hsm_request_mask(page, start, off, count, eof, +- cdt->cdt_other_request_mask); ++ return mdt_hsm_request_mask_show(m, cdt->cdt_other_request_mask); + } + + static inline enum hsm_copytool_action +@@ -2137,9 +2098,9 @@ hsm_copytool_name2action(const char *name) + return -1; + } + +-static int +-lprocfs_wr_hsm_request_mask(struct file *file, const char __user *user_buf, +- unsigned long user_count, __u64 *mask) ++static ssize_t ++mdt_write_hsm_request_mask(struct file *file, const char __user *user_buf, ++ size_t user_count, __u64 *mask) + { + char *buf, *pos, *name; + size_t buf_size; +@@ -2183,69 +2144,73 @@ out: + RETURN(rc); + } + +-static int +-lprocfs_wr_hsm_user_request_mask(struct file *file, const char __user *buf, +- unsigned long count, void *data) ++static ssize_t ++mdt_hsm_user_request_mask_seq_write(struct file *file, const char __user *buf, ++ size_t count, loff_t *off) + { +- struct mdt_device *mdt = data; ++ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private; + struct coordinator *cdt = &mdt->mdt_coordinator; + +- return lprocfs_wr_hsm_request_mask(file, buf, count, ++ return mdt_write_hsm_request_mask(file, buf, count, + &cdt->cdt_user_request_mask); + } + +-static int +-lprocfs_wr_hsm_group_request_mask(struct file *file, const char __user *buf, +- unsigned long count, void *data) ++static ssize_t ++mdt_hsm_group_request_mask_seq_write(struct file *file, const char __user *buf, ++ size_t count, loff_t *off) + { +- struct mdt_device *mdt = data; ++ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private; + struct coordinator *cdt = &mdt->mdt_coordinator; + +- return lprocfs_wr_hsm_request_mask(file, buf, count, ++ return mdt_write_hsm_request_mask(file, buf, count, + &cdt->cdt_group_request_mask); + } + +-static int +-lprocfs_wr_hsm_other_request_mask(struct file *file, const char __user *buf, +- unsigned long count, void *data) ++static ssize_t ++mdt_hsm_other_request_mask_seq_write(struct file *file, const char __user *buf, ++ size_t count, loff_t *off) + { +- struct mdt_device *mdt = data; ++ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private; + struct coordinator *cdt = &mdt->mdt_coordinator; + +- return lprocfs_wr_hsm_request_mask(file, buf, count, ++ return mdt_write_hsm_request_mask(file, buf, count, + &cdt->cdt_other_request_mask); + } + +-static struct lprocfs_vars lprocfs_mdt_hsm_vars[] = { +- { "agents", NULL, NULL, NULL, &mdt_hsm_agent_fops, +- 0 }, +- { "actions", NULL, NULL, NULL, &mdt_hsm_actions_fops, +- 0444 }, +- { "default_archive_id", lprocfs_rd_hsm_cdt_default_archive_id, +- lprocfs_wr_hsm_cdt_default_archive_id, +- NULL, NULL, 0 }, +- { "grace_delay", lprocfs_rd_hsm_cdt_grace_delay, +- lprocfs_wr_hsm_cdt_grace_delay, +- NULL, NULL, 0 }, +- { "loop_period", lprocfs_rd_hsm_cdt_loop_period, +- lprocfs_wr_hsm_cdt_loop_period, +- NULL, NULL, 0 }, +- { "max_requests", lprocfs_rd_hsm_cdt_max_requests, +- lprocfs_wr_hsm_cdt_max_requests, +- NULL, NULL, 0 }, +- { "policy", lprocfs_rd_hsm_policy, +- lprocfs_wr_hsm_policy, +- NULL, NULL, 0 }, +- { "active_request_timeout", lprocfs_rd_hsm_cdt_active_req_timeout, +- lprocfs_wr_hsm_cdt_active_req_timeout, +- NULL, NULL, 0 }, +- { "active_requests", NULL, NULL, NULL, +- &mdt_hsm_active_requests_fops, 0 }, +- { "user_request_mask", lprocfs_rd_hsm_user_request_mask, +- lprocfs_wr_hsm_user_request_mask, }, +- { "group_request_mask", lprocfs_rd_hsm_group_request_mask, +- lprocfs_wr_hsm_group_request_mask, }, +- { "other_request_mask", lprocfs_rd_hsm_other_request_mask, +- lprocfs_wr_hsm_other_request_mask, }, ++LPROC_SEQ_FOPS(mdt_hsm_cdt_loop_period); ++LPROC_SEQ_FOPS(mdt_hsm_cdt_grace_delay); ++LPROC_SEQ_FOPS(mdt_hsm_cdt_active_req_timeout); ++LPROC_SEQ_FOPS(mdt_hsm_cdt_max_requests); ++LPROC_SEQ_FOPS(mdt_hsm_cdt_default_archive_id); ++LPROC_SEQ_FOPS(mdt_hsm_user_request_mask); ++LPROC_SEQ_FOPS(mdt_hsm_group_request_mask); ++LPROC_SEQ_FOPS(mdt_hsm_other_request_mask); ++ ++static struct lprocfs_seq_vars lprocfs_mdt_hsm_vars[] = { ++ { .name = "agents", ++ .fops = &mdt_hsm_agent_fops }, ++ { .name = "actions", ++ .fops = &mdt_hsm_actions_fops, ++ .proc_mode = 0444 }, ++ { .name = "default_archive_id", ++ .fops = &mdt_hsm_cdt_default_archive_id_fops }, ++ { .name = "grace_delay", ++ .fops = &mdt_hsm_cdt_grace_delay_fops }, ++ { .name = "loop_period", ++ .fops = &mdt_hsm_cdt_loop_period_fops }, ++ { .name = "max_requests", ++ .fops = &mdt_hsm_cdt_max_requests_fops }, ++ { .name = "policy", ++ .fops = &mdt_hsm_policy_fops }, ++ { .name = "active_request_timeout", ++ .fops = &mdt_hsm_cdt_active_req_timeout_fops }, ++ { .name = "active_requests", ++ .fops = &mdt_hsm_active_requests_fops }, ++ { .name = "user_request_mask", ++ .fops = &mdt_hsm_user_request_mask_fops, }, ++ { .name = "group_request_mask", ++ .fops = &mdt_hsm_group_request_mask_fops, }, ++ { .name = "other_request_mask", ++ .fops = &mdt_hsm_other_request_mask_fops, }, + { 0 } + }; +diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c +index 064fef1..c850356 100644 +--- a/lustre/mdt/mdt_handler.c ++++ b/lustre/mdt/mdt_handler.c +@@ -4539,7 +4539,6 @@ static int mdt_process_config(const struct lu_env *env, + + switch (cfg->lcfg_command) { + case LCFG_PARAM: { +- struct lprocfs_static_vars lvars; + struct obd_device *obd = d->ld_obd; + + /* For interoperability */ +@@ -4574,14 +4573,13 @@ static int mdt_process_config(const struct lu_env *env, + } + } + +- lprocfs_mdt_init_vars(&lvars); +- rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, +- cfg, obd); ++ rc = class_process_proc_seq_param(PARAM_MDT, obd->obd_vars, ++ cfg, obd); + if (rc > 0 || rc == -ENOSYS) { + /* is it an HSM var ? */ +- rc = class_process_proc_param(PARAM_HSM, +- hsm_cdt_get_proc_vars(), +- cfg, obd); ++ rc = class_process_proc_seq_param(PARAM_HSM, ++ hsm_cdt_get_proc_vars(), ++ cfg, obd); + if (rc > 0 || rc == -ENOSYS) + /* we don't understand; pass it on */ + rc = next->ld_ops->ldo_process_config(env, next, +@@ -5762,7 +5760,6 @@ static struct lu_device_type mdt_device_type = { + + static int __init mdt_mod_init(void) + { +- struct lprocfs_static_vars lvars; + int rc; + + CLASSERT(sizeof("0x0123456789ABCDEF:0x01234567:0x01234567") == +@@ -5777,10 +5774,9 @@ static int __init mdt_mod_init(void) + if (rc) + GOTO(lu_fini, rc); + +- lprocfs_mdt_init_vars(&lvars); + rc = class_register_type(&mdt_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lvars.module_vars, ++ NULL, + #endif + LUSTRE_MDT_NAME, &mdt_device_type); + if (rc) +diff --git a/lustre/mdt/mdt_hsm_cdt_actions.c b/lustre/mdt/mdt_hsm_cdt_actions.c +index da7f5a9..49c6b8b 100644 +--- a/lustre/mdt/mdt_hsm_cdt_actions.c ++++ b/lustre/mdt/mdt_hsm_cdt_actions.c +@@ -513,9 +513,6 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file) + struct mdt_device *mdt; + ENTRY; + +- if (LPROCFS_ENTRY_CHECK(PDE(inode))) +- RETURN(-ENOENT); +- + rc = seq_open(file, &mdt_hsm_actions_proc_ops); + if (rc) + RETURN(rc); +@@ -532,7 +529,7 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file) + /* mdt is saved in proc_dir_entry->data by + * mdt_coordinator_procfs_init() calling lprocfs_register() + */ +- mdt = (struct mdt_device *)PDE(inode)->data; ++ mdt = (struct mdt_device *)PDE_DATA(inode); + aai->aai_mdt = mdt; + s = file->private_data; + s->private = aai; +diff --git a/lustre/mdt/mdt_hsm_cdt_agent.c b/lustre/mdt/mdt_hsm_cdt_agent.c +index 9a9ce6d..158cced 100644 +--- a/lustre/mdt/mdt_hsm_cdt_agent.c ++++ b/lustre/mdt/mdt_hsm_cdt_agent.c +@@ -621,15 +621,12 @@ static int lprocfs_open_hsm_agent(struct inode *inode, struct file *file) + int rc; + ENTRY; + +- if (LPROCFS_ENTRY_CHECK(PDE(inode))) +- RETURN(-ENOENT); +- + rc = seq_open(file, &mdt_hsm_agent_proc_ops); + if (rc) + RETURN(rc); + + s = file->private_data; +- s->private = PDE(inode)->data; ++ s->private = PDE_DATA(inode); + + RETURN(rc); + } +diff --git a/lustre/mdt/mdt_hsm_cdt_requests.c b/lustre/mdt/mdt_hsm_cdt_requests.c +index 1300861..3125dcc 100644 +--- a/lustre/mdt/mdt_hsm_cdt_requests.c ++++ b/lustre/mdt/mdt_hsm_cdt_requests.c +@@ -569,15 +569,12 @@ static int lprocfs_open_hsm_active_requests(struct inode *inode, + int rc; + ENTRY; + +- if (LPROCFS_ENTRY_CHECK(PDE(inode))) +- RETURN(-ENOENT); +- + rc = seq_open(file, &mdt_hsm_active_requests_proc_ops); + if (rc) { + RETURN(rc); + } + s = file->private_data; +- s->private = PDE(inode)->data; ++ s->private = PDE_DATA(inode); + + RETURN(rc); + } +diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h +index d548988..e30d78d 100644 +--- a/lustre/mdt/mdt_internal.h ++++ b/lustre/mdt/mdt_internal.h +@@ -784,9 +784,6 @@ void mdt_thread_info_init(struct ptlrpc_request *req, + void mdt_thread_info_fini(struct mdt_thread_info *mti); + struct mdt_thread_info *tsi2mdt_info(struct tgt_session_info *tsi); + +-extern struct lprocfs_vars lprocfs_mds_module_vars[]; +-extern struct lprocfs_vars lprocfs_mds_obd_vars[]; +- + int mdt_hsm_attr_set(struct mdt_thread_info *info, struct mdt_object *obj, + const struct md_hsm *mh); + +@@ -919,13 +916,12 @@ int mdt_hsm_cdt_fini(struct mdt_device *mdt); + int mdt_hsm_cdt_wakeup(struct mdt_device *mdt); + + /* coordinator control /proc interface */ +-int lprocfs_wr_hsm_cdt_control(struct file *file, const char *buffer, +- unsigned long count, void *data); +-int lprocfs_rd_hsm_cdt_control(char *page, char **start, off_t off, +- int count, int *eof, void *data); ++ssize_t mdt_hsm_cdt_control_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off); ++int mdt_hsm_cdt_control_seq_show(struct seq_file *m, void *data); + int hsm_cdt_procfs_init(struct mdt_device *mdt); + void hsm_cdt_procfs_fini(struct mdt_device *mdt); +-struct lprocfs_vars *hsm_cdt_get_proc_vars(void); ++struct lprocfs_seq_vars *hsm_cdt_get_proc_vars(void); + /* md_hsm helpers */ + struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti, + const struct lu_fid *fid, +@@ -1065,8 +1061,6 @@ enum { + }; + void mdt_counter_incr(struct ptlrpc_request *req, int opcode); + void mdt_stats_counter_init(struct lprocfs_stats *stats); +-void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars); +-void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars); + int mdt_procfs_init(struct mdt_device *mdt, const char *name); + void mdt_procfs_fini(struct mdt_device *mdt); + +diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c +index 0ee5148..658f00d 100644 +--- a/lustre/mdt/mdt_lproc.c ++++ b/lustre/mdt/mdt_lproc.c +@@ -156,7 +156,6 @@ static ssize_t mdt_rename_stats_seq_write(struct file *file, const char *buf, + + return len; + } +- + LPROC_SEQ_FOPS(mdt_rename_stats); + + static int lproc_mdt_attach_rename_seqstat(struct mdt_device *mdt) +@@ -213,143 +212,73 @@ void mdt_rename_counter_tally(struct mdt_thread_info *info, + (unsigned int)ma->ma_attr.la_size); + } + +-int mdt_procfs_init(struct mdt_device *mdt, const char *name) ++static int mdt_identity_expire_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = mdt2obd_dev(mdt); +- struct lprocfs_static_vars lvars; +- int rc; +- ENTRY; +- +- LASSERT(name != NULL); +- +- lprocfs_mdt_init_vars(&lvars); +- rc = lprocfs_obd_setup(obd, lvars.obd_vars); +- if (rc) { +- CERROR("%s: cannot create proc entries: rc = %d\n", +- mdt_obd_name(mdt), rc); +- return rc; +- } +- +- rc = hsm_cdt_procfs_init(mdt); +- if (rc) { +- CERROR("%s: cannot create hsm proc entries: rc = %d\n", +- mdt_obd_name(mdt), rc); +- return rc; +- } +- +- obd->obd_proc_exports_entry = proc_mkdir("exports", +- obd->obd_proc_entry); +- if (obd->obd_proc_exports_entry) +- lprocfs_add_simple(obd->obd_proc_exports_entry, +- "clear", lprocfs_nid_stats_clear_read, +- lprocfs_nid_stats_clear_write, obd, NULL); +- rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST); +- if (rc) +- return rc; +- mdt_stats_counter_init(obd->obd_md_stats); +- +- rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST, +- mdt_stats_counter_init); +- +- rc = lproc_mdt_attach_rename_seqstat(mdt); +- if (rc) +- CERROR("%s: MDT can not create rename stats rc = %d\n", +- mdt_obd_name(mdt), rc); +- +- RETURN(rc); +-} +- +-void mdt_procfs_fini(struct mdt_device *mdt) +-{ +- struct obd_device *obd = mdt2obd_dev(mdt); +- +- if (obd->obd_proc_exports_entry != NULL) { +- lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); +- obd->obd_proc_exports_entry = NULL; +- } +- +- lprocfs_free_per_client_stats(obd); +- hsm_cdt_procfs_fini(mdt); +- lprocfs_obd_cleanup(obd); +- lprocfs_free_md_stats(obd); +- lprocfs_free_obd_stats(obd); +- lprocfs_job_stats_fini(obd); +-} +- +-static int lprocfs_rd_identity_expire(char *page, char **start, off_t off, +- int count, int *eof, void *data) +-{ +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- *eof = 1; +- return snprintf(page, count, "%u\n", +- mdt->mdt_identity_cache->uc_entry_expire); ++ return seq_printf(m, "%u\n", mdt->mdt_identity_cache->uc_entry_expire); + } + +-static int lprocfs_wr_identity_expire(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_identity_expire_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- int rc, val; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ int rc, val; + +- rc = lprocfs_write_helper(buffer, count, &val); +- if (rc) +- return rc; ++ rc = lprocfs_write_helper(buffer, count, &val); ++ if (rc) ++ return rc; + +- mdt->mdt_identity_cache->uc_entry_expire = val; +- return count; ++ mdt->mdt_identity_cache->uc_entry_expire = val; ++ return count; + } ++LPROC_SEQ_FOPS(mdt_identity_expire); + +-static int lprocfs_rd_identity_acquire_expire(char *page, char **start, +- off_t off, int count, int *eof, +- void *data) ++static int mdt_identity_acquire_expire_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- *eof = 1; +- return snprintf(page, count, "%u\n", +- mdt->mdt_identity_cache->uc_acquire_expire); ++ return seq_printf(m,"%u\n", mdt->mdt_identity_cache->uc_acquire_expire); + } + +-static int lprocfs_wr_identity_acquire_expire(struct file *file, +- const char *buffer, +- unsigned long count, +- void *data) ++static ssize_t ++mdt_identity_acquire_expire_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- int rc, val; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ int rc, val; + +- rc = lprocfs_write_helper(buffer, count, &val); +- if (rc) +- return rc; ++ rc = lprocfs_write_helper(buffer, count, &val); ++ if (rc) ++ return rc; + +- mdt->mdt_identity_cache->uc_acquire_expire = val; +- return count; ++ mdt->mdt_identity_cache->uc_acquire_expire = val; ++ return count; + } ++LPROC_SEQ_FOPS(mdt_identity_acquire_expire); + +-static int lprocfs_rd_identity_upcall(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_identity_upcall_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- struct upcall_cache *hash = mdt->mdt_identity_cache; +- int len; ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct upcall_cache *hash = mdt->mdt_identity_cache; + +- *eof = 1; + read_lock(&hash->uc_upcall_rwlock); +- len = snprintf(page, count, "%s\n", hash->uc_upcall); ++ seq_printf(m, "%s\n", hash->uc_upcall); + read_unlock(&hash->uc_upcall_rwlock); +- return len; ++ return 0; + } + +-static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_identity_upcall_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + struct upcall_cache *hash = mdt->mdt_identity_cache; + int rc; +@@ -388,11 +317,13 @@ static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer, + OBD_FREE(kernbuf, count + 1); + RETURN(rc); + } ++LPROC_SEQ_FOPS(mdt_identity_upcall); + +-static int lprocfs_wr_identity_flush(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lprocfs_identity_flush_seq_write(struct file *file, const char *buffer, ++ size_t count, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + int rc, uid; + +@@ -403,11 +334,13 @@ static int lprocfs_wr_identity_flush(struct file *file, const char *buffer, + mdt_flush_identity(mdt->mdt_identity_cache, uid); + return count; + } ++LPROC_SEQ_FOPS_WO_TYPE(mdt, identity_flush); + +-static int lprocfs_wr_identity_info(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lprocfs_identity_info_seq_write(struct file *file, const char *buffer, ++ size_t count, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + struct identity_downcall_data *param; + int size = sizeof(*param), rc, checked = 0; +@@ -415,7 +348,7 @@ static int lprocfs_wr_identity_info(struct file *file, const char *buffer, + again: + if (count < size) { + CERROR("%s: invalid data count = %lu, size = %d\n", +- mdt_obd_name(mdt), count, size); ++ mdt_obd_name(mdt), (unsigned long) count, size); + return -EINVAL; + } + +@@ -468,23 +401,24 @@ out: + + return rc ? rc : count; + } ++LPROC_SEQ_FOPS_WO_TYPE(mdt, identity_info); + + /* for debug only */ +-static int lprocfs_rd_capa(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_capa_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "capability on: %s %s\n", ++ return seq_printf(m, "capability on: %s %s\n", + mdt->mdt_lut.lut_oss_capa ? "oss" : "", + mdt->mdt_lut.lut_mds_capa ? "mds" : ""); + } + +-static int lprocfs_wr_capa(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_capa_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + int val, rc; + +@@ -521,64 +455,65 @@ static int lprocfs_wr_capa(struct file *file, const char *buffer, + mdt->mdt_lut.lut_oss_capa ? "enabled" : "disabled"); + return count; + } ++LPROC_SEQ_FOPS(mdt_capa); + +-static int lprocfs_rd_capa_count(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_capa_count_seq_show(struct seq_file *m, void *data) + { +- return snprintf(page, count, "%d %d\n", +- capa_count[CAPA_SITE_CLIENT], +- capa_count[CAPA_SITE_SERVER]); ++ return seq_printf(m, "%d %d\n", capa_count[CAPA_SITE_CLIENT], ++ capa_count[CAPA_SITE_SERVER]); + } ++LPROC_SEQ_FOPS_RO(mdt_capa_count); + +-static int lprocfs_rd_site_stats(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_site_stats_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return lu_site_stats_print(mdt_lu_site(mdt), page, count); ++ return lu_site_stats_seq_print(mdt_lu_site(mdt), m); + } ++LPROC_SEQ_FOPS_RO(mdt_site_stats); + +-static int lprocfs_rd_capa_timeout(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_capa_timeout_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%lu\n", mdt->mdt_capa_timeout); ++ return seq_printf(m, "%lu\n", mdt->mdt_capa_timeout); + } + +-static int lprocfs_wr_capa_timeout(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_capa_timeout_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- int val, rc; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ int val, rc; + +- rc = lprocfs_write_helper(buffer, count, &val); +- if (rc) +- return rc; ++ rc = lprocfs_write_helper(buffer, count, &val); ++ if (rc) ++ return rc; + +- mdt->mdt_capa_timeout = (unsigned long)val; +- mdt->mdt_capa_conf = 1; +- return count; ++ mdt->mdt_capa_timeout = (unsigned long)val; ++ mdt->mdt_capa_conf = 1; ++ return count; + } ++LPROC_SEQ_FOPS(mdt_capa_timeout); + +-static int lprocfs_rd_ck_timeout(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int mdt_ck_timeout_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%lu\n", mdt->mdt_ck_timeout); ++ return seq_printf(m, "%lu\n", mdt->mdt_ck_timeout); + } + +-static int lprocfs_wr_ck_timeout(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_ck_timeout_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- int val, rc; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ int val, rc; + + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) +@@ -588,11 +523,13 @@ static int lprocfs_wr_ck_timeout(struct file *file, const char *buffer, + mdt->mdt_capa_conf = 1; + return count; + } ++LPROC_SEQ_FOPS(mdt_ck_timeout); + + #define BUFLEN (UUID_MAX + 4) + +-static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lprocfs_mds_evict_client_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { + char *kbuf; + char *tmpbuf; +@@ -614,7 +551,7 @@ static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer, + tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count)); + + if (strncmp(tmpbuf, "nid:", 4) != 0) { +- count = lprocfs_wr_evict_client(file, buffer, count, data); ++ count = lprocfs_evict_client_seq_write(file, buffer, count, off); + goto out; + } + +@@ -627,21 +564,21 @@ out: + + #undef BUFLEN + +-static int lprocfs_rd_sec_level(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_sec_level_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%d\n", mdt->mdt_lut.lut_sec_level); ++ return seq_printf(m, "%d\n", mdt->mdt_lut.lut_sec_level); + } + +-static int lprocfs_wr_sec_level(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_sec_level_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- int val, rc; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ int val, rc; + + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) +@@ -659,22 +596,23 @@ static int lprocfs_wr_sec_level(struct file *file, const char *buffer, + mdt->mdt_lut.lut_sec_level = val; + return count; + } ++LPROC_SEQ_FOPS(mdt_sec_level); + +-static int lprocfs_rd_cos(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_cos_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%u\n", mdt_cos_is_enabled(mdt)); ++ return seq_printf(m, "%u\n", mdt_cos_is_enabled(mdt)); + } + +-static int lprocfs_wr_cos(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_cos_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- int val, rc; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ int val, rc; + + rc = lprocfs_write_helper(buffer, count, &val); + if (rc) +@@ -682,15 +620,15 @@ static int lprocfs_wr_cos(struct file *file, const char *buffer, + mdt_enable_cos(mdt, val); + return count; + } ++LPROC_SEQ_FOPS(mdt_cos); + +-static int lprocfs_rd_root_squash(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_root_squash_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%u:%u\n", mdt->mdt_squash_uid, +- mdt->mdt_squash_gid); ++ return seq_printf(m, "%u:%u\n", mdt->mdt_squash_uid, ++ mdt->mdt_squash_gid); + } + + static int safe_strtoul(const char *str, char **endp, unsigned long *res) +@@ -708,10 +646,11 @@ static int safe_strtoul(const char *str, char **endp, unsigned long *res) + return 0; + } + +-static int lprocfs_wr_root_squash(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_root_squash_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + int rc; + char kernbuf[50], *tmp, *end, *errmsg; +@@ -765,22 +704,23 @@ failed: + mdt_obd_name(mdt), buffer, errmsg, rc); + RETURN(rc); + } ++LPROC_SEQ_FOPS(mdt_root_squash); + +-static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_nosquash_nids_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- if (mdt->mdt_nosquash_str) +- return snprintf(page, count, "%s\n", mdt->mdt_nosquash_str); +- return snprintf(page, count, "NONE\n"); ++ if (mdt->mdt_nosquash_str) ++ return seq_printf(m, "%s\n", mdt->mdt_nosquash_str); ++ return seq_printf(m, "NONE\n"); + } + +-static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_nosquash_nids_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + int rc; + char *kernbuf, *errmsg; +@@ -842,25 +782,26 @@ failed: + OBD_FREE(kernbuf, count + 1); + RETURN(rc); + } ++LPROC_SEQ_FOPS(mdt_nosquash_nids); + +-static int lprocfs_rd_mdt_som(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_som_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_device *obd = m->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%sabled\n", +- mdt->mdt_som_conf ? "en" : "dis"); ++ return seq_printf(m, "%sabled\n", ++ mdt->mdt_som_conf ? "en" : "dis"); + } + +-static int lprocfs_wr_mdt_som(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_som_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_export *exp; +- struct obd_device *obd = data; +- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); +- char kernbuf[16]; +- unsigned long val = 0; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; ++ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); ++ struct obd_export *exp; ++ char kernbuf[16]; ++ unsigned long val = 0; + + if (count > (sizeof(kernbuf) - 1)) + return -EINVAL; +@@ -902,20 +843,21 @@ static int lprocfs_wr_mdt_som(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(mdt_som); + +-static int lprocfs_rd_enable_remote_dir(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_enable_remote_dir_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%u\n", mdt->mdt_enable_remote_dir); ++ return seq_printf(m, "%u\n", mdt->mdt_enable_remote_dir); + } + +-static int lprocfs_wr_enable_remote_dir(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_enable_remote_dir_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + __u32 val; + int rc; +@@ -930,22 +872,22 @@ static int lprocfs_wr_enable_remote_dir(struct file *file, const char *buffer, + mdt->mdt_enable_remote_dir = val; + return count; + } ++LPROC_SEQ_FOPS(mdt_enable_remote_dir); + +-static int lprocfs_rd_enable_remote_dir_gid(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int mdt_enable_remote_dir_gid_seq_show(struct seq_file *m, void *data) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = m->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + +- return snprintf(page, count, "%d\n", +- (int)mdt->mdt_enable_remote_dir_gid); ++ return seq_printf(m, "%d\n", ++ (int)mdt->mdt_enable_remote_dir_gid); + } + +-static int lprocfs_wr_enable_remote_dir_gid(struct file *file, +- const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++mdt_enable_remote_dir_gid_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct obd_device *obd = data; ++ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; + struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + __u32 val; + int rc; +@@ -957,97 +899,72 @@ static int lprocfs_wr_enable_remote_dir_gid(struct file *file, + mdt->mdt_enable_remote_dir_gid = val; + return count; + } +- +-static struct lprocfs_vars lprocfs_mdt_obd_vars[] = { +- { "uuid", lprocfs_rd_uuid, NULL, +- NULL, NULL, 0 }, +- { "recovery_status", lprocfs_obd_rd_recovery_status, NULL, +- NULL, NULL, 0 }, +- { "num_exports", lprocfs_rd_num_exports, NULL, +- NULL, NULL, 0 }, +- { "identity_expire", lprocfs_rd_identity_expire, +- lprocfs_wr_identity_expire, +- NULL, NULL, 0 }, +- { "identity_acquire_expire", lprocfs_rd_identity_acquire_expire, +- lprocfs_wr_identity_acquire_expire, +- NULL, NULL, 0 }, +- { "identity_upcall", lprocfs_rd_identity_upcall, +- lprocfs_wr_identity_upcall, +- NULL, NULL, 0 }, +- { "identity_flush", NULL, lprocfs_wr_identity_flush, +- NULL, NULL, 0 }, +- { "identity_info", NULL, lprocfs_wr_identity_info, +- NULL, NULL, 0 }, +- { "capa", lprocfs_rd_capa, +- lprocfs_wr_capa, +- NULL, NULL, 0 }, +- { "capa_timeout", lprocfs_rd_capa_timeout, +- lprocfs_wr_capa_timeout, +- NULL, NULL, 0 }, +- { "capa_key_timeout", lprocfs_rd_ck_timeout, +- lprocfs_wr_ck_timeout, +- NULL, NULL, 0 }, +- { "capa_count", lprocfs_rd_capa_count, NULL, +- NULL, NULL, 0 }, +- { "site_stats", lprocfs_rd_site_stats, NULL, +- NULL, NULL, 0 }, +- { "evict_client", NULL, lprocfs_mdt_wr_evict_client, +- NULL, NULL, 0 }, +- { "hash_stats", lprocfs_obd_rd_hash, NULL, +- NULL, NULL, 0 }, +- { "sec_level", lprocfs_rd_sec_level, +- lprocfs_wr_sec_level, +- NULL, NULL, 0 }, +- { "commit_on_sharing", lprocfs_rd_cos, lprocfs_wr_cos, +- NULL, NULL, 0 }, +- { "root_squash", lprocfs_rd_root_squash, +- lprocfs_wr_root_squash, +- NULL, NULL, 0 }, +- { "nosquash_nids", lprocfs_rd_nosquash_nids, +- lprocfs_wr_nosquash_nids, +- NULL, NULL, 0 }, +- { "som", lprocfs_rd_mdt_som, +- lprocfs_wr_mdt_som, +- NULL, NULL, 0 }, +- { "instance", lprocfs_target_rd_instance, NULL, +- NULL, NULL, 0}, +- { "ir_factor", lprocfs_obd_rd_ir_factor, +- lprocfs_obd_wr_ir_factor, +- NULL, NULL, 0 }, +- { "job_cleanup_interval", lprocfs_rd_job_interval, +- lprocfs_wr_job_interval, +- NULL, NULL, 0 }, +- { "enable_remote_dir", lprocfs_rd_enable_remote_dir, +- lprocfs_wr_enable_remote_dir, +- NULL, NULL, 0}, +- { "enable_remote_dir_gid", lprocfs_rd_enable_remote_dir_gid, +- lprocfs_wr_enable_remote_dir_gid, +- NULL, NULL, 0}, +- { "hsm_control", lprocfs_rd_hsm_cdt_control, +- lprocfs_wr_hsm_cdt_control, +- NULL, NULL, 0 }, +- { 0 } +-}; +- +-static struct lprocfs_vars lprocfs_mdt_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, NULL, +- NULL, NULL, 0 }, +- { 0 } +-}; +- +-void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars) +-{ +- lvars->module_vars = lprocfs_mdt_module_vars; +- lvars->obd_vars = lprocfs_mdt_obd_vars; +-} +- +-struct lprocfs_vars lprocfs_mds_obd_vars[] = { +- { "uuid", lprocfs_rd_uuid, NULL, NULL, NULL, 0 }, +- { 0 } +-}; +- +-struct lprocfs_vars lprocfs_mds_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, NULL, NULL, NULL, 0 }, ++LPROC_SEQ_FOPS(mdt_enable_remote_dir_gid); ++ ++LPROC_SEQ_FOPS_RO_TYPE(mdt, uuid); ++LPROC_SEQ_FOPS_RO_TYPE(mdt, recovery_status); ++LPROC_SEQ_FOPS_RO_TYPE(mdt, num_exports); ++LPROC_SEQ_FOPS_RO_TYPE(mdt, target_instance); ++LPROC_SEQ_FOPS_RO_TYPE(mdt, hash); ++LPROC_SEQ_FOPS_WO_TYPE(mdt, mds_evict_client); ++LPROC_SEQ_FOPS_RW_TYPE(mdt, job_interval); ++LPROC_SEQ_FOPS_RW_TYPE(mdt, ir_factor); ++LPROC_SEQ_FOPS_RW_TYPE(mdt, nid_stats_clear); ++LPROC_SEQ_FOPS(mdt_hsm_cdt_control); ++ ++static struct lprocfs_seq_vars lprocfs_mdt_obd_vars[] = { ++ { .name = "uuid", ++ .fops = &mdt_uuid_fops }, ++ { .name = "recovery_status", ++ .fops = &mdt_recovery_status_fops }, ++ { .name = "num_exports", ++ .fops = &mdt_num_exports_fops }, ++ { .name = "identity_expire", ++ .fops = &mdt_identity_expire_fops }, ++ { .name = "identity_acquire_expire", ++ .fops = &mdt_identity_acquire_expire_fops }, ++ { .name = "identity_upcall", ++ .fops = &mdt_identity_upcall_fops }, ++ { .name = "identity_flush", ++ .fops = &mdt_identity_flush_fops }, ++ { .name = "identity_info", ++ .fops = &mdt_identity_info_fops }, ++ { .name = "capa", ++ .fops = &mdt_capa_fops }, ++ { .name = "capa_timeout", ++ .fops = &mdt_capa_timeout_fops }, ++ { .name = "capa_key_timeout", ++ .fops = &mdt_ck_timeout_fops }, ++ { .name = "capa_count", ++ .fops = &mdt_capa_count_fops }, ++ { .name = "site_stats", ++ .fops = &mdt_site_stats_fops }, ++ { .name = "evict_client", ++ .fops = &mdt_mds_evict_client_fops }, ++ { .name = "hash_stats", ++ .fops = &mdt_hash_fops }, ++ { .name = "sec_level", ++ .fops = &mdt_sec_level_fops }, ++ { .name = "commit_on_sharing", ++ .fops = &mdt_cos_fops }, ++ { .name = "root_squash", ++ .fops = &mdt_root_squash_fops }, ++ { .name = "nosquash_nids", ++ .fops = &mdt_nosquash_nids_fops }, ++ { .name = "som", ++ .fops = &mdt_som_fops }, ++ { .name = "instance", ++ .fops = &mdt_target_instance_fops }, ++ { .name = "ir_factor", ++ .fops = &mdt_ir_factor_fops }, ++ { .name = "job_cleanup_interval", ++ .fops = &mdt_job_interval_fops }, ++ { .name = "enable_remote_dir", ++ .fops = &mdt_enable_remote_dir_fops }, ++ { .name = "enable_remote_dir_gid", ++ .fops = &mdt_enable_remote_dir_gid_fops }, ++ { .name = "hsm_control", ++ .fops = &mdt_hsm_cdt_control_fops }, + { 0 } + }; + +@@ -1085,21 +1002,15 @@ int lprocfs_mdt_open_files_seq_show(struct seq_file *seq, void *v) + + int lprocfs_mdt_open_files_seq_open(struct inode *inode, struct file *file) + { +- struct proc_dir_entry *dp = PDE(inode); + struct seq_file *seq; +- struct nid_stat *tmp; + int rc; + +- if (LPROCFS_ENTRY_CHECK(dp)) +- return -ENOENT; +- +- tmp = dp->data; + rc = single_open(file, &lprocfs_mdt_open_files_seq_show, NULL); + if (rc != 0) + return rc; + + seq = file->private_data; +- seq->private = tmp; ++ seq->private = PDE_DATA(inode); + + return 0; + } +@@ -1140,3 +1051,67 @@ void mdt_stats_counter_init(struct lprocfs_stats *stats) + lprocfs_counter_init(stats, LPROC_MDT_CROSSDIR_RENAME, 0, + "crossdir_rename", "reqs"); + } ++ ++int mdt_procfs_init(struct mdt_device *mdt, const char *name) ++{ ++ struct obd_device *obd = mdt2obd_dev(mdt); ++ int rc; ++ ENTRY; ++ ++ LASSERT(name != NULL); ++ ++ obd->obd_vars = lprocfs_mdt_obd_vars; ++ rc = lprocfs_seq_obd_setup(obd); ++ if (rc) { ++ CERROR("%s: cannot create proc entries: rc = %d\n", ++ mdt_obd_name(mdt), rc); ++ return rc; ++ } ++ ++ rc = hsm_cdt_procfs_init(mdt); ++ if (rc) { ++ CERROR("%s: cannot create hsm proc entries: rc = %d\n", ++ mdt_obd_name(mdt), rc); ++ return rc; ++ } ++ ++ obd->obd_proc_exports_entry = proc_mkdir("exports", ++ obd->obd_proc_entry); ++ if (obd->obd_proc_exports_entry) ++ lprocfs_add_simple(obd->obd_proc_exports_entry, "clear", ++#ifndef HAVE_ONLY_PROCFS_SEQ ++ NULL, NULL, ++#endif ++ obd, &mdt_nid_stats_clear_fops); ++ rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST); ++ if (rc) ++ return rc; ++ mdt_stats_counter_init(obd->obd_md_stats); ++ ++ rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST, ++ mdt_stats_counter_init); ++ ++ rc = lproc_mdt_attach_rename_seqstat(mdt); ++ if (rc) ++ CERROR("%s: MDT can not create rename stats rc = %d\n", ++ mdt_obd_name(mdt), rc); ++ ++ RETURN(rc); ++} ++ ++void mdt_procfs_fini(struct mdt_device *mdt) ++{ ++ struct obd_device *obd = mdt2obd_dev(mdt); ++ ++ if (obd->obd_proc_exports_entry != NULL) { ++ lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); ++ obd->obd_proc_exports_entry = NULL; ++ } ++ ++ lprocfs_free_per_client_stats(obd); ++ hsm_cdt_procfs_fini(mdt); ++ lprocfs_obd_cleanup(obd); ++ lprocfs_free_md_stats(obd); ++ lprocfs_free_obd_stats(obd); ++ lprocfs_job_stats_fini(obd); ++} +diff --git a/lustre/mdt/mdt_mds.c b/lustre/mdt/mdt_mds.c +index 367f659..4fa66c3 100644 +--- a/lustre/mdt/mdt_mds.c ++++ b/lustre/mdt/mdt_mds.c +@@ -464,6 +464,13 @@ static struct lu_device *mds_device_free(const struct lu_env *env, + RETURN(NULL); + } + ++LPROC_SEQ_FOPS_RO_TYPE(mds, uuid); ++ ++static struct lprocfs_seq_vars lprocfs_mds_obd_vars[] = { ++ { "uuid", &mds_uuid_fops }, ++ { 0 } ++}; ++ + static struct lu_device *mds_device_alloc(const struct lu_env *env, + struct lu_device_type *t, + struct lustre_cfg *cfg) +@@ -487,7 +494,8 @@ static struct lu_device *mds_device_alloc(const struct lu_env *env, + /* set this lu_device to obd, because error handling need it */ + obd->obd_lu_dev = l; + +- rc = lprocfs_obd_setup(obd, lprocfs_mds_obd_vars); ++ obd->obd_vars = lprocfs_mds_obd_vars; ++ rc = lprocfs_seq_obd_setup(obd); + if (rc != 0) { + mds_device_free(env, l); + l = ERR_PTR(rc); +@@ -541,7 +549,7 @@ int mds_mod_init(void) + + return class_register_type(&mds_obd_device_ops, NULL, NULL, + #ifndef HAVE_ONLY_PROCFS_SEQ +- lprocfs_mds_module_vars, ++ NULL, + #endif + LUSTRE_MDS_NAME, &mds_device_type); + } +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch b/sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch deleted file mode 100644 index febec325b..000000000 --- a/sys-cluster/lustre/files/0009-LU-3319-procfs-move-mdt-mds-proc-handling-to-seq_fil.patch +++ /dev/null @@ -1,1553 +0,0 @@ -From 1013b4b997343de8530c4d4ef5380220d57f155a Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Sun, 9 Feb 2014 11:04:31 -0500 -Subject: [PATCH 09/13] LU-3319 procfs: move mdt/mds proc handling to seq_files - -With 3.10 linux kernel and above proc handling now only -uses struct seq_files. This patch migrates the mdt/mds -layer proc entries over to using seq_files. - -Signed-off-by: James Simmons -Change-Id: Icbafdcd2c2fe3959a51dda3f9c715b0ff8d95742 ---- - lustre/mdt/mdt_coordinator.c | 259 +++++++-------- - lustre/mdt/mdt_handler.c | 16 +- - lustre/mdt/mdt_hsm_cdt_actions.c | 5 +- - lustre/mdt/mdt_hsm_cdt_agent.c | 5 +- - lustre/mdt/mdt_hsm_cdt_requests.c | 5 +- - lustre/mdt/mdt_internal.h | 14 +- - lustre/mdt/mdt_lproc.c | 639 ++++++++++++++++++-------------------- - lustre/mdt/mdt_mds.c | 12 +- - 8 files changed, 442 insertions(+), 513 deletions(-) - -diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c -index 037bcbd..9bbcbd4 100644 ---- a/lustre/mdt/mdt_coordinator.c -+++ b/lustre/mdt/mdt_coordinator.c -@@ -46,7 +46,7 @@ - #include - #include "mdt_internal.h" - --static struct lprocfs_vars lprocfs_mdt_hsm_vars[]; -+static struct lprocfs_seq_vars lprocfs_mdt_hsm_vars[]; - - /** - * get obj and HSM attributes on a fid -@@ -393,7 +393,7 @@ int hsm_cdt_procfs_init(struct mdt_device *mdt) - ENTRY; - - /* init /proc entries, failure is not critical */ -- cdt->cdt_proc_dir = lprocfs_register("hsm", -+ cdt->cdt_proc_dir = lprocfs_seq_register("hsm", - mdt2obd_dev(mdt)->obd_proc_entry, - lprocfs_mdt_hsm_vars, mdt); - if (IS_ERR(cdt->cdt_proc_dir)) { -@@ -425,7 +425,7 @@ void hsm_cdt_procfs_fini(struct mdt_device *mdt) - * \param none - * \retval var vector - */ --struct lprocfs_vars *hsm_cdt_get_proc_vars(void) -+struct lprocfs_seq_vars *hsm_cdt_get_proc_vars(void) - { - return lprocfs_mdt_hsm_vars; - } -@@ -1786,22 +1786,17 @@ static __u64 hsm_policy_str2bit(const char *name) - * \param hexa [IN] print mask before bit names - * \param buffer [OUT] string - * \param count [IN] size of buffer -- * \retval size filled in buffer - */ --static int hsm_policy_bit2str(const __u64 mask, const bool hexa, char *buffer, -- int count) -+static void hsm_policy_bit2str(struct seq_file *m, const __u64 mask, -+ const bool hexa) - { -- int i, j, sz; -- char *ptr; -+ int i, j; - __u64 bit; - ENTRY; - -- ptr = buffer; -- if (hexa) { -- sz = snprintf(buffer, count, "("LPX64") ", mask); -- ptr += sz; -- count -= sz; -- } -+ if (hexa) -+ seq_printf(m, "("LPX64") ", mask); -+ - for (i = 0; i < CDT_POLICY_SHIFT_COUNT; i++) { - bit = (1ULL << i); - -@@ -1810,48 +1805,34 @@ static int hsm_policy_bit2str(const __u64 mask, const bool hexa, char *buffer, - break; - } - if (bit & mask) -- sz = snprintf(ptr, count, "[%s] ", -- hsm_policy_names[j].name); -+ seq_printf(m, "[%s] ", hsm_policy_names[j].name); - else -- sz = snprintf(ptr, count, "%s ", -- hsm_policy_names[j].name); -- -- ptr += sz; -- count -= sz; -+ seq_printf(m, "%s ", hsm_policy_names[j].name); - } -- /* remove last ' ' */ -- *ptr = '\0'; -- ptr--; -- RETURN(ptr - buffer); - } - - /* methods to read/write HSM policy flags */ --static int lprocfs_rd_hsm_policy(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_hsm_policy_seq_show(struct seq_file *m, void *data) - { -- struct mdt_device *mdt = data; -+ struct mdt_device *mdt = m->private; - struct coordinator *cdt = &mdt->mdt_coordinator; -- int sz; - ENTRY; - -- sz = hsm_policy_bit2str(cdt->cdt_policy, false, page, count); -- page[sz] = '\n'; -- sz++; -- page[sz] = '\0'; -- *eof = 1; -- RETURN(sz); -+ hsm_policy_bit2str(m, cdt->cdt_policy, false); -+ RETURN(0); - } - --static int lprocfs_wr_hsm_policy(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_hsm_policy_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct mdt_device *mdt = data; -+ struct seq_file *m = file->private_data; -+ struct mdt_device *mdt = m->private; - struct coordinator *cdt = &mdt->mdt_coordinator; - char *start, *token, sign; - char *buf; - __u64 policy; - __u64 add_mask, remove_mask, set_mask; -- int sz; - int rc; - ENTRY; - -@@ -1884,18 +1865,10 @@ static int lprocfs_wr_hsm_policy(struct file *file, const char *buffer, - - policy = hsm_policy_str2bit(token); - if (policy == 0) { -- char *msg; -- -- sz = PAGE_SIZE; -- OBD_ALLOC(msg, sz); -- if (!msg) -- GOTO(out, rc = -ENOMEM); -- -- hsm_policy_bit2str(0, false, msg, sz); - CWARN("%s: '%s' is unknown, " -- "supported policies are: %s\n", mdt_obd_name(mdt), -- token, msg); -- OBD_FREE(msg, sz); -+ "supported policies are: \n", mdt_obd_name(mdt), -+ token); -+ hsm_policy_bit2str(m, 0, false); - GOTO(out, rc = -EINVAL); - } - switch (sign) { -@@ -1934,25 +1907,24 @@ out: - OBD_FREE(buf, count + 1); - RETURN(rc); - } -+LPROC_SEQ_FOPS(mdt_hsm_policy); - - #define GENERATE_PROC_METHOD(VAR) \ --static int lprocfs_rd_hsm_##VAR(char *page, char **start, off_t off, \ -- int count, int *eof, void *data) \ -+static int mdt_hsm_##VAR##_seq_show(struct seq_file *m, void *data) \ - { \ -- struct mdt_device *mdt = data; \ -+ struct mdt_device *mdt = m->private; \ - struct coordinator *cdt = &mdt->mdt_coordinator; \ -- int sz; \ - ENTRY; \ - \ -- sz = snprintf(page, count, LPU64"\n", (__u64)cdt->VAR); \ -- *eof = 1; \ -- RETURN(sz); \ -+ seq_printf(m, LPU64"\n", (__u64)cdt->VAR); \ -+ RETURN(0); \ - } \ --static int lprocfs_wr_hsm_##VAR(struct file *file, const char *buffer, \ -- unsigned long count, void *data) \ -+static ssize_t \ -+mdt_hsm_##VAR##_seq_write(struct file *file, const char *buffer, \ -+ size_t count, loff_t *off) \ - \ - { \ -- struct mdt_device *mdt = data; \ -+ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private;\ - struct coordinator *cdt = &mdt->mdt_coordinator; \ - int val; \ - int rc; \ -@@ -1966,7 +1938,7 @@ static int lprocfs_wr_hsm_##VAR(struct file *file, const char *buffer, \ - RETURN(count); \ - } \ - RETURN(-EINVAL); \ --} -+} \ - - GENERATE_PROC_METHOD(cdt_loop_period) - GENERATE_PROC_METHOD(cdt_grace_delay) -@@ -1984,10 +1956,11 @@ GENERATE_PROC_METHOD(cdt_default_archive_id) - #define CDT_PURGE_CMD "purge" - #define CDT_HELP_CMD "help" - --int lprocfs_wr_hsm_cdt_control(struct file *file, const char *buffer, -- unsigned long count, void *data) -+ssize_t -+mdt_hsm_cdt_control_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - struct coordinator *cdt = &(mdt->mdt_coordinator); - int rc, usage = 0; -@@ -2041,83 +2014,71 @@ int lprocfs_wr_hsm_cdt_control(struct file *file, const char *buffer, - RETURN(count); - } - --int lprocfs_rd_hsm_cdt_control(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+int mdt_hsm_cdt_control_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct coordinator *cdt; -- int sz; - ENTRY; - - cdt = &(mdt_dev(obd->obd_lu_dev)->mdt_coordinator); -- *eof = 1; - - if (cdt->cdt_state == CDT_INIT) -- sz = snprintf(page, count, "init\n"); -+ seq_printf(m, "init\n"); - else if (cdt->cdt_state == CDT_RUNNING) -- sz = snprintf(page, count, "enabled\n"); -+ seq_printf(m, "enabled\n"); - else if (cdt->cdt_state == CDT_STOPPING) -- sz = snprintf(page, count, "stopping\n"); -+ seq_printf(m, "stopping\n"); - else if (cdt->cdt_state == CDT_STOPPED) -- sz = snprintf(page, count, "stopped\n"); -+ seq_printf(m, "stopped\n"); - else if (cdt->cdt_state == CDT_DISABLE) -- sz = snprintf(page, count, "disabled\n"); -+ seq_printf(m, "disabled\n"); - else -- sz = snprintf(page, count, "unknown\n"); -+ seq_printf(m, "unknown\n"); - -- RETURN(sz); -+ RETURN(0); - } - - static int --lprocfs_rd_hsm_request_mask(char *page, char **start, off_t off, -- int count, int *eof, __u64 mask) -+mdt_hsm_request_mask_show(struct seq_file *m, __u64 mask) - { - int i, rc = 0; - ENTRY; - - for (i = 0; i < 8 * sizeof(mask); i++) { - if (mask & (1UL << i)) -- rc += snprintf(page + rc, count - rc, "%s%s", -- rc == 0 ? "" : " ", -- hsm_copytool_action2name(i)); -+ rc += seq_printf(m, "%s%s", rc == 0 ? "" : " ", -+ hsm_copytool_action2name(i)); - } -- -- rc += snprintf(page + rc, count - rc, "\n"); -+ rc += seq_printf(m, "\n"); - - RETURN(rc); - } - - static int --lprocfs_rd_hsm_user_request_mask(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+mdt_hsm_user_request_mask_seq_show(struct seq_file *m, void *data) - { -- struct mdt_device *mdt = data; -+ struct mdt_device *mdt = m->private; - struct coordinator *cdt = &mdt->mdt_coordinator; - -- return lprocfs_rd_hsm_request_mask(page, start, off, count, eof, -- cdt->cdt_user_request_mask); -+ return mdt_hsm_request_mask_show(m, cdt->cdt_user_request_mask); - } - - static int --lprocfs_rd_hsm_group_request_mask(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+mdt_hsm_group_request_mask_seq_show(struct seq_file *m, void *data) - { -- struct mdt_device *mdt = data; -+ struct mdt_device *mdt = m->private; - struct coordinator *cdt = &mdt->mdt_coordinator; - -- return lprocfs_rd_hsm_request_mask(page, start, off, count, eof, -- cdt->cdt_group_request_mask); -+ return mdt_hsm_request_mask_show(m, cdt->cdt_group_request_mask); - } - - static int --lprocfs_rd_hsm_other_request_mask(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+mdt_hsm_other_request_mask_seq_show(struct seq_file *m, void *data) - { -- struct mdt_device *mdt = data; -+ struct mdt_device *mdt = m->private; - struct coordinator *cdt = &mdt->mdt_coordinator; - -- return lprocfs_rd_hsm_request_mask(page, start, off, count, eof, -- cdt->cdt_other_request_mask); -+ return mdt_hsm_request_mask_show(m, cdt->cdt_other_request_mask); - } - - static inline enum hsm_copytool_action -@@ -2137,9 +2098,9 @@ hsm_copytool_name2action(const char *name) - return -1; - } - --static int --lprocfs_wr_hsm_request_mask(struct file *file, const char __user *user_buf, -- unsigned long user_count, __u64 *mask) -+static ssize_t -+mdt_write_hsm_request_mask(struct file *file, const char __user *user_buf, -+ size_t user_count, __u64 *mask) - { - char *buf, *pos, *name; - size_t buf_size; -@@ -2183,69 +2144,73 @@ out: - RETURN(rc); - } - --static int --lprocfs_wr_hsm_user_request_mask(struct file *file, const char __user *buf, -- unsigned long count, void *data) -+static ssize_t -+mdt_hsm_user_request_mask_seq_write(struct file *file, const char __user *buf, -+ size_t count, loff_t *off) - { -- struct mdt_device *mdt = data; -+ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private; - struct coordinator *cdt = &mdt->mdt_coordinator; - -- return lprocfs_wr_hsm_request_mask(file, buf, count, -+ return mdt_write_hsm_request_mask(file, buf, count, - &cdt->cdt_user_request_mask); - } - --static int --lprocfs_wr_hsm_group_request_mask(struct file *file, const char __user *buf, -- unsigned long count, void *data) -+static ssize_t -+mdt_hsm_group_request_mask_seq_write(struct file *file, const char __user *buf, -+ size_t count, loff_t *off) - { -- struct mdt_device *mdt = data; -+ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private; - struct coordinator *cdt = &mdt->mdt_coordinator; - -- return lprocfs_wr_hsm_request_mask(file, buf, count, -+ return mdt_write_hsm_request_mask(file, buf, count, - &cdt->cdt_group_request_mask); - } - --static int --lprocfs_wr_hsm_other_request_mask(struct file *file, const char __user *buf, -- unsigned long count, void *data) -+static ssize_t -+mdt_hsm_other_request_mask_seq_write(struct file *file, const char __user *buf, -+ size_t count, loff_t *off) - { -- struct mdt_device *mdt = data; -+ struct mdt_device *mdt = ((struct seq_file *)file->private_data)->private; - struct coordinator *cdt = &mdt->mdt_coordinator; - -- return lprocfs_wr_hsm_request_mask(file, buf, count, -+ return mdt_write_hsm_request_mask(file, buf, count, - &cdt->cdt_other_request_mask); - } - --static struct lprocfs_vars lprocfs_mdt_hsm_vars[] = { -- { "agents", NULL, NULL, NULL, &mdt_hsm_agent_fops, -- 0 }, -- { "actions", NULL, NULL, NULL, &mdt_hsm_actions_fops, -- 0444 }, -- { "default_archive_id", lprocfs_rd_hsm_cdt_default_archive_id, -- lprocfs_wr_hsm_cdt_default_archive_id, -- NULL, NULL, 0 }, -- { "grace_delay", lprocfs_rd_hsm_cdt_grace_delay, -- lprocfs_wr_hsm_cdt_grace_delay, -- NULL, NULL, 0 }, -- { "loop_period", lprocfs_rd_hsm_cdt_loop_period, -- lprocfs_wr_hsm_cdt_loop_period, -- NULL, NULL, 0 }, -- { "max_requests", lprocfs_rd_hsm_cdt_max_requests, -- lprocfs_wr_hsm_cdt_max_requests, -- NULL, NULL, 0 }, -- { "policy", lprocfs_rd_hsm_policy, -- lprocfs_wr_hsm_policy, -- NULL, NULL, 0 }, -- { "active_request_timeout", lprocfs_rd_hsm_cdt_active_req_timeout, -- lprocfs_wr_hsm_cdt_active_req_timeout, -- NULL, NULL, 0 }, -- { "active_requests", NULL, NULL, NULL, -- &mdt_hsm_active_requests_fops, 0 }, -- { "user_request_mask", lprocfs_rd_hsm_user_request_mask, -- lprocfs_wr_hsm_user_request_mask, }, -- { "group_request_mask", lprocfs_rd_hsm_group_request_mask, -- lprocfs_wr_hsm_group_request_mask, }, -- { "other_request_mask", lprocfs_rd_hsm_other_request_mask, -- lprocfs_wr_hsm_other_request_mask, }, -+LPROC_SEQ_FOPS(mdt_hsm_cdt_loop_period); -+LPROC_SEQ_FOPS(mdt_hsm_cdt_grace_delay); -+LPROC_SEQ_FOPS(mdt_hsm_cdt_active_req_timeout); -+LPROC_SEQ_FOPS(mdt_hsm_cdt_max_requests); -+LPROC_SEQ_FOPS(mdt_hsm_cdt_default_archive_id); -+LPROC_SEQ_FOPS(mdt_hsm_user_request_mask); -+LPROC_SEQ_FOPS(mdt_hsm_group_request_mask); -+LPROC_SEQ_FOPS(mdt_hsm_other_request_mask); -+ -+static struct lprocfs_seq_vars lprocfs_mdt_hsm_vars[] = { -+ { .name = "agents", -+ .fops = &mdt_hsm_agent_fops }, -+ { .name = "actions", -+ .fops = &mdt_hsm_actions_fops, -+ .proc_mode = 0444 }, -+ { .name = "default_archive_id", -+ .fops = &mdt_hsm_cdt_default_archive_id_fops }, -+ { .name = "grace_delay", -+ .fops = &mdt_hsm_cdt_grace_delay_fops }, -+ { .name = "loop_period", -+ .fops = &mdt_hsm_cdt_loop_period_fops }, -+ { .name = "max_requests", -+ .fops = &mdt_hsm_cdt_max_requests_fops }, -+ { .name = "policy", -+ .fops = &mdt_hsm_policy_fops }, -+ { .name = "active_request_timeout", -+ .fops = &mdt_hsm_cdt_active_req_timeout_fops }, -+ { .name = "active_requests", -+ .fops = &mdt_hsm_active_requests_fops }, -+ { .name = "user_request_mask", -+ .fops = &mdt_hsm_user_request_mask_fops, }, -+ { .name = "group_request_mask", -+ .fops = &mdt_hsm_group_request_mask_fops, }, -+ { .name = "other_request_mask", -+ .fops = &mdt_hsm_other_request_mask_fops, }, - { 0 } - }; -diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c -index 064fef1..c850356 100644 ---- a/lustre/mdt/mdt_handler.c -+++ b/lustre/mdt/mdt_handler.c -@@ -4539,7 +4539,6 @@ static int mdt_process_config(const struct lu_env *env, - - switch (cfg->lcfg_command) { - case LCFG_PARAM: { -- struct lprocfs_static_vars lvars; - struct obd_device *obd = d->ld_obd; - - /* For interoperability */ -@@ -4574,14 +4573,13 @@ static int mdt_process_config(const struct lu_env *env, - } - } - -- lprocfs_mdt_init_vars(&lvars); -- rc = class_process_proc_param(PARAM_MDT, lvars.obd_vars, -- cfg, obd); -+ rc = class_process_proc_seq_param(PARAM_MDT, obd->obd_vars, -+ cfg, obd); - if (rc > 0 || rc == -ENOSYS) { - /* is it an HSM var ? */ -- rc = class_process_proc_param(PARAM_HSM, -- hsm_cdt_get_proc_vars(), -- cfg, obd); -+ rc = class_process_proc_seq_param(PARAM_HSM, -+ hsm_cdt_get_proc_vars(), -+ cfg, obd); - if (rc > 0 || rc == -ENOSYS) - /* we don't understand; pass it on */ - rc = next->ld_ops->ldo_process_config(env, next, -@@ -5762,7 +5760,6 @@ static struct lu_device_type mdt_device_type = { - - static int __init mdt_mod_init(void) - { -- struct lprocfs_static_vars lvars; - int rc; - - CLASSERT(sizeof("0x0123456789ABCDEF:0x01234567:0x01234567") == -@@ -5777,10 +5774,9 @@ static int __init mdt_mod_init(void) - if (rc) - GOTO(lu_fini, rc); - -- lprocfs_mdt_init_vars(&lvars); - rc = class_register_type(&mdt_obd_device_ops, NULL, NULL, - #ifndef HAVE_ONLY_PROCFS_SEQ -- lvars.module_vars, -+ NULL, - #endif - LUSTRE_MDT_NAME, &mdt_device_type); - if (rc) -diff --git a/lustre/mdt/mdt_hsm_cdt_actions.c b/lustre/mdt/mdt_hsm_cdt_actions.c -index da7f5a9..49c6b8b 100644 ---- a/lustre/mdt/mdt_hsm_cdt_actions.c -+++ b/lustre/mdt/mdt_hsm_cdt_actions.c -@@ -513,9 +513,6 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file) - struct mdt_device *mdt; - ENTRY; - -- if (LPROCFS_ENTRY_CHECK(PDE(inode))) -- RETURN(-ENOENT); -- - rc = seq_open(file, &mdt_hsm_actions_proc_ops); - if (rc) - RETURN(rc); -@@ -532,7 +529,7 @@ static int lprocfs_open_hsm_actions(struct inode *inode, struct file *file) - /* mdt is saved in proc_dir_entry->data by - * mdt_coordinator_procfs_init() calling lprocfs_register() - */ -- mdt = (struct mdt_device *)PDE(inode)->data; -+ mdt = (struct mdt_device *)PDE_DATA(inode); - aai->aai_mdt = mdt; - s = file->private_data; - s->private = aai; -diff --git a/lustre/mdt/mdt_hsm_cdt_agent.c b/lustre/mdt/mdt_hsm_cdt_agent.c -index 9a9ce6d..158cced 100644 ---- a/lustre/mdt/mdt_hsm_cdt_agent.c -+++ b/lustre/mdt/mdt_hsm_cdt_agent.c -@@ -621,15 +621,12 @@ static int lprocfs_open_hsm_agent(struct inode *inode, struct file *file) - int rc; - ENTRY; - -- if (LPROCFS_ENTRY_CHECK(PDE(inode))) -- RETURN(-ENOENT); -- - rc = seq_open(file, &mdt_hsm_agent_proc_ops); - if (rc) - RETURN(rc); - - s = file->private_data; -- s->private = PDE(inode)->data; -+ s->private = PDE_DATA(inode); - - RETURN(rc); - } -diff --git a/lustre/mdt/mdt_hsm_cdt_requests.c b/lustre/mdt/mdt_hsm_cdt_requests.c -index 1300861..3125dcc 100644 ---- a/lustre/mdt/mdt_hsm_cdt_requests.c -+++ b/lustre/mdt/mdt_hsm_cdt_requests.c -@@ -569,15 +569,12 @@ static int lprocfs_open_hsm_active_requests(struct inode *inode, - int rc; - ENTRY; - -- if (LPROCFS_ENTRY_CHECK(PDE(inode))) -- RETURN(-ENOENT); -- - rc = seq_open(file, &mdt_hsm_active_requests_proc_ops); - if (rc) { - RETURN(rc); - } - s = file->private_data; -- s->private = PDE(inode)->data; -+ s->private = PDE_DATA(inode); - - RETURN(rc); - } -diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h -index d548988..e30d78d 100644 ---- a/lustre/mdt/mdt_internal.h -+++ b/lustre/mdt/mdt_internal.h -@@ -784,9 +784,6 @@ void mdt_thread_info_init(struct ptlrpc_request *req, - void mdt_thread_info_fini(struct mdt_thread_info *mti); - struct mdt_thread_info *tsi2mdt_info(struct tgt_session_info *tsi); - --extern struct lprocfs_vars lprocfs_mds_module_vars[]; --extern struct lprocfs_vars lprocfs_mds_obd_vars[]; -- - int mdt_hsm_attr_set(struct mdt_thread_info *info, struct mdt_object *obj, - const struct md_hsm *mh); - -@@ -919,13 +916,12 @@ int mdt_hsm_cdt_fini(struct mdt_device *mdt); - int mdt_hsm_cdt_wakeup(struct mdt_device *mdt); - - /* coordinator control /proc interface */ --int lprocfs_wr_hsm_cdt_control(struct file *file, const char *buffer, -- unsigned long count, void *data); --int lprocfs_rd_hsm_cdt_control(char *page, char **start, off_t off, -- int count, int *eof, void *data); -+ssize_t mdt_hsm_cdt_control_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off); -+int mdt_hsm_cdt_control_seq_show(struct seq_file *m, void *data); - int hsm_cdt_procfs_init(struct mdt_device *mdt); - void hsm_cdt_procfs_fini(struct mdt_device *mdt); --struct lprocfs_vars *hsm_cdt_get_proc_vars(void); -+struct lprocfs_seq_vars *hsm_cdt_get_proc_vars(void); - /* md_hsm helpers */ - struct mdt_object *mdt_hsm_get_md_hsm(struct mdt_thread_info *mti, - const struct lu_fid *fid, -@@ -1065,8 +1061,6 @@ enum { - }; - void mdt_counter_incr(struct ptlrpc_request *req, int opcode); - void mdt_stats_counter_init(struct lprocfs_stats *stats); --void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars); --void lprocfs_mds_init_vars(struct lprocfs_static_vars *lvars); - int mdt_procfs_init(struct mdt_device *mdt, const char *name); - void mdt_procfs_fini(struct mdt_device *mdt); - -diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c -index 0ee5148..658f00d 100644 ---- a/lustre/mdt/mdt_lproc.c -+++ b/lustre/mdt/mdt_lproc.c -@@ -156,7 +156,6 @@ static ssize_t mdt_rename_stats_seq_write(struct file *file, const char *buf, - - return len; - } -- - LPROC_SEQ_FOPS(mdt_rename_stats); - - static int lproc_mdt_attach_rename_seqstat(struct mdt_device *mdt) -@@ -213,143 +212,73 @@ void mdt_rename_counter_tally(struct mdt_thread_info *info, - (unsigned int)ma->ma_attr.la_size); - } - --int mdt_procfs_init(struct mdt_device *mdt, const char *name) -+static int mdt_identity_expire_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = mdt2obd_dev(mdt); -- struct lprocfs_static_vars lvars; -- int rc; -- ENTRY; -- -- LASSERT(name != NULL); -- -- lprocfs_mdt_init_vars(&lvars); -- rc = lprocfs_obd_setup(obd, lvars.obd_vars); -- if (rc) { -- CERROR("%s: cannot create proc entries: rc = %d\n", -- mdt_obd_name(mdt), rc); -- return rc; -- } -- -- rc = hsm_cdt_procfs_init(mdt); -- if (rc) { -- CERROR("%s: cannot create hsm proc entries: rc = %d\n", -- mdt_obd_name(mdt), rc); -- return rc; -- } -- -- obd->obd_proc_exports_entry = proc_mkdir("exports", -- obd->obd_proc_entry); -- if (obd->obd_proc_exports_entry) -- lprocfs_add_simple(obd->obd_proc_exports_entry, -- "clear", lprocfs_nid_stats_clear_read, -- lprocfs_nid_stats_clear_write, obd, NULL); -- rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST); -- if (rc) -- return rc; -- mdt_stats_counter_init(obd->obd_md_stats); -- -- rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST, -- mdt_stats_counter_init); -- -- rc = lproc_mdt_attach_rename_seqstat(mdt); -- if (rc) -- CERROR("%s: MDT can not create rename stats rc = %d\n", -- mdt_obd_name(mdt), rc); -- -- RETURN(rc); --} -- --void mdt_procfs_fini(struct mdt_device *mdt) --{ -- struct obd_device *obd = mdt2obd_dev(mdt); -- -- if (obd->obd_proc_exports_entry != NULL) { -- lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); -- obd->obd_proc_exports_entry = NULL; -- } -- -- lprocfs_free_per_client_stats(obd); -- hsm_cdt_procfs_fini(mdt); -- lprocfs_obd_cleanup(obd); -- lprocfs_free_md_stats(obd); -- lprocfs_free_obd_stats(obd); -- lprocfs_job_stats_fini(obd); --} -- --static int lprocfs_rd_identity_expire(char *page, char **start, off_t off, -- int count, int *eof, void *data) --{ -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- *eof = 1; -- return snprintf(page, count, "%u\n", -- mdt->mdt_identity_cache->uc_entry_expire); -+ return seq_printf(m, "%u\n", mdt->mdt_identity_cache->uc_entry_expire); - } - --static int lprocfs_wr_identity_expire(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_identity_expire_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- int rc, val; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ int rc, val; - -- rc = lprocfs_write_helper(buffer, count, &val); -- if (rc) -- return rc; -+ rc = lprocfs_write_helper(buffer, count, &val); -+ if (rc) -+ return rc; - -- mdt->mdt_identity_cache->uc_entry_expire = val; -- return count; -+ mdt->mdt_identity_cache->uc_entry_expire = val; -+ return count; - } -+LPROC_SEQ_FOPS(mdt_identity_expire); - --static int lprocfs_rd_identity_acquire_expire(char *page, char **start, -- off_t off, int count, int *eof, -- void *data) -+static int mdt_identity_acquire_expire_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- *eof = 1; -- return snprintf(page, count, "%u\n", -- mdt->mdt_identity_cache->uc_acquire_expire); -+ return seq_printf(m,"%u\n", mdt->mdt_identity_cache->uc_acquire_expire); - } - --static int lprocfs_wr_identity_acquire_expire(struct file *file, -- const char *buffer, -- unsigned long count, -- void *data) -+static ssize_t -+mdt_identity_acquire_expire_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- int rc, val; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ int rc, val; - -- rc = lprocfs_write_helper(buffer, count, &val); -- if (rc) -- return rc; -+ rc = lprocfs_write_helper(buffer, count, &val); -+ if (rc) -+ return rc; - -- mdt->mdt_identity_cache->uc_acquire_expire = val; -- return count; -+ mdt->mdt_identity_cache->uc_acquire_expire = val; -+ return count; - } -+LPROC_SEQ_FOPS(mdt_identity_acquire_expire); - --static int lprocfs_rd_identity_upcall(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_identity_upcall_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- struct upcall_cache *hash = mdt->mdt_identity_cache; -- int len; -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct upcall_cache *hash = mdt->mdt_identity_cache; - -- *eof = 1; - read_lock(&hash->uc_upcall_rwlock); -- len = snprintf(page, count, "%s\n", hash->uc_upcall); -+ seq_printf(m, "%s\n", hash->uc_upcall); - read_unlock(&hash->uc_upcall_rwlock); -- return len; -+ return 0; - } - --static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_identity_upcall_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - struct upcall_cache *hash = mdt->mdt_identity_cache; - int rc; -@@ -388,11 +317,13 @@ static int lprocfs_wr_identity_upcall(struct file *file, const char *buffer, - OBD_FREE(kernbuf, count + 1); - RETURN(rc); - } -+LPROC_SEQ_FOPS(mdt_identity_upcall); - --static int lprocfs_wr_identity_flush(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lprocfs_identity_flush_seq_write(struct file *file, const char *buffer, -+ size_t count, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - int rc, uid; - -@@ -403,11 +334,13 @@ static int lprocfs_wr_identity_flush(struct file *file, const char *buffer, - mdt_flush_identity(mdt->mdt_identity_cache, uid); - return count; - } -+LPROC_SEQ_FOPS_WO_TYPE(mdt, identity_flush); - --static int lprocfs_wr_identity_info(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lprocfs_identity_info_seq_write(struct file *file, const char *buffer, -+ size_t count, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - struct identity_downcall_data *param; - int size = sizeof(*param), rc, checked = 0; -@@ -415,7 +348,7 @@ static int lprocfs_wr_identity_info(struct file *file, const char *buffer, - again: - if (count < size) { - CERROR("%s: invalid data count = %lu, size = %d\n", -- mdt_obd_name(mdt), count, size); -+ mdt_obd_name(mdt), (unsigned long) count, size); - return -EINVAL; - } - -@@ -468,23 +401,24 @@ out: - - return rc ? rc : count; - } -+LPROC_SEQ_FOPS_WO_TYPE(mdt, identity_info); - - /* for debug only */ --static int lprocfs_rd_capa(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_capa_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "capability on: %s %s\n", -+ return seq_printf(m, "capability on: %s %s\n", - mdt->mdt_lut.lut_oss_capa ? "oss" : "", - mdt->mdt_lut.lut_mds_capa ? "mds" : ""); - } - --static int lprocfs_wr_capa(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_capa_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - int val, rc; - -@@ -521,64 +455,65 @@ static int lprocfs_wr_capa(struct file *file, const char *buffer, - mdt->mdt_lut.lut_oss_capa ? "enabled" : "disabled"); - return count; - } -+LPROC_SEQ_FOPS(mdt_capa); - --static int lprocfs_rd_capa_count(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_capa_count_seq_show(struct seq_file *m, void *data) - { -- return snprintf(page, count, "%d %d\n", -- capa_count[CAPA_SITE_CLIENT], -- capa_count[CAPA_SITE_SERVER]); -+ return seq_printf(m, "%d %d\n", capa_count[CAPA_SITE_CLIENT], -+ capa_count[CAPA_SITE_SERVER]); - } -+LPROC_SEQ_FOPS_RO(mdt_capa_count); - --static int lprocfs_rd_site_stats(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_site_stats_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return lu_site_stats_print(mdt_lu_site(mdt), page, count); -+ return lu_site_stats_seq_print(mdt_lu_site(mdt), m); - } -+LPROC_SEQ_FOPS_RO(mdt_site_stats); - --static int lprocfs_rd_capa_timeout(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_capa_timeout_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%lu\n", mdt->mdt_capa_timeout); -+ return seq_printf(m, "%lu\n", mdt->mdt_capa_timeout); - } - --static int lprocfs_wr_capa_timeout(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_capa_timeout_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- int val, rc; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ int val, rc; - -- rc = lprocfs_write_helper(buffer, count, &val); -- if (rc) -- return rc; -+ rc = lprocfs_write_helper(buffer, count, &val); -+ if (rc) -+ return rc; - -- mdt->mdt_capa_timeout = (unsigned long)val; -- mdt->mdt_capa_conf = 1; -- return count; -+ mdt->mdt_capa_timeout = (unsigned long)val; -+ mdt->mdt_capa_conf = 1; -+ return count; - } -+LPROC_SEQ_FOPS(mdt_capa_timeout); - --static int lprocfs_rd_ck_timeout(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int mdt_ck_timeout_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%lu\n", mdt->mdt_ck_timeout); -+ return seq_printf(m, "%lu\n", mdt->mdt_ck_timeout); - } - --static int lprocfs_wr_ck_timeout(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_ck_timeout_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- int val, rc; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ int val, rc; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) -@@ -588,11 +523,13 @@ static int lprocfs_wr_ck_timeout(struct file *file, const char *buffer, - mdt->mdt_capa_conf = 1; - return count; - } -+LPROC_SEQ_FOPS(mdt_ck_timeout); - - #define BUFLEN (UUID_MAX + 4) - --static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lprocfs_mds_evict_client_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { - char *kbuf; - char *tmpbuf; -@@ -614,7 +551,7 @@ static int lprocfs_mdt_wr_evict_client(struct file *file, const char *buffer, - tmpbuf = cfs_firststr(kbuf, min_t(unsigned long, BUFLEN - 1, count)); - - if (strncmp(tmpbuf, "nid:", 4) != 0) { -- count = lprocfs_wr_evict_client(file, buffer, count, data); -+ count = lprocfs_evict_client_seq_write(file, buffer, count, off); - goto out; - } - -@@ -627,21 +564,21 @@ out: - - #undef BUFLEN - --static int lprocfs_rd_sec_level(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_sec_level_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%d\n", mdt->mdt_lut.lut_sec_level); -+ return seq_printf(m, "%d\n", mdt->mdt_lut.lut_sec_level); - } - --static int lprocfs_wr_sec_level(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_sec_level_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- int val, rc; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ int val, rc; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) -@@ -659,22 +596,23 @@ static int lprocfs_wr_sec_level(struct file *file, const char *buffer, - mdt->mdt_lut.lut_sec_level = val; - return count; - } -+LPROC_SEQ_FOPS(mdt_sec_level); - --static int lprocfs_rd_cos(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_cos_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%u\n", mdt_cos_is_enabled(mdt)); -+ return seq_printf(m, "%u\n", mdt_cos_is_enabled(mdt)); - } - --static int lprocfs_wr_cos(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_cos_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- int val, rc; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ int val, rc; - - rc = lprocfs_write_helper(buffer, count, &val); - if (rc) -@@ -682,15 +620,15 @@ static int lprocfs_wr_cos(struct file *file, const char *buffer, - mdt_enable_cos(mdt, val); - return count; - } -+LPROC_SEQ_FOPS(mdt_cos); - --static int lprocfs_rd_root_squash(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_root_squash_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%u:%u\n", mdt->mdt_squash_uid, -- mdt->mdt_squash_gid); -+ return seq_printf(m, "%u:%u\n", mdt->mdt_squash_uid, -+ mdt->mdt_squash_gid); - } - - static int safe_strtoul(const char *str, char **endp, unsigned long *res) -@@ -708,10 +646,11 @@ static int safe_strtoul(const char *str, char **endp, unsigned long *res) - return 0; - } - --static int lprocfs_wr_root_squash(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_root_squash_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - int rc; - char kernbuf[50], *tmp, *end, *errmsg; -@@ -765,22 +704,23 @@ failed: - mdt_obd_name(mdt), buffer, errmsg, rc); - RETURN(rc); - } -+LPROC_SEQ_FOPS(mdt_root_squash); - --static int lprocfs_rd_nosquash_nids(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_nosquash_nids_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- if (mdt->mdt_nosquash_str) -- return snprintf(page, count, "%s\n", mdt->mdt_nosquash_str); -- return snprintf(page, count, "NONE\n"); -+ if (mdt->mdt_nosquash_str) -+ return seq_printf(m, "%s\n", mdt->mdt_nosquash_str); -+ return seq_printf(m, "NONE\n"); - } - --static int lprocfs_wr_nosquash_nids(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_nosquash_nids_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - int rc; - char *kernbuf, *errmsg; -@@ -842,25 +782,26 @@ failed: - OBD_FREE(kernbuf, count + 1); - RETURN(rc); - } -+LPROC_SEQ_FOPS(mdt_nosquash_nids); - --static int lprocfs_rd_mdt_som(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_som_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_device *obd = m->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%sabled\n", -- mdt->mdt_som_conf ? "en" : "dis"); -+ return seq_printf(m, "%sabled\n", -+ mdt->mdt_som_conf ? "en" : "dis"); - } - --static int lprocfs_wr_mdt_som(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_som_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_export *exp; -- struct obd_device *obd = data; -- struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -- char kernbuf[16]; -- unsigned long val = 0; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; -+ struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); -+ struct obd_export *exp; -+ char kernbuf[16]; -+ unsigned long val = 0; - - if (count > (sizeof(kernbuf) - 1)) - return -EINVAL; -@@ -902,20 +843,21 @@ static int lprocfs_wr_mdt_som(struct file *file, const char *buffer, - - return count; - } -+LPROC_SEQ_FOPS(mdt_som); - --static int lprocfs_rd_enable_remote_dir(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_enable_remote_dir_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%u\n", mdt->mdt_enable_remote_dir); -+ return seq_printf(m, "%u\n", mdt->mdt_enable_remote_dir); - } - --static int lprocfs_wr_enable_remote_dir(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_enable_remote_dir_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - __u32 val; - int rc; -@@ -930,22 +872,22 @@ static int lprocfs_wr_enable_remote_dir(struct file *file, const char *buffer, - mdt->mdt_enable_remote_dir = val; - return count; - } -+LPROC_SEQ_FOPS(mdt_enable_remote_dir); - --static int lprocfs_rd_enable_remote_dir_gid(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int mdt_enable_remote_dir_gid_seq_show(struct seq_file *m, void *data) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = m->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - -- return snprintf(page, count, "%d\n", -- (int)mdt->mdt_enable_remote_dir_gid); -+ return seq_printf(m, "%d\n", -+ (int)mdt->mdt_enable_remote_dir_gid); - } - --static int lprocfs_wr_enable_remote_dir_gid(struct file *file, -- const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+mdt_enable_remote_dir_gid_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct obd_device *obd = data; -+ struct obd_device *obd = ((struct seq_file *)file->private_data)->private; - struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - __u32 val; - int rc; -@@ -957,97 +899,72 @@ static int lprocfs_wr_enable_remote_dir_gid(struct file *file, - mdt->mdt_enable_remote_dir_gid = val; - return count; - } -- --static struct lprocfs_vars lprocfs_mdt_obd_vars[] = { -- { "uuid", lprocfs_rd_uuid, NULL, -- NULL, NULL, 0 }, -- { "recovery_status", lprocfs_obd_rd_recovery_status, NULL, -- NULL, NULL, 0 }, -- { "num_exports", lprocfs_rd_num_exports, NULL, -- NULL, NULL, 0 }, -- { "identity_expire", lprocfs_rd_identity_expire, -- lprocfs_wr_identity_expire, -- NULL, NULL, 0 }, -- { "identity_acquire_expire", lprocfs_rd_identity_acquire_expire, -- lprocfs_wr_identity_acquire_expire, -- NULL, NULL, 0 }, -- { "identity_upcall", lprocfs_rd_identity_upcall, -- lprocfs_wr_identity_upcall, -- NULL, NULL, 0 }, -- { "identity_flush", NULL, lprocfs_wr_identity_flush, -- NULL, NULL, 0 }, -- { "identity_info", NULL, lprocfs_wr_identity_info, -- NULL, NULL, 0 }, -- { "capa", lprocfs_rd_capa, -- lprocfs_wr_capa, -- NULL, NULL, 0 }, -- { "capa_timeout", lprocfs_rd_capa_timeout, -- lprocfs_wr_capa_timeout, -- NULL, NULL, 0 }, -- { "capa_key_timeout", lprocfs_rd_ck_timeout, -- lprocfs_wr_ck_timeout, -- NULL, NULL, 0 }, -- { "capa_count", lprocfs_rd_capa_count, NULL, -- NULL, NULL, 0 }, -- { "site_stats", lprocfs_rd_site_stats, NULL, -- NULL, NULL, 0 }, -- { "evict_client", NULL, lprocfs_mdt_wr_evict_client, -- NULL, NULL, 0 }, -- { "hash_stats", lprocfs_obd_rd_hash, NULL, -- NULL, NULL, 0 }, -- { "sec_level", lprocfs_rd_sec_level, -- lprocfs_wr_sec_level, -- NULL, NULL, 0 }, -- { "commit_on_sharing", lprocfs_rd_cos, lprocfs_wr_cos, -- NULL, NULL, 0 }, -- { "root_squash", lprocfs_rd_root_squash, -- lprocfs_wr_root_squash, -- NULL, NULL, 0 }, -- { "nosquash_nids", lprocfs_rd_nosquash_nids, -- lprocfs_wr_nosquash_nids, -- NULL, NULL, 0 }, -- { "som", lprocfs_rd_mdt_som, -- lprocfs_wr_mdt_som, -- NULL, NULL, 0 }, -- { "instance", lprocfs_target_rd_instance, NULL, -- NULL, NULL, 0}, -- { "ir_factor", lprocfs_obd_rd_ir_factor, -- lprocfs_obd_wr_ir_factor, -- NULL, NULL, 0 }, -- { "job_cleanup_interval", lprocfs_rd_job_interval, -- lprocfs_wr_job_interval, -- NULL, NULL, 0 }, -- { "enable_remote_dir", lprocfs_rd_enable_remote_dir, -- lprocfs_wr_enable_remote_dir, -- NULL, NULL, 0}, -- { "enable_remote_dir_gid", lprocfs_rd_enable_remote_dir_gid, -- lprocfs_wr_enable_remote_dir_gid, -- NULL, NULL, 0}, -- { "hsm_control", lprocfs_rd_hsm_cdt_control, -- lprocfs_wr_hsm_cdt_control, -- NULL, NULL, 0 }, -- { 0 } --}; -- --static struct lprocfs_vars lprocfs_mdt_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, NULL, -- NULL, NULL, 0 }, -- { 0 } --}; -- --void lprocfs_mdt_init_vars(struct lprocfs_static_vars *lvars) --{ -- lvars->module_vars = lprocfs_mdt_module_vars; -- lvars->obd_vars = lprocfs_mdt_obd_vars; --} -- --struct lprocfs_vars lprocfs_mds_obd_vars[] = { -- { "uuid", lprocfs_rd_uuid, NULL, NULL, NULL, 0 }, -- { 0 } --}; -- --struct lprocfs_vars lprocfs_mds_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, NULL, NULL, NULL, 0 }, -+LPROC_SEQ_FOPS(mdt_enable_remote_dir_gid); -+ -+LPROC_SEQ_FOPS_RO_TYPE(mdt, uuid); -+LPROC_SEQ_FOPS_RO_TYPE(mdt, recovery_status); -+LPROC_SEQ_FOPS_RO_TYPE(mdt, num_exports); -+LPROC_SEQ_FOPS_RO_TYPE(mdt, target_instance); -+LPROC_SEQ_FOPS_RO_TYPE(mdt, hash); -+LPROC_SEQ_FOPS_WO_TYPE(mdt, mds_evict_client); -+LPROC_SEQ_FOPS_RW_TYPE(mdt, job_interval); -+LPROC_SEQ_FOPS_RW_TYPE(mdt, ir_factor); -+LPROC_SEQ_FOPS_RW_TYPE(mdt, nid_stats_clear); -+LPROC_SEQ_FOPS(mdt_hsm_cdt_control); -+ -+static struct lprocfs_seq_vars lprocfs_mdt_obd_vars[] = { -+ { .name = "uuid", -+ .fops = &mdt_uuid_fops }, -+ { .name = "recovery_status", -+ .fops = &mdt_recovery_status_fops }, -+ { .name = "num_exports", -+ .fops = &mdt_num_exports_fops }, -+ { .name = "identity_expire", -+ .fops = &mdt_identity_expire_fops }, -+ { .name = "identity_acquire_expire", -+ .fops = &mdt_identity_acquire_expire_fops }, -+ { .name = "identity_upcall", -+ .fops = &mdt_identity_upcall_fops }, -+ { .name = "identity_flush", -+ .fops = &mdt_identity_flush_fops }, -+ { .name = "identity_info", -+ .fops = &mdt_identity_info_fops }, -+ { .name = "capa", -+ .fops = &mdt_capa_fops }, -+ { .name = "capa_timeout", -+ .fops = &mdt_capa_timeout_fops }, -+ { .name = "capa_key_timeout", -+ .fops = &mdt_ck_timeout_fops }, -+ { .name = "capa_count", -+ .fops = &mdt_capa_count_fops }, -+ { .name = "site_stats", -+ .fops = &mdt_site_stats_fops }, -+ { .name = "evict_client", -+ .fops = &mdt_mds_evict_client_fops }, -+ { .name = "hash_stats", -+ .fops = &mdt_hash_fops }, -+ { .name = "sec_level", -+ .fops = &mdt_sec_level_fops }, -+ { .name = "commit_on_sharing", -+ .fops = &mdt_cos_fops }, -+ { .name = "root_squash", -+ .fops = &mdt_root_squash_fops }, -+ { .name = "nosquash_nids", -+ .fops = &mdt_nosquash_nids_fops }, -+ { .name = "som", -+ .fops = &mdt_som_fops }, -+ { .name = "instance", -+ .fops = &mdt_target_instance_fops }, -+ { .name = "ir_factor", -+ .fops = &mdt_ir_factor_fops }, -+ { .name = "job_cleanup_interval", -+ .fops = &mdt_job_interval_fops }, -+ { .name = "enable_remote_dir", -+ .fops = &mdt_enable_remote_dir_fops }, -+ { .name = "enable_remote_dir_gid", -+ .fops = &mdt_enable_remote_dir_gid_fops }, -+ { .name = "hsm_control", -+ .fops = &mdt_hsm_cdt_control_fops }, - { 0 } - }; - -@@ -1085,21 +1002,15 @@ int lprocfs_mdt_open_files_seq_show(struct seq_file *seq, void *v) - - int lprocfs_mdt_open_files_seq_open(struct inode *inode, struct file *file) - { -- struct proc_dir_entry *dp = PDE(inode); - struct seq_file *seq; -- struct nid_stat *tmp; - int rc; - -- if (LPROCFS_ENTRY_CHECK(dp)) -- return -ENOENT; -- -- tmp = dp->data; - rc = single_open(file, &lprocfs_mdt_open_files_seq_show, NULL); - if (rc != 0) - return rc; - - seq = file->private_data; -- seq->private = tmp; -+ seq->private = PDE_DATA(inode); - - return 0; - } -@@ -1140,3 +1051,67 @@ void mdt_stats_counter_init(struct lprocfs_stats *stats) - lprocfs_counter_init(stats, LPROC_MDT_CROSSDIR_RENAME, 0, - "crossdir_rename", "reqs"); - } -+ -+int mdt_procfs_init(struct mdt_device *mdt, const char *name) -+{ -+ struct obd_device *obd = mdt2obd_dev(mdt); -+ int rc; -+ ENTRY; -+ -+ LASSERT(name != NULL); -+ -+ obd->obd_vars = lprocfs_mdt_obd_vars; -+ rc = lprocfs_seq_obd_setup(obd); -+ if (rc) { -+ CERROR("%s: cannot create proc entries: rc = %d\n", -+ mdt_obd_name(mdt), rc); -+ return rc; -+ } -+ -+ rc = hsm_cdt_procfs_init(mdt); -+ if (rc) { -+ CERROR("%s: cannot create hsm proc entries: rc = %d\n", -+ mdt_obd_name(mdt), rc); -+ return rc; -+ } -+ -+ obd->obd_proc_exports_entry = proc_mkdir("exports", -+ obd->obd_proc_entry); -+ if (obd->obd_proc_exports_entry) -+ lprocfs_add_simple(obd->obd_proc_exports_entry, "clear", -+#ifndef HAVE_ONLY_PROCFS_SEQ -+ NULL, NULL, -+#endif -+ obd, &mdt_nid_stats_clear_fops); -+ rc = lprocfs_alloc_md_stats(obd, LPROC_MDT_LAST); -+ if (rc) -+ return rc; -+ mdt_stats_counter_init(obd->obd_md_stats); -+ -+ rc = lprocfs_job_stats_init(obd, LPROC_MDT_LAST, -+ mdt_stats_counter_init); -+ -+ rc = lproc_mdt_attach_rename_seqstat(mdt); -+ if (rc) -+ CERROR("%s: MDT can not create rename stats rc = %d\n", -+ mdt_obd_name(mdt), rc); -+ -+ RETURN(rc); -+} -+ -+void mdt_procfs_fini(struct mdt_device *mdt) -+{ -+ struct obd_device *obd = mdt2obd_dev(mdt); -+ -+ if (obd->obd_proc_exports_entry != NULL) { -+ lprocfs_remove_proc_entry("clear", obd->obd_proc_exports_entry); -+ obd->obd_proc_exports_entry = NULL; -+ } -+ -+ lprocfs_free_per_client_stats(obd); -+ hsm_cdt_procfs_fini(mdt); -+ lprocfs_obd_cleanup(obd); -+ lprocfs_free_md_stats(obd); -+ lprocfs_free_obd_stats(obd); -+ lprocfs_job_stats_fini(obd); -+} -diff --git a/lustre/mdt/mdt_mds.c b/lustre/mdt/mdt_mds.c -index 367f659..4fa66c3 100644 ---- a/lustre/mdt/mdt_mds.c -+++ b/lustre/mdt/mdt_mds.c -@@ -464,6 +464,13 @@ static struct lu_device *mds_device_free(const struct lu_env *env, - RETURN(NULL); - } - -+LPROC_SEQ_FOPS_RO_TYPE(mds, uuid); -+ -+static struct lprocfs_seq_vars lprocfs_mds_obd_vars[] = { -+ { "uuid", &mds_uuid_fops }, -+ { 0 } -+}; -+ - static struct lu_device *mds_device_alloc(const struct lu_env *env, - struct lu_device_type *t, - struct lustre_cfg *cfg) -@@ -487,7 +494,8 @@ static struct lu_device *mds_device_alloc(const struct lu_env *env, - /* set this lu_device to obd, because error handling need it */ - obd->obd_lu_dev = l; - -- rc = lprocfs_obd_setup(obd, lprocfs_mds_obd_vars); -+ obd->obd_vars = lprocfs_mds_obd_vars; -+ rc = lprocfs_seq_obd_setup(obd); - if (rc != 0) { - mds_device_free(env, l); - l = ERR_PTR(rc); -@@ -541,7 +549,7 @@ int mds_mod_init(void) - - return class_register_type(&mds_obd_device_ops, NULL, NULL, - #ifndef HAVE_ONLY_PROCFS_SEQ -- lprocfs_mds_module_vars, -+ NULL, - #endif - LUSTRE_MDS_NAME, &mds_device_type); - } --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0009-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch b/sys-cluster/lustre/files/0009-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch new file mode 100644 index 000000000..97b8e0e74 --- /dev/null +++ b/sys-cluster/lustre/files/0009-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch @@ -0,0 +1,807 @@ +From adf3be9fe382564c4760b83a5843b7d5502bbe48 Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Sun, 9 Feb 2014 10:45:37 -0500 +Subject: [PATCH 09/12] LU-3319 procfs: update ldiskfs proc handling to + seq_files + +Migrate all ldiskfs proc handling to using strictly +seq_files. Also include a fix with newer gcc complaining +certain variables are initialized. + +Signed-off-by: James Simmons +Change-Id: Ia296a4682e2feda02bcfbe0100de8a89404cd731 +--- + lustre/osd-ldiskfs/osd_compat.c | 6 +- + lustre/osd-ldiskfs/osd_handler.c | 16 +- + lustre/osd-ldiskfs/osd_internal.h | 6 +- + lustre/osd-ldiskfs/osd_lproc.c | 336 ++++++++++++++++++++------------------ + lustre/osd-ldiskfs/osd_scrub.c | 73 +++------ + 5 files changed, 220 insertions(+), 217 deletions(-) + +diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c +index b4a018c..6ca1304 100644 +--- a/lustre/osd-ldiskfs/osd_compat.c ++++ b/lustre/osd-ldiskfs/osd_compat.c +@@ -1168,7 +1168,7 @@ int osd_obj_spec_update(struct osd_thread_info *info, struct osd_device *osd, + handle_t *th) + { + struct dentry *root; +- char *name; ++ char *name = NULL; + int rc; + ENTRY; + +@@ -1189,7 +1189,7 @@ int osd_obj_spec_insert(struct osd_thread_info *info, struct osd_device *osd, + handle_t *th) + { + struct dentry *root; +- char *name; ++ char *name = NULL; + int rc; + ENTRY; + +@@ -1211,7 +1211,7 @@ int osd_obj_spec_lookup(struct osd_thread_info *info, struct osd_device *osd, + struct dentry *root; + struct dentry *dentry; + struct inode *inode; +- char *name; ++ char *name = NULL; + int rc = -ENOENT; + ENTRY; + +diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c +index 9027533..dfaa542 100644 +--- a/lustre/osd-ldiskfs/osd_handler.c ++++ b/lustre/osd-ldiskfs/osd_handler.c +@@ -5814,6 +5814,7 @@ static struct lu_device *osd_device_free(const struct lu_env *env, + static int osd_process_config(const struct lu_env *env, + struct lu_device *d, struct lustre_cfg *cfg) + { ++ struct obd_device *obd = d->ld_obd; + struct osd_device *o = osd_dev(d); + int rc; + ENTRY; +@@ -5828,12 +5829,12 @@ static int osd_process_config(const struct lu_env *env, + break; + case LCFG_PARAM: + LASSERT(&o->od_dt_dev); +- rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars, +- cfg, &o->od_dt_dev); ++ rc = class_process_proc_seq_param(PARAM_OSD, obd->obd_vars, ++ cfg, &o->od_dt_dev); + if (rc > 0 || rc == -ENOSYS) +- rc = class_process_proc_param(PARAM_OST, +- lprocfs_osd_obd_vars, +- cfg, &o->od_dt_dev); ++ rc = class_process_proc_seq_param(PARAM_OST, ++ obd->obd_vars, cfg, ++ &o->od_dt_dev); + break; + default: + rc = -ENOSYS; +@@ -5981,9 +5982,10 @@ static int __init osd_mod_init(void) + if (rc) + return rc; + +- rc = class_register_type(&osd_obd_device_ops, NULL, NULL, +-#ifndef HAVE_ONLY_PROCFS_SEQ ++ rc = class_register_type(&osd_obd_device_ops, NULL, + lprocfs_osd_module_vars, ++#ifndef HAVE_ONLY_PROCFS_SEQ ++ NULL, + #endif + LUSTRE_OSD_LDISKFS_NAME, &osd_device_type); + if (rc) +diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h +index 8436d1f..c90147f 100644 +--- a/lustre/osd-ldiskfs/osd_internal.h ++++ b/lustre/osd-ldiskfs/osd_internal.h +@@ -623,8 +623,8 @@ static inline int __osd_xattr_set(struct osd_thread_info *info, + + #ifdef LPROCFS + /* osd_lproc.c */ +-extern struct lprocfs_vars lprocfs_osd_obd_vars[]; +-extern struct lprocfs_vars lprocfs_osd_module_vars[]; ++extern struct lprocfs_seq_vars lprocfs_osd_obd_vars[]; ++extern struct lprocfs_seq_vars lprocfs_osd_module_vars[]; + int osd_procfs_init(struct osd_device *osd, const char *name); + int osd_procfs_fini(struct osd_device *osd); + void osd_brw_stats_update(struct osd_device *osd, struct osd_iobuf *iobuf); +@@ -679,7 +679,7 @@ int osd_oii_insert(struct osd_device *dev, struct osd_idmap_cache *oic, + int insert); + int osd_oii_lookup(struct osd_device *dev, const struct lu_fid *fid, + struct osd_inode_id *id); +-int osd_scrub_dump(struct osd_device *dev, char *buf, int len); ++int osd_scrub_dump(struct seq_file *m, struct osd_device *dev); + + int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd, + obd_seq seq, struct lu_seq_range *range); +diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c +index b9b4e3d..947a4b9 100644 +--- a/lustre/osd-ldiskfs/osd_lproc.c ++++ b/lustre/osd-ldiskfs/osd_lproc.c +@@ -237,92 +237,46 @@ out: + RETURN(result); + } + +-int osd_procfs_init(struct osd_device *osd, const char *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_OSD_LDISKFS_NAME); +- +- LASSERT(name != NULL); +- LASSERT(type != NULL); +- +- /* Find the type procroot and add the proc entry for this device */ +- osd->od_proc_entry = lprocfs_register(name, type->typ_procroot, +- lprocfs_osd_obd_vars, +- &osd->od_dt_dev); +- if (IS_ERR(osd->od_proc_entry)) { +- rc = PTR_ERR(osd->od_proc_entry); +- CERROR("Error %d setting up lprocfs for %s\n", +- rc, name); +- osd->od_proc_entry = NULL; +- GOTO(out, rc); +- } +- +- rc = osd_stats_init(osd); +- +- EXIT; +-out: +- if (rc) +- osd_procfs_fini(osd); +- return rc; +-} +- +-int osd_procfs_fini(struct osd_device *osd) +-{ +- if (osd->od_stats) +- lprocfs_free_stats(&osd->od_stats); +- +- if (osd->od_proc_entry) { +- lprocfs_remove(&osd->od_proc_entry); +- osd->od_proc_entry = NULL; +- } +- RETURN(0); +-} +- +-static int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int ldiskfs_osd_fstype_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *osd = osd_dt_dev(data); ++ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); + +- LASSERT(osd != NULL); +- return snprintf(page, count, "ldiskfs\n"); ++ LASSERT(osd != NULL); ++ return seq_printf(m, "ldiskfs\n"); + } ++LPROC_SEQ_FOPS_RO(ldiskfs_osd_fstype); + +-static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int ldiskfs_osd_mntdev_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *osd = osd_dt_dev(data); ++ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); + +- LASSERT(osd != NULL); ++ LASSERT(osd != NULL); + if (unlikely(osd->od_mnt == NULL)) +- return -EINPROGRESS; +- +- *eof = 1; ++ return -EINPROGRESS; + +- return snprintf(page, count, "%s\n", osd->od_mntdev); ++ return seq_printf(m, "%u\n", osd->od_read_cache); + } ++LPROC_SEQ_FOPS_RO(ldiskfs_osd_mntdev); + +-static int lprocfs_osd_rd_cache(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ldiskfs_osd_cache_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *osd = osd_dt_dev(data); ++ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); + + LASSERT(osd != NULL); + if (unlikely(osd->od_mnt == NULL)) + return -EINPROGRESS; + +- return snprintf(page, count, "%u\n", osd->od_read_cache); ++ return seq_printf(m, "%u\n", osd->od_read_cache); + } + +-static int lprocfs_osd_wr_cache(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ldiskfs_osd_cache_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct osd_device *osd = osd_dt_dev(data); +- int val, rc; ++ struct seq_file *m = file->private_data; ++ struct dt_device *dt = m->private; ++ struct osd_device *osd = osd_dt_dev(dt); ++ int val, rc; + + LASSERT(osd != NULL); + if (unlikely(osd->od_mnt == NULL)) +@@ -335,24 +289,26 @@ static int lprocfs_osd_wr_cache(struct file *file, const char *buffer, + osd->od_read_cache = !!val; + return count; + } ++LPROC_SEQ_FOPS(ldiskfs_osd_cache); + +-static int lprocfs_osd_rd_wcache(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ldiskfs_osd_wcache_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *osd = osd_dt_dev(data); ++ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); + + LASSERT(osd != NULL); + if (unlikely(osd->od_mnt == NULL)) + return -EINPROGRESS; + +- return snprintf(page, count, "%u\n", osd->od_writethrough_cache); ++ return seq_printf(m, "%u\n", osd->od_writethrough_cache); + } + +-static int lprocfs_osd_wr_wcache(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ldiskfs_osd_wcache_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct osd_device *osd = osd_dt_dev(data); +- int val, rc; ++ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; ++ struct osd_device *osd = osd_dt_dev(dt); ++ int val, rc; + + LASSERT(osd != NULL); + if (unlikely(osd->od_mnt == NULL)) +@@ -365,14 +321,16 @@ static int lprocfs_osd_wr_wcache(struct file *file, const char *buffer, + osd->od_writethrough_cache = !!val; + return count; + } ++LPROC_SEQ_FOPS(ldiskfs_osd_wcache); + +-static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++lprocfs_osd_force_sync_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct osd_device *osd = osd_dt_dev(data); +- struct dt_device *dt = data; +- struct lu_env env; +- int rc; ++ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; ++ struct osd_device *osd = osd_dt_dev(dt); ++ struct lu_env env; ++ int rc; + + LASSERT(osd != NULL); + if (unlikely(osd->od_mnt == NULL)) +@@ -386,20 +344,18 @@ static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, + + return rc == 0 ? count : rc; + } ++LPROC_SEQ_FOPS_WO_TYPE(ldiskfs, osd_force_sync); + +-static int lprocfs_osd_rd_pdo(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++static int ldiskfs_osd_pdo_seq_show(struct seq_file *m, void *data) + { +- *eof = 1; +- +- return snprintf(page, count, "%s\n", ldiskfs_pdo ? "ON" : "OFF"); ++ return seq_printf(m, "%s\n", ldiskfs_pdo ? "ON" : "OFF"); + } + +-static int lprocfs_osd_wr_pdo(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ldiskfs_osd_pdo_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- int pdo; +- int rc; ++ int pdo, rc; + + rc = lprocfs_write_helper(buffer, count, &pdo); + if (rc != 0) +@@ -409,24 +365,25 @@ static int lprocfs_osd_wr_pdo(struct file *file, const char *buffer, + + return count; + } ++LPROC_SEQ_FOPS(ldiskfs_osd_pdo); + +-static int lprocfs_osd_rd_auto_scrub(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ldiskfs_osd_auto_scrub_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *dev = osd_dt_dev(data); ++ struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private); + + LASSERT(dev != NULL); + if (unlikely(dev->od_mnt == NULL)) + return -EINPROGRESS; + +- *eof = 1; +- return snprintf(page, count, "%d\n", !dev->od_noscrub); ++ return seq_printf(m, "%d\n", !dev->od_noscrub); + } + +-static int lprocfs_osd_wr_auto_scrub(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ldiskfs_osd_auto_scrub_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct osd_device *dev = osd_dt_dev(data); ++ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; ++ struct osd_device *dev = osd_dt_dev(dt); + int val, rc; + + LASSERT(dev != NULL); +@@ -440,19 +397,18 @@ static int lprocfs_osd_wr_auto_scrub(struct file *file, const char *buffer, + dev->od_noscrub = !val; + return count; + } ++LPROC_SEQ_FOPS(ldiskfs_osd_auto_scrub); + +-static int lprocfs_osd_rd_track_declares_assert(char *page, char **start, +- off_t off, int count, +- int *eof, void *data) ++static int ++ldiskfs_osd_track_declares_assert_seq_show(struct seq_file *m, void *data) + { +- *eof = 1; +- +- return snprintf(page, count, "%d\n", ldiskfs_track_declares_assert); ++ return seq_printf(m, "%d\n", ldiskfs_track_declares_assert); + } + +-static int lprocfs_osd_wr_track_declares_assert(struct file *file, ++static ssize_t ++ldiskfs_osd_track_declares_assert_seq_write(struct file *file, + const char *buffer, +- unsigned long count, void *data) ++ size_t count, loff_t *off) + { + int track_declares_assert; + int rc; +@@ -465,38 +421,39 @@ static int lprocfs_osd_wr_track_declares_assert(struct file *file, + + return count; + } ++LPROC_SEQ_FOPS(ldiskfs_osd_track_declares_assert); ++ ++extern int osd_scrub_dump(struct seq_file *m, struct osd_device *dev); + +-static int lprocfs_osd_rd_oi_scrub(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ldiskfs_osd_oi_scrub_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *dev = osd_dt_dev(data); ++ struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private); + + LASSERT(dev != NULL); + if (unlikely(dev->od_mnt == NULL)) + return -EINPROGRESS; + +- *eof = 1; +- return osd_scrub_dump(dev, page, count); ++ return osd_scrub_dump(m, dev); + } ++LPROC_SEQ_FOPS_RO(ldiskfs_osd_oi_scrub); + +-int lprocfs_osd_rd_readcache(char *page, char **start, off_t off, int count, +- int *eof, void *data) ++int ldiskfs_osd_readcache_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *osd = osd_dt_dev(data); +- int rc; ++ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); + + LASSERT(osd != NULL); + if (unlikely(osd->od_mnt == NULL)) + return -EINPROGRESS; + +- rc = snprintf(page, count, LPU64"\n", osd->od_readcache_max_filesize); +- return rc; ++ return seq_printf(m, LPU64"\n", osd->od_readcache_max_filesize); + } + +-int lprocfs_osd_wr_readcache(struct file *file, const char *buffer, +- unsigned long count, void *data) ++ssize_t ++ldiskfs_osd_readcache_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct osd_device *osd = osd_dt_dev(data); ++ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; ++ struct osd_device *osd = osd_dt_dev(dt); + __u64 val; + int rc; + +@@ -512,24 +469,25 @@ int lprocfs_osd_wr_readcache(struct file *file, const char *buffer, + OSD_MAX_CACHE_SIZE : val; + return count; + } ++LPROC_SEQ_FOPS(ldiskfs_osd_readcache); + +-static int lprocfs_osd_rd_lma_self_repair(char *page, char **start, off_t off, +- int count, int *eof, void *data) ++static int ldiskfs_osd_lma_self_repair_seq_show(struct seq_file *m, void *data) + { +- struct osd_device *dev = osd_dt_dev(data); ++ struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private); + + LASSERT(dev != NULL); + if (unlikely(dev->od_mnt == NULL)) + return -EINPROGRESS; + +- *eof = 1; +- return snprintf(page, count, "%d\n", !!dev->od_lma_self_repair); ++ return seq_printf(m, "%d\n", !!dev->od_lma_self_repair); + } + +-static int lprocfs_osd_wr_lma_self_repair(struct file *file, const char *buffer, +- unsigned long count, void *data) ++static ssize_t ++ldiskfs_osd_lma_self_repair_seq_write(struct file *file, const char *buffer, ++ size_t count, loff_t *off) + { +- struct osd_device *dev = osd_dt_dev(data); ++ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; ++ struct osd_device *dev = osd_dt_dev(dt); + int val; + int rc; + +@@ -544,38 +502,102 @@ static int lprocfs_osd_wr_lma_self_repair(struct file *file, const char *buffer, + dev->od_lma_self_repair = !!val; + return count; + } +- +-struct lprocfs_vars lprocfs_osd_obd_vars[] = { +- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, +- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, +- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, +- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, +- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, +- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, +- { "fstype", lprocfs_osd_rd_fstype, 0, 0 }, +- { "mntdev", lprocfs_osd_rd_mntdev, 0, 0 }, +- { "force_sync", 0, lprocfs_osd_wr_force_sync }, +- { "pdo", lprocfs_osd_rd_pdo, lprocfs_osd_wr_pdo, 0 }, +- { "auto_scrub", lprocfs_osd_rd_auto_scrub, +- lprocfs_osd_wr_auto_scrub, 0 }, +- { "oi_scrub", lprocfs_osd_rd_oi_scrub, 0, 0 }, +- { "force_sync", 0, lprocfs_osd_wr_force_sync }, +- { "read_cache_enable", lprocfs_osd_rd_cache, lprocfs_osd_wr_cache, 0 }, +- { "writethrough_cache_enable", lprocfs_osd_rd_wcache, +- lprocfs_osd_wr_wcache, 0 }, +- { "readcache_max_filesize", lprocfs_osd_rd_readcache, +- lprocfs_osd_wr_readcache, 0 }, +- { "lma_self_repair", lprocfs_osd_rd_lma_self_repair, +- lprocfs_osd_wr_lma_self_repair, 0, 0 }, ++LPROC_SEQ_FOPS(ldiskfs_osd_lma_self_repair); ++ ++LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_blksize); ++LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytestotal); ++LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytesfree); ++LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytesavail); ++LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_filestotal); ++LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_filesfree); ++ ++struct lprocfs_seq_vars lprocfs_osd_obd_vars[] = { ++ { .name = "blocksize", ++ .fops = &ldiskfs_dt_blksize_fops }, ++ { .name = "kbytestotal", ++ .fops = &ldiskfs_dt_kbytestotal_fops }, ++ { .name = "kbytesfree", ++ .fops = &ldiskfs_dt_kbytesfree_fops }, ++ { .name = "kbytesavail", ++ .fops = &ldiskfs_dt_kbytesavail_fops }, ++ { .name = "filestotal", ++ .fops = &ldiskfs_dt_filestotal_fops }, ++ { .name = "filesfree", ++ .fops = &ldiskfs_dt_filesfree_fops }, ++ { .name = "fstype", ++ .fops = &ldiskfs_osd_fstype_fops }, ++ { .name = "mntdev", ++ .fops = &ldiskfs_osd_mntdev_fops }, ++ { .name = "force_sync", ++ .fops = &ldiskfs_osd_force_sync_fops }, ++ { .name = "pdo", ++ .fops = &ldiskfs_osd_pdo_fops }, ++ { .name = "auto_scrub", ++ .fops = &ldiskfs_osd_auto_scrub_fops }, ++ { .name = "oi_scrub", ++ .fops = &ldiskfs_osd_oi_scrub_fops }, ++ { .name = "read_cache_enable", ++ .fops = &ldiskfs_osd_cache_fops }, ++ { .name = "writethrough_cache_enable", ++ .fops = &ldiskfs_osd_wcache_fops }, ++ { .name = "readcache_max_filesize", ++ .fops = &ldiskfs_osd_readcache_fops }, ++ { .name = "lma_self_repair", ++ .fops = &ldiskfs_osd_lma_self_repair_fops }, + { 0 } + }; + +-struct lprocfs_vars lprocfs_osd_module_vars[] = { +- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, +- { "track_declares_assert", lprocfs_osd_rd_track_declares_assert, +- lprocfs_osd_wr_track_declares_assert, +- 0 }, +- { 0 } ++struct lprocfs_seq_vars lprocfs_osd_module_vars[] = { ++ { .name = "track_declares_assert", ++ .fops = &ldiskfs_osd_track_declares_assert_fops }, ++ { 0 } + }; + ++ ++int osd_procfs_init(struct osd_device *osd, const char *name) ++{ ++ struct obd_type *type; ++ int rc; ++ ENTRY; ++ ++ if (osd->od_proc_entry) ++ RETURN(0); ++ ++ /* 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_OSD_LDISKFS_NAME); ++ ++ LASSERT(name != NULL); ++ LASSERT(type != NULL); ++ ++ /* Find the type procroot and add the proc entry for this device */ ++ osd->od_proc_entry = lprocfs_seq_register(name, type->typ_procroot, ++ lprocfs_osd_obd_vars, ++ &osd->od_dt_dev); ++ if (IS_ERR(osd->od_proc_entry)) { ++ rc = PTR_ERR(osd->od_proc_entry); ++ CERROR("Error %d setting up lprocfs for %s\n", ++ rc, name); ++ osd->od_proc_entry = NULL; ++ GOTO(out, rc); ++ } ++ ++ rc = osd_stats_init(osd); ++ ++ EXIT; ++out: ++ if (rc) ++ osd_procfs_fini(osd); ++ return rc; ++} ++ ++int osd_procfs_fini(struct osd_device *osd) ++{ ++ if (osd->od_stats) ++ lprocfs_free_stats(&osd->od_stats); ++ ++ if (osd->od_proc_entry) ++ lprocfs_remove(&osd->od_proc_entry); ++ RETURN(0); ++} + #endif +diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c +index cce33af..1002913 100644 +--- a/lustre/osd-ldiskfs/osd_scrub.c ++++ b/lustre/osd-ldiskfs/osd_scrub.c +@@ -2578,80 +2578,69 @@ static const char *scrub_param_names[] = { + NULL + }; + +-static int scrub_bits_dump(char **buf, int *len, int bits, const char *names[], ++static int scrub_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'); ++ rc = seq_printf(m, "%s:%c", prefix, bits != 0 ? ' ' : '\n'); + if (rc <= 0) + return -ENOSPC; + +- *buf += rc; +- *len -= rc; + for (i = 0, flag = 1; bits != 0; i++, flag = 1 << i) { + if (flag & bits) { + bits &= ~flag; +- rc = snprintf(*buf, *len, "%s%c", names[i], +- bits != 0 ? ',' : '\n'); ++ rc = seq_printf(m, "%s%c", names[i], ++ bits != 0 ? ',' : '\n'); + if (rc <= 0) + return -ENOSPC; +- +- *buf += rc; +- *len -= rc; + } + } +- return save - *len; ++ return 0; + } + +-static int scrub_time_dump(char **buf, int *len, __u64 time, const char *prefix) ++static int scrub_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, ++ rc = seq_printf(m, "%s: "LPU64" seconds\n", prefix, + cfs_time_current_sec() - time); + else +- rc = snprintf(*buf, *len, "%s: N/A\n", prefix); ++ rc = seq_printf(m, "%s: N/A\n", prefix); + if (rc <= 0) + return -ENOSPC; + +- *buf += rc; +- *len -= rc; +- return rc; ++ return 0; + } + +-static int scrub_pos_dump(char **buf, int *len, __u64 pos, const char *prefix) ++static int scrub_pos_dump(struct seq_file *m, __u64 pos, const char *prefix) + { + int rc; + + if (pos != 0) +- rc = snprintf(*buf, *len, "%s: "LPU64"\n", prefix, pos); ++ rc = seq_printf(m, "%s: "LPU64"\n", prefix, pos); + else +- rc = snprintf(*buf, *len, "%s: N/A\n", prefix); ++ rc = seq_printf(m, "%s: N/A\n", prefix); + if (rc <= 0) + return -ENOSPC; + +- *buf += rc; +- *len -= rc; + return rc; + } + +-int osd_scrub_dump(struct osd_device *dev, char *buf, int len) ++int osd_scrub_dump(struct seq_file *m,struct osd_device *dev) + { + struct osd_scrub *scrub = &dev->od_scrub; + struct scrub_file *sf = &scrub->os_file; + __u64 checked; + __u64 speed; +- int save = len; + int ret = -ENOSPC; + int rc; + + down_read(&scrub->os_rwsem); +- rc = snprintf(buf, len, ++ rc = seq_printf(m, + "name: OI_scrub\n" + "magic: 0x%x\n" + "oi_files: %d\n" +@@ -2661,51 +2650,48 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) + if (rc <= 0) + goto out; + +- buf += rc; +- len -= rc; +- rc = scrub_bits_dump(&buf, &len, sf->sf_flags, scrub_flags_names, ++ rc = scrub_bits_dump(m, sf->sf_flags, scrub_flags_names, + "flags"); + if (rc < 0) + goto out; + +- rc = scrub_bits_dump(&buf, &len, sf->sf_param, scrub_param_names, ++ rc = scrub_bits_dump(m, sf->sf_param, scrub_param_names, + "param"); + if (rc < 0) + goto out; + +- rc = scrub_time_dump(&buf, &len, sf->sf_time_last_complete, ++ rc = scrub_time_dump(m, sf->sf_time_last_complete, + "time_since_last_completed"); + if (rc < 0) + goto out; + +- rc = scrub_time_dump(&buf, &len, sf->sf_time_latest_start, ++ rc = scrub_time_dump(m, sf->sf_time_latest_start, + "time_since_latest_start"); + if (rc < 0) + goto out; + +- rc = scrub_time_dump(&buf, &len, sf->sf_time_last_checkpoint, ++ rc = scrub_time_dump(m, sf->sf_time_last_checkpoint, + "time_since_last_checkpoint"); + if (rc < 0) + goto out; + +- rc = scrub_pos_dump(&buf, &len, sf->sf_pos_latest_start, ++ rc = scrub_pos_dump(m, sf->sf_pos_latest_start, + "latest_start_position"); + if (rc < 0) + goto out; + +- rc = scrub_pos_dump(&buf, &len, sf->sf_pos_last_checkpoint, ++ rc = scrub_pos_dump(m, sf->sf_pos_last_checkpoint, + "last_checkpoint_position"); + if (rc < 0) + goto out; + +- rc = scrub_pos_dump(&buf, &len, sf->sf_pos_first_inconsistent, ++ rc = scrub_pos_dump(m, sf->sf_pos_first_inconsistent, + "first_failure_position"); + if (rc < 0) + goto out; + + checked = sf->sf_items_checked + scrub->os_new_checked; +- rc = snprintf(buf, len, +- "checked: "LPU64"\n" ++ rc = seq_printf(m, "checked: "LPU64"\n" + "updated: "LPU64"\n" + "failed: "LPU64"\n" + "prior_updated: "LPU64"\n" +@@ -2718,8 +2704,6 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) + if (rc <= 0) + goto out; + +- buf += rc; +- len -= rc; + speed = checked; + if (thread_is_running(&scrub->os_thread)) { + cfs_duration_t duration = cfs_time_current() - +@@ -2732,8 +2716,7 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) + do_div(new_checked, duration); + if (rtime != 0) + do_div(speed, rtime); +- rc = snprintf(buf, len, +- "run_time: %u seconds\n" ++ rc = seq_printf(m, "run_time: %u seconds\n" + "average_speed: "LPU64" objects/sec\n" + "real-time_speed: "LPU64" objects/sec\n" + "current_position: %u\n" +@@ -2746,8 +2729,7 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) + } else { + if (sf->sf_run_time != 0) + do_div(speed, sf->sf_run_time); +- rc = snprintf(buf, len, +- "run_time: %u seconds\n" ++ rc = seq_printf(m, "run_time: %u seconds\n" + "average_speed: "LPU64" objects/sec\n" + "real-time_speed: N/A\n" + "current_position: N/A\n" +@@ -2759,10 +2741,7 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) + } + if (rc <= 0) + goto out; +- +- buf += rc; +- len -= rc; +- ret = save - len; ++ ret = 0; + + out: + up_read(&scrub->os_rwsem); +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0010-LU-3319-lprocfs-client-side-cleanups.patch b/sys-cluster/lustre/files/0010-LU-3319-lprocfs-client-side-cleanups.patch new file mode 100644 index 000000000..1eed584b6 --- /dev/null +++ b/sys-cluster/lustre/files/0010-LU-3319-lprocfs-client-side-cleanups.patch @@ -0,0 +1,463 @@ +From cd81037fa6ecc7f6b36d3c49205a3d6f3e7aa0de Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Tue, 21 Jan 2014 12:06:59 -0500 +Subject: [PATCH 10/12] LU-3319 lprocfs: client side cleanups + +Now that all the client side seq_file patches it is +time to handle the issue that people pointed out but +were not severe enough to prevent landing. This patch +addresses all the concerns as well and move all struct +lprocfs_seq_var to be initialized C99 style. + +Change-Id: I89e8b719bd067ecf4e3cab481a2d4c62d5052af0 +Signed-off-by: James Simmons +--- + lustre/fid/lproc_fid.c | 21 ++++++--- + lustre/lmv/lproc_lmv.c | 15 ++++--- + lustre/lov/lproc_lov.c | 42 ++++++++++++------ + lustre/mdc/lproc_mdc.c | 52 ++++++++++++++-------- + lustre/mgc/lproc_mgc.c | 25 +++++++---- + lustre/obdclass/lprocfs_status.c | 1 - + lustre/obdecho/echo.c | 3 +- + lustre/osc/lproc_osc.c | 94 +++++++++++++++++++++++++++------------- + lustre/osc/osc_request.c | 2 +- + lustre/ost/ost_handler.c | 3 +- + lustre/ptlrpc/lproc_ptlrpc.c | 2 +- + lustre/quota/qmt_pool.c | 3 +- + lustre/quota/qsd_lib.c | 12 +++-- + 13 files changed, 183 insertions(+), 92 deletions(-) + +diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c +index d89c4f6..3b9d170 100644 +--- a/lustre/fid/lproc_fid.c ++++ b/lustre/fid/lproc_fid.c +@@ -203,9 +203,12 @@ LPROC_SEQ_FOPS(lprocfs_server_fid_width); + LPROC_SEQ_FOPS_RO(lprocfs_server_fid_server); + + struct lprocfs_seq_vars seq_server_proc_list[] = { +- { "space", &lprocfs_server_fid_space_fops }, +- { "width", &lprocfs_server_fid_width_fops }, +- { "server", &lprocfs_server_fid_server_fops }, ++ { .name = "space", ++ .fops = &lprocfs_server_fid_space_fops }, ++ { .name = "width", ++ .fops = &lprocfs_server_fid_width_fops }, ++ { .name = "server", ++ .fops = &lprocfs_server_fid_server_fops }, + { NULL } + }; + +@@ -623,10 +626,14 @@ LPROC_SEQ_FOPS_RO(lprocfs_client_fid_server); + LPROC_SEQ_FOPS_RO(lprocfs_client_fid_fid); + + struct lprocfs_seq_vars seq_client_proc_list[] = { +- { "space", &lprocfs_client_fid_space_fops }, +- { "width", &lprocfs_client_fid_width_fops }, +- { "server", &lprocfs_client_fid_server_fops }, +- { "fid", &lprocfs_client_fid_fid_fops }, ++ { .name = "space", ++ .fops = &lprocfs_client_fid_space_fops }, ++ { .name = "width", ++ .fops = &lprocfs_client_fid_width_fops }, ++ { .name = "server", ++ .fops = &lprocfs_client_fid_server_fops }, ++ { .name = "fid", ++ .fops = &lprocfs_client_fid_fid_fops }, + { NULL } + }; + #endif +diff --git a/lustre/lmv/lproc_lmv.c b/lustre/lmv/lproc_lmv.c +index eea5927..5a7271a 100644 +--- a/lustre/lmv/lproc_lmv.c ++++ b/lustre/lmv/lproc_lmv.c +@@ -203,11 +203,16 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) + LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid); + + struct lprocfs_seq_vars lprocfs_lmv_obd_vars[] = { +- { "numobd", &lmv_numobd_fops }, +- { "placement", &lmv_placement_fops }, +- { "activeobd", &lmv_activeobd_fops }, +- { "uuid", &lmv_uuid_fops }, +- { "desc_uuid", &lmv_desc_uuid_fops }, ++ { .name = "numobd", ++ .fops = &lmv_numobd_fops }, ++ { .name = "placement", ++ .fops = &lmv_placement_fops }, ++ { .name = "activeobd", ++ .fops = &lmv_activeobd_fops }, ++ { .name = "uuid", ++ .fops = &lmv_uuid_fops }, ++ { .name = "desc_uuid", ++ .fops = &lmv_desc_uuid_fops }, + { 0 } + }; + +diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c +index e400faf..7786513 100644 +--- a/lustre/lov/lproc_lov.c ++++ b/lustre/lov/lproc_lov.c +@@ -263,20 +263,34 @@ LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree); + LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail); + + struct lprocfs_seq_vars lprocfs_lov_obd_vars[] = { +- { "uuid", &lov_uuid_fops }, +- { "stripesize", &lov_stripesize_fops }, +- { "stripeoffset", &lov_stripeoffset_fops }, +- { "stripecount", &lov_stripecount_fops }, +- { "stripetype", &lov_stripetype_fops }, +- { "numobd", &lov_numobd_fops }, +- { "activeobd", &lov_activeobd_fops }, +- { "filestotal", &lov_filestotal_fops }, +- { "filesfree", &lov_filesfree_fops }, +- { "blocksize", &lov_blksize_fops }, +- { "kbytestotal", &lov_kbytestotal_fops }, +- { "kbytesfree", &lov_kbytesfree_fops }, +- { "kbytesavail", &lov_kbytesavail_fops }, +- { "desc_uuid", &lov_desc_uuid_fops }, ++ { .name = "uuid", ++ .fops = &lov_uuid_fops }, ++ { .name = "stripesize", ++ .fops = &lov_stripesize_fops }, ++ { .name = "stripeoffset", ++ .fops = &lov_stripeoffset_fops }, ++ { .name = "stripecount", ++ .fops = &lov_stripecount_fops }, ++ { .name = "stripetype", ++ .fops = &lov_stripetype_fops }, ++ { .name = "numobd", ++ .fops = &lov_numobd_fops }, ++ { .name = "activeobd", ++ .fops = &lov_activeobd_fops }, ++ { .name = "filestotal", ++ .fops = &lov_filestotal_fops }, ++ { .name = "filesfree", ++ .fops = &lov_filesfree_fops }, ++ { .name = "blocksize", ++ .fops = &lov_blksize_fops }, ++ { .name = "kbytestotal", ++ .fops = &lov_kbytestotal_fops }, ++ { .name = "kbytesfree", ++ .fops = &lov_kbytesfree_fops }, ++ { .name = "kbytesavail", ++ .fops = &lov_kbytesavail_fops }, ++ { .name = "desc_uuid", ++ .fops = &lov_desc_uuid_fops }, + { 0 } + }; + +diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c +index cba4f61..69e377f 100644 +--- a/lustre/mdc/lproc_mdc.c ++++ b/lustre/mdc/lproc_mdc.c +@@ -103,29 +103,47 @@ LPROC_SEQ_FOPS_RW_TYPE(mdc, import); + LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); + + struct lprocfs_seq_vars lprocfs_mdc_obd_vars[] = { +- { "uuid", &mdc_uuid_fops, 0, 0 }, +- { "ping", &mdc_ping_fops, 0, 0222 }, +- { "connect_flags", &mdc_connect_flags_fops,0, 0 }, +- { "blocksize", &mdc_blksize_fops, 0, 0 }, +- { "kbytestotal", &mdc_kbytestotal_fops, 0, 0 }, +- { "kbytesfree", &mdc_kbytesfree_fops, 0, 0 }, +- { "kbytesavail", &mdc_kbytesavail_fops, 0, 0 }, +- { "filestotal", &mdc_filestotal_fops, 0, 0 }, +- { "filesfree", &mdc_filesfree_fops, 0, 0 }, +- { "mds_server_uuid", &mdc_server_uuid_fops, 0, 0 }, +- { "mds_conn_uuid", &mdc_conn_uuid_fops, 0, 0 }, ++ { .name = "uuid", ++ .fops = &mdc_uuid_fops }, ++ { .name = "ping", ++ .fops = &mdc_ping_fops, ++ .proc_mode = 0222 }, ++ { .name = "connect_flags", ++ .fops = &mdc_connect_flags_fops }, ++ { .name = "blocksize", ++ .fops = &mdc_blksize_fops }, ++ { .name = "kbytestotal", ++ .fops = &mdc_kbytestotal_fops }, ++ { .name = "kbytesfree", ++ .fops = &mdc_kbytesfree_fops }, ++ { .name = "kbytesavail", ++ .fops = &mdc_kbytesavail_fops }, ++ { .name = "filestotal", ++ .fops = &mdc_filestotal_fops }, ++ { .name = "filesfree", ++ .fops = &mdc_filesfree_fops }, ++ { .name = "mds_server_uuid", ++ .fops = &mdc_server_uuid_fops }, ++ { .name = "mds_conn_uuid", ++ .fops = &mdc_conn_uuid_fops }, + /* + * FIXME: below proc entry is provided, but not in used, instead + * sbi->sb_md_brw_size is used, the per obd variable should be used + * when CMD is enabled, and dir pages are managed in MDC layer. + * Remember to enable proc write function. + */ +- { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops }, +- { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops }, +- { "timeouts", &mdc_timeouts_fops }, +- { "import", &mdc_import_fops }, +- { "state", &mdc_state_fops }, +- { "pinger_recov", &mdc_pinger_recov_fops }, ++ { .name = "max_pages_per_rpc", ++ .fops = &mdc_obd_max_pages_per_rpc_fops }, ++ { .name = "max_rpcs_in_flight", ++ .fops = &mdc_max_rpcs_in_flight_fops }, ++ { .name = "timeouts", ++ .fops = &mdc_timeouts_fops }, ++ { .name = "import", ++ .fops = &mdc_import_fops }, ++ { .name = "state", ++ .fops = &mdc_state_fops }, ++ { .name = "pinger_recov", ++ .fops = &mdc_pinger_recov_fops }, + { 0 } + }; + #endif /* LPROCFS */ +diff --git a/lustre/mgc/lproc_mgc.c b/lustre/mgc/lproc_mgc.c +index 648b6e5..f818def 100644 +--- a/lustre/mgc/lproc_mgc.c ++++ b/lustre/mgc/lproc_mgc.c +@@ -59,14 +59,23 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) + LPROC_SEQ_FOPS_RO(mgc_ir_state); + + struct lprocfs_seq_vars lprocfs_mgc_obd_vars[] = { +- { "uuid", &mgc_uuid_fops, 0, 0 }, +- { "ping", &mgc_ping_fops, 0, 0222 }, +- { "connect_flags", &mgc_connect_flags_fops,0, 0 }, +- { "mgs_server_uuid", &mgc_server_uuid_fops, 0, 0 }, +- { "mgs_conn_uuid", &mgc_conn_uuid_fops, 0, 0 }, +- { "import", &mgc_import_fops, 0, 0 }, +- { "state", &mgc_state_fops, 0, 0 }, +- { "ir_state", &mgc_ir_state_fops, 0, 0 }, ++ { .name = "uuid", ++ .fops = &mgc_uuid_fops }, ++ { .name = "ping", ++ .fops = &mgc_ping_fops, ++ .proc_mode = 0222 }, ++ { .name = "connect_flags", ++ .fops = &mgc_connect_flags_fops }, ++ { .name = "mgs_server_uuid", ++ .fops = &mgc_server_uuid_fops }, ++ { .name = "mgs_conn_uuid", ++ .fops = &mgc_conn_uuid_fops }, ++ { .name = "import", ++ .fops = &mgc_import_fops }, ++ { .name = "state", ++ .fops = &mgc_state_fops }, ++ { .name = "ir_state", ++ .fops = &mgc_ir_state_fops }, + { 0 } + }; + #endif /* LPROCFS */ +diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c +index f9cb944..abe5d71 100644 +--- a/lustre/obdclass/lprocfs_status.c ++++ b/lustre/obdclass/lprocfs_status.c +@@ -2581,7 +2581,6 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) + EXPORT_SYMBOL(lprocfs_init_ldlm_stats); + + #ifdef HAVE_SERVER_SUPPORT +-/* No one appears to be using this ?? */ + int lprocfs_exp_nid_seq_show(struct seq_file *m, void *data) + { + struct obd_export *exp = m->private; +diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c +index 6d63aff..8563e68 100644 +--- a/lustre/obdecho/echo.c ++++ b/lustre/obdecho/echo.c +@@ -561,7 +561,8 @@ commitrw_cleanup: + + LPROC_SEQ_FOPS_RO_TYPE(echo, uuid); + static struct lprocfs_seq_vars lprocfs_echo_obd_vars[] = { +- { "uuid", &echo_uuid_fops }, ++ { .name = "uuid", ++ .fops = &echo_uuid_fops }, + { 0 } + }; + +diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c +index d6e3703..ccfc212 100644 +--- a/lustre/osc/lproc_osc.c ++++ b/lustre/osc/lproc_osc.c +@@ -543,37 +543,69 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import); + LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); + + struct lprocfs_seq_vars lprocfs_osc_obd_vars[] = { +- { "uuid", &osc_uuid_fops }, +- { "ping", &osc_ping_fops, 0, 0222 }, +- { "connect_flags", &osc_connect_flags_fops }, +- { "blocksize", &osc_blksize_fops }, +- { "kbytestotal", &osc_kbytestotal_fops }, +- { "kbytesfree", &osc_kbytesfree_fops }, +- { "kbytesavail", &osc_kbytesavail_fops }, +- { "filestotal", &osc_filestotal_fops }, +- { "filesfree", &osc_filesfree_fops }, +- { "ost_server_uuid", &osc_server_uuid_fops }, +- { "ost_conn_uuid", &osc_conn_uuid_fops }, +- { "active", &osc_active_fops }, +- { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops }, +- { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops }, +- { "destroys_in_flight", &osc_destroys_in_flight_fops }, +- { "max_dirty_mb", &osc_max_dirty_mb_fops }, +- { "osc_cached_mb", &osc_cached_mb_fops }, +- { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops }, +- { "cur_grant_bytes", &osc_cur_grant_bytes_fops }, +- { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops }, +- { "grant_shrink_interval", &osc_grant_shrink_interval_fops }, +- { "checksums", &osc_checksum_fops }, +- { "checksum_type", &osc_checksum_type_fops }, +- { "resend_count", &osc_resend_count_fops }, +- { "timeouts", &osc_timeouts_fops }, +- { "contention_seconds", &osc_contention_seconds_fops }, +- { "lockless_truncate", &osc_lockless_truncate_fops }, +- { "import", &osc_import_fops }, +- { "state", &osc_state_fops }, +- { "pinger_recov", &osc_pinger_recov_fops }, +- { "unstable_stats", &osc_unstable_stats_fops }, ++ { .name = "uuid", ++ .fops = &osc_uuid_fops }, ++ { .name = "ping", ++ .fops = &osc_ping_fops, ++ .proc_mode = 0222 }, ++ { .name = "connect_flags", ++ .fops = &osc_connect_flags_fops }, ++ { .name = "blocksize", ++ .fops = &osc_blksize_fops }, ++ { .name = "kbytestotal", ++ .fops = &osc_kbytestotal_fops }, ++ { .name = "kbytesfree", ++ .fops = &osc_kbytesfree_fops }, ++ { .name = "kbytesavail", ++ .fops = &osc_kbytesavail_fops }, ++ { .name = "filestotal", ++ .fops = &osc_filestotal_fops }, ++ { .name = "filesfree", ++ .fops = &osc_filesfree_fops }, ++ { .name = "ost_server_uuid", ++ .fops = &osc_server_uuid_fops }, ++ { .name = "ost_conn_uuid", ++ .fops = &osc_conn_uuid_fops }, ++ { .name = "active", ++ .fops = &osc_active_fops }, ++ { .name = "max_pages_per_rpc", ++ .fops = &osc_obd_max_pages_per_rpc_fops }, ++ { .name = "max_rpcs_in_flight", ++ .fops = &osc_max_rpcs_in_flight_fops }, ++ { .name = "destroys_in_flight", ++ .fops = &osc_destroys_in_flight_fops }, ++ { .name = "max_dirty_mb", ++ .fops = &osc_max_dirty_mb_fops }, ++ { .name = "osc_cached_mb", ++ .fops = &osc_cached_mb_fops }, ++ { .name = "cur_dirty_bytes", ++ .fops = &osc_cur_dirty_bytes_fops }, ++ { .name = "cur_grant_bytes", ++ .fops = &osc_cur_grant_bytes_fops }, ++ { .name = "cur_lost_grant_bytes", ++ .fops = &osc_cur_lost_grant_bytes_fops }, ++ { .name = "grant_shrink_interval", ++ .fops = &osc_grant_shrink_interval_fops }, ++ { .name = "checksums", ++ .fops = &osc_checksum_fops }, ++ { .name = "checksum_type", ++ .fops = &osc_checksum_type_fops }, ++ { .name = "resend_count", ++ .fops = &osc_resend_count_fops }, ++ { .name = "timeouts", ++ .fops = &osc_timeouts_fops }, ++ { .name = "contention_seconds", ++ .fops = &osc_contention_seconds_fops }, ++ { .name = "lockless_truncate", ++ .fops = &osc_lockless_truncate_fops }, ++ { .name = "import", ++ .fops = &osc_import_fops }, ++ { .name = "state", ++ .fops = &osc_state_fops }, ++ { .name = "pinger_recov", ++ .fops = &osc_pinger_recov_fops }, ++ { .name = "unstable_stats", ++ .fops = &osc_unstable_stats_fops }, + { 0 } + }; + +diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c +index b9d1b71..f95fb55 100644 +--- a/lustre/osc/osc_request.c ++++ b/lustre/osc/osc_request.c +@@ -3669,7 +3669,7 @@ int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) + { + int rc = class_process_proc_seq_param(PARAM_OSC, obd->obd_vars, + lcfg, obd); +- return(rc > 0 ? 0: rc); ++ return rc > 0 ? 0: rc; + } + + static int osc_process_config(struct obd_device *obd, obd_count len, void *buf) +diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c +index d4da00d..d20a30f 100644 +--- a/lustre/ost/ost_handler.c ++++ b/lustre/ost/ost_handler.c +@@ -75,7 +75,8 @@ static struct cfs_cpt_table *ost_io_cptable; + LPROC_SEQ_FOPS_RO_TYPE(ost, uuid); + + static struct lprocfs_seq_vars lprocfs_ost_obd_vars[] = { +- { "uuid", &ost_uuid_fops }, ++ { .name = "uuid", ++ .fops = &ost_uuid_fops }, + { 0 } + }; + #endif /* LPROCFS */ +diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c +index 8e5a397..bf21958 100644 +--- a/lustre/ptlrpc/lproc_ptlrpc.c ++++ b/lustre/ptlrpc/lproc_ptlrpc.c +@@ -1382,7 +1382,7 @@ lprocfs_import_seq_write(struct file *file, const char *buffer, size_t count, + + *ptr = 0; + do_reconn = 0; +- ptr += strlen("::"); ++ ptr += 2; /* Skip :: */ + inst = simple_strtol(ptr, &endptr, 10); + if (*endptr) { + CERROR("config: wrong instance # %s\n", ptr); +diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c +index afd450c..df6d6fc 100644 +--- a/lustre/quota/qmt_pool.c ++++ b/lustre/quota/qmt_pool.c +@@ -171,7 +171,8 @@ static int qpi_state_seq_show(struct seq_file *m, void *data) + LPROC_SEQ_FOPS_RO(qpi_state); + + static struct lprocfs_seq_vars lprocfs_quota_qpi_vars[] = { +- { "info", &qpi_state_fops }, ++ { .name = "info", ++ .fops = &qpi_state_fops }, + { NULL } + }; + +diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c +index 990cfee..573473c 100644 +--- a/lustre/quota/qsd_lib.c ++++ b/lustre/quota/qsd_lib.c +@@ -208,10 +208,14 @@ qsd_timeout_seq_write(struct file *file, const char *buffer, + LPROC_SEQ_FOPS(qsd_timeout); + + static struct lprocfs_seq_vars lprocfs_quota_qsd_vars[] = { +- { "info", &qsd_state_fops }, +- { "enabled", &qsd_enabled_fops }, +- { "force_reint", &qsd_force_reint_fops }, +- { "timeout", &qsd_timeout_fops }, ++ { .name = "info", ++ .fops = &qsd_state_fops }, ++ { .name = "enabled", ++ .fops = &qsd_enabled_fops }, ++ { .name = "force_reint", ++ .fops = &qsd_force_reint_fops }, ++ { .name = "timeout", ++ .fops = &qsd_timeout_fops }, + { NULL } + }; + +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0010-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch b/sys-cluster/lustre/files/0010-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch deleted file mode 100644 index 0be7f2aaf..000000000 --- a/sys-cluster/lustre/files/0010-LU-3319-procfs-update-ldiskfs-proc-handling-to-seq_f.patch +++ /dev/null @@ -1,807 +0,0 @@ -From adf3be9fe382564c4760b83a5843b7d5502bbe48 Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Sun, 9 Feb 2014 10:45:37 -0500 -Subject: [PATCH 10/13] LU-3319 procfs: update ldiskfs proc handling to - seq_files - -Migrate all ldiskfs proc handling to using strictly -seq_files. Also include a fix with newer gcc complaining -certain variables are initialized. - -Signed-off-by: James Simmons -Change-Id: Ia296a4682e2feda02bcfbe0100de8a89404cd731 ---- - lustre/osd-ldiskfs/osd_compat.c | 6 +- - lustre/osd-ldiskfs/osd_handler.c | 16 +- - lustre/osd-ldiskfs/osd_internal.h | 6 +- - lustre/osd-ldiskfs/osd_lproc.c | 336 ++++++++++++++++++++------------------ - lustre/osd-ldiskfs/osd_scrub.c | 73 +++------ - 5 files changed, 220 insertions(+), 217 deletions(-) - -diff --git a/lustre/osd-ldiskfs/osd_compat.c b/lustre/osd-ldiskfs/osd_compat.c -index b4a018c..6ca1304 100644 ---- a/lustre/osd-ldiskfs/osd_compat.c -+++ b/lustre/osd-ldiskfs/osd_compat.c -@@ -1168,7 +1168,7 @@ int osd_obj_spec_update(struct osd_thread_info *info, struct osd_device *osd, - handle_t *th) - { - struct dentry *root; -- char *name; -+ char *name = NULL; - int rc; - ENTRY; - -@@ -1189,7 +1189,7 @@ int osd_obj_spec_insert(struct osd_thread_info *info, struct osd_device *osd, - handle_t *th) - { - struct dentry *root; -- char *name; -+ char *name = NULL; - int rc; - ENTRY; - -@@ -1211,7 +1211,7 @@ int osd_obj_spec_lookup(struct osd_thread_info *info, struct osd_device *osd, - struct dentry *root; - struct dentry *dentry; - struct inode *inode; -- char *name; -+ char *name = NULL; - int rc = -ENOENT; - ENTRY; - -diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c -index 9027533..dfaa542 100644 ---- a/lustre/osd-ldiskfs/osd_handler.c -+++ b/lustre/osd-ldiskfs/osd_handler.c -@@ -5814,6 +5814,7 @@ static struct lu_device *osd_device_free(const struct lu_env *env, - static int osd_process_config(const struct lu_env *env, - struct lu_device *d, struct lustre_cfg *cfg) - { -+ struct obd_device *obd = d->ld_obd; - struct osd_device *o = osd_dev(d); - int rc; - ENTRY; -@@ -5828,12 +5829,12 @@ static int osd_process_config(const struct lu_env *env, - break; - case LCFG_PARAM: - LASSERT(&o->od_dt_dev); -- rc = class_process_proc_param(PARAM_OSD, lprocfs_osd_obd_vars, -- cfg, &o->od_dt_dev); -+ rc = class_process_proc_seq_param(PARAM_OSD, obd->obd_vars, -+ cfg, &o->od_dt_dev); - if (rc > 0 || rc == -ENOSYS) -- rc = class_process_proc_param(PARAM_OST, -- lprocfs_osd_obd_vars, -- cfg, &o->od_dt_dev); -+ rc = class_process_proc_seq_param(PARAM_OST, -+ obd->obd_vars, cfg, -+ &o->od_dt_dev); - break; - default: - rc = -ENOSYS; -@@ -5981,9 +5982,10 @@ static int __init osd_mod_init(void) - if (rc) - return rc; - -- rc = class_register_type(&osd_obd_device_ops, NULL, NULL, --#ifndef HAVE_ONLY_PROCFS_SEQ -+ rc = class_register_type(&osd_obd_device_ops, NULL, - lprocfs_osd_module_vars, -+#ifndef HAVE_ONLY_PROCFS_SEQ -+ NULL, - #endif - LUSTRE_OSD_LDISKFS_NAME, &osd_device_type); - if (rc) -diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h -index 8436d1f..c90147f 100644 ---- a/lustre/osd-ldiskfs/osd_internal.h -+++ b/lustre/osd-ldiskfs/osd_internal.h -@@ -623,8 +623,8 @@ static inline int __osd_xattr_set(struct osd_thread_info *info, - - #ifdef LPROCFS - /* osd_lproc.c */ --extern struct lprocfs_vars lprocfs_osd_obd_vars[]; --extern struct lprocfs_vars lprocfs_osd_module_vars[]; -+extern struct lprocfs_seq_vars lprocfs_osd_obd_vars[]; -+extern struct lprocfs_seq_vars lprocfs_osd_module_vars[]; - int osd_procfs_init(struct osd_device *osd, const char *name); - int osd_procfs_fini(struct osd_device *osd); - void osd_brw_stats_update(struct osd_device *osd, struct osd_iobuf *iobuf); -@@ -679,7 +679,7 @@ int osd_oii_insert(struct osd_device *dev, struct osd_idmap_cache *oic, - int insert); - int osd_oii_lookup(struct osd_device *dev, const struct lu_fid *fid, - struct osd_inode_id *id); --int osd_scrub_dump(struct osd_device *dev, char *buf, int len); -+int osd_scrub_dump(struct seq_file *m, struct osd_device *dev); - - int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd, - obd_seq seq, struct lu_seq_range *range); -diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c -index b9b4e3d..947a4b9 100644 ---- a/lustre/osd-ldiskfs/osd_lproc.c -+++ b/lustre/osd-ldiskfs/osd_lproc.c -@@ -237,92 +237,46 @@ out: - RETURN(result); - } - --int osd_procfs_init(struct osd_device *osd, const char *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_OSD_LDISKFS_NAME); -- -- LASSERT(name != NULL); -- LASSERT(type != NULL); -- -- /* Find the type procroot and add the proc entry for this device */ -- osd->od_proc_entry = lprocfs_register(name, type->typ_procroot, -- lprocfs_osd_obd_vars, -- &osd->od_dt_dev); -- if (IS_ERR(osd->od_proc_entry)) { -- rc = PTR_ERR(osd->od_proc_entry); -- CERROR("Error %d setting up lprocfs for %s\n", -- rc, name); -- osd->od_proc_entry = NULL; -- GOTO(out, rc); -- } -- -- rc = osd_stats_init(osd); -- -- EXIT; --out: -- if (rc) -- osd_procfs_fini(osd); -- return rc; --} -- --int osd_procfs_fini(struct osd_device *osd) --{ -- if (osd->od_stats) -- lprocfs_free_stats(&osd->od_stats); -- -- if (osd->od_proc_entry) { -- lprocfs_remove(&osd->od_proc_entry); -- osd->od_proc_entry = NULL; -- } -- RETURN(0); --} -- --static int lprocfs_osd_rd_fstype(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int ldiskfs_osd_fstype_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *osd = osd_dt_dev(data); -+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); - -- LASSERT(osd != NULL); -- return snprintf(page, count, "ldiskfs\n"); -+ LASSERT(osd != NULL); -+ return seq_printf(m, "ldiskfs\n"); - } -+LPROC_SEQ_FOPS_RO(ldiskfs_osd_fstype); - --static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int ldiskfs_osd_mntdev_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *osd = osd_dt_dev(data); -+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); - -- LASSERT(osd != NULL); -+ LASSERT(osd != NULL); - if (unlikely(osd->od_mnt == NULL)) -- return -EINPROGRESS; -- -- *eof = 1; -+ return -EINPROGRESS; - -- return snprintf(page, count, "%s\n", osd->od_mntdev); -+ return seq_printf(m, "%u\n", osd->od_read_cache); - } -+LPROC_SEQ_FOPS_RO(ldiskfs_osd_mntdev); - --static int lprocfs_osd_rd_cache(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int ldiskfs_osd_cache_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *osd = osd_dt_dev(data); -+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); - - LASSERT(osd != NULL); - if (unlikely(osd->od_mnt == NULL)) - return -EINPROGRESS; - -- return snprintf(page, count, "%u\n", osd->od_read_cache); -+ return seq_printf(m, "%u\n", osd->od_read_cache); - } - --static int lprocfs_osd_wr_cache(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+ldiskfs_osd_cache_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct osd_device *osd = osd_dt_dev(data); -- int val, rc; -+ struct seq_file *m = file->private_data; -+ struct dt_device *dt = m->private; -+ struct osd_device *osd = osd_dt_dev(dt); -+ int val, rc; - - LASSERT(osd != NULL); - if (unlikely(osd->od_mnt == NULL)) -@@ -335,24 +289,26 @@ static int lprocfs_osd_wr_cache(struct file *file, const char *buffer, - osd->od_read_cache = !!val; - return count; - } -+LPROC_SEQ_FOPS(ldiskfs_osd_cache); - --static int lprocfs_osd_rd_wcache(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int ldiskfs_osd_wcache_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *osd = osd_dt_dev(data); -+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); - - LASSERT(osd != NULL); - if (unlikely(osd->od_mnt == NULL)) - return -EINPROGRESS; - -- return snprintf(page, count, "%u\n", osd->od_writethrough_cache); -+ return seq_printf(m, "%u\n", osd->od_writethrough_cache); - } - --static int lprocfs_osd_wr_wcache(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+ldiskfs_osd_wcache_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct osd_device *osd = osd_dt_dev(data); -- int val, rc; -+ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; -+ struct osd_device *osd = osd_dt_dev(dt); -+ int val, rc; - - LASSERT(osd != NULL); - if (unlikely(osd->od_mnt == NULL)) -@@ -365,14 +321,16 @@ static int lprocfs_osd_wr_wcache(struct file *file, const char *buffer, - osd->od_writethrough_cache = !!val; - return count; - } -+LPROC_SEQ_FOPS(ldiskfs_osd_wcache); - --static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+lprocfs_osd_force_sync_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct osd_device *osd = osd_dt_dev(data); -- struct dt_device *dt = data; -- struct lu_env env; -- int rc; -+ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; -+ struct osd_device *osd = osd_dt_dev(dt); -+ struct lu_env env; -+ int rc; - - LASSERT(osd != NULL); - if (unlikely(osd->od_mnt == NULL)) -@@ -386,20 +344,18 @@ static int lprocfs_osd_wr_force_sync(struct file *file, const char *buffer, - - return rc == 0 ? count : rc; - } -+LPROC_SEQ_FOPS_WO_TYPE(ldiskfs, osd_force_sync); - --static int lprocfs_osd_rd_pdo(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+static int ldiskfs_osd_pdo_seq_show(struct seq_file *m, void *data) - { -- *eof = 1; -- -- return snprintf(page, count, "%s\n", ldiskfs_pdo ? "ON" : "OFF"); -+ return seq_printf(m, "%s\n", ldiskfs_pdo ? "ON" : "OFF"); - } - --static int lprocfs_osd_wr_pdo(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+ldiskfs_osd_pdo_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- int pdo; -- int rc; -+ int pdo, rc; - - rc = lprocfs_write_helper(buffer, count, &pdo); - if (rc != 0) -@@ -409,24 +365,25 @@ static int lprocfs_osd_wr_pdo(struct file *file, const char *buffer, - - return count; - } -+LPROC_SEQ_FOPS(ldiskfs_osd_pdo); - --static int lprocfs_osd_rd_auto_scrub(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int ldiskfs_osd_auto_scrub_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *dev = osd_dt_dev(data); -+ struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private); - - LASSERT(dev != NULL); - if (unlikely(dev->od_mnt == NULL)) - return -EINPROGRESS; - -- *eof = 1; -- return snprintf(page, count, "%d\n", !dev->od_noscrub); -+ return seq_printf(m, "%d\n", !dev->od_noscrub); - } - --static int lprocfs_osd_wr_auto_scrub(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+ldiskfs_osd_auto_scrub_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct osd_device *dev = osd_dt_dev(data); -+ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; -+ struct osd_device *dev = osd_dt_dev(dt); - int val, rc; - - LASSERT(dev != NULL); -@@ -440,19 +397,18 @@ static int lprocfs_osd_wr_auto_scrub(struct file *file, const char *buffer, - dev->od_noscrub = !val; - return count; - } -+LPROC_SEQ_FOPS(ldiskfs_osd_auto_scrub); - --static int lprocfs_osd_rd_track_declares_assert(char *page, char **start, -- off_t off, int count, -- int *eof, void *data) -+static int -+ldiskfs_osd_track_declares_assert_seq_show(struct seq_file *m, void *data) - { -- *eof = 1; -- -- return snprintf(page, count, "%d\n", ldiskfs_track_declares_assert); -+ return seq_printf(m, "%d\n", ldiskfs_track_declares_assert); - } - --static int lprocfs_osd_wr_track_declares_assert(struct file *file, -+static ssize_t -+ldiskfs_osd_track_declares_assert_seq_write(struct file *file, - const char *buffer, -- unsigned long count, void *data) -+ size_t count, loff_t *off) - { - int track_declares_assert; - int rc; -@@ -465,38 +421,39 @@ static int lprocfs_osd_wr_track_declares_assert(struct file *file, - - return count; - } -+LPROC_SEQ_FOPS(ldiskfs_osd_track_declares_assert); -+ -+extern int osd_scrub_dump(struct seq_file *m, struct osd_device *dev); - --static int lprocfs_osd_rd_oi_scrub(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int ldiskfs_osd_oi_scrub_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *dev = osd_dt_dev(data); -+ struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private); - - LASSERT(dev != NULL); - if (unlikely(dev->od_mnt == NULL)) - return -EINPROGRESS; - -- *eof = 1; -- return osd_scrub_dump(dev, page, count); -+ return osd_scrub_dump(m, dev); - } -+LPROC_SEQ_FOPS_RO(ldiskfs_osd_oi_scrub); - --int lprocfs_osd_rd_readcache(char *page, char **start, off_t off, int count, -- int *eof, void *data) -+int ldiskfs_osd_readcache_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *osd = osd_dt_dev(data); -- int rc; -+ struct osd_device *osd = osd_dt_dev((struct dt_device *)m->private); - - LASSERT(osd != NULL); - if (unlikely(osd->od_mnt == NULL)) - return -EINPROGRESS; - -- rc = snprintf(page, count, LPU64"\n", osd->od_readcache_max_filesize); -- return rc; -+ return seq_printf(m, LPU64"\n", osd->od_readcache_max_filesize); - } - --int lprocfs_osd_wr_readcache(struct file *file, const char *buffer, -- unsigned long count, void *data) -+ssize_t -+ldiskfs_osd_readcache_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct osd_device *osd = osd_dt_dev(data); -+ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; -+ struct osd_device *osd = osd_dt_dev(dt); - __u64 val; - int rc; - -@@ -512,24 +469,25 @@ int lprocfs_osd_wr_readcache(struct file *file, const char *buffer, - OSD_MAX_CACHE_SIZE : val; - return count; - } -+LPROC_SEQ_FOPS(ldiskfs_osd_readcache); - --static int lprocfs_osd_rd_lma_self_repair(char *page, char **start, off_t off, -- int count, int *eof, void *data) -+static int ldiskfs_osd_lma_self_repair_seq_show(struct seq_file *m, void *data) - { -- struct osd_device *dev = osd_dt_dev(data); -+ struct osd_device *dev = osd_dt_dev((struct dt_device *)m->private); - - LASSERT(dev != NULL); - if (unlikely(dev->od_mnt == NULL)) - return -EINPROGRESS; - -- *eof = 1; -- return snprintf(page, count, "%d\n", !!dev->od_lma_self_repair); -+ return seq_printf(m, "%d\n", !!dev->od_lma_self_repair); - } - --static int lprocfs_osd_wr_lma_self_repair(struct file *file, const char *buffer, -- unsigned long count, void *data) -+static ssize_t -+ldiskfs_osd_lma_self_repair_seq_write(struct file *file, const char *buffer, -+ size_t count, loff_t *off) - { -- struct osd_device *dev = osd_dt_dev(data); -+ struct dt_device *dt = ((struct seq_file *)file->private_data)->private; -+ struct osd_device *dev = osd_dt_dev(dt); - int val; - int rc; - -@@ -544,38 +502,102 @@ static int lprocfs_osd_wr_lma_self_repair(struct file *file, const char *buffer, - dev->od_lma_self_repair = !!val; - return count; - } -- --struct lprocfs_vars lprocfs_osd_obd_vars[] = { -- { "blocksize", lprocfs_dt_rd_blksize, 0, 0 }, -- { "kbytestotal", lprocfs_dt_rd_kbytestotal, 0, 0 }, -- { "kbytesfree", lprocfs_dt_rd_kbytesfree, 0, 0 }, -- { "kbytesavail", lprocfs_dt_rd_kbytesavail, 0, 0 }, -- { "filestotal", lprocfs_dt_rd_filestotal, 0, 0 }, -- { "filesfree", lprocfs_dt_rd_filesfree, 0, 0 }, -- { "fstype", lprocfs_osd_rd_fstype, 0, 0 }, -- { "mntdev", lprocfs_osd_rd_mntdev, 0, 0 }, -- { "force_sync", 0, lprocfs_osd_wr_force_sync }, -- { "pdo", lprocfs_osd_rd_pdo, lprocfs_osd_wr_pdo, 0 }, -- { "auto_scrub", lprocfs_osd_rd_auto_scrub, -- lprocfs_osd_wr_auto_scrub, 0 }, -- { "oi_scrub", lprocfs_osd_rd_oi_scrub, 0, 0 }, -- { "force_sync", 0, lprocfs_osd_wr_force_sync }, -- { "read_cache_enable", lprocfs_osd_rd_cache, lprocfs_osd_wr_cache, 0 }, -- { "writethrough_cache_enable", lprocfs_osd_rd_wcache, -- lprocfs_osd_wr_wcache, 0 }, -- { "readcache_max_filesize", lprocfs_osd_rd_readcache, -- lprocfs_osd_wr_readcache, 0 }, -- { "lma_self_repair", lprocfs_osd_rd_lma_self_repair, -- lprocfs_osd_wr_lma_self_repair, 0, 0 }, -+LPROC_SEQ_FOPS(ldiskfs_osd_lma_self_repair); -+ -+LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_blksize); -+LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytestotal); -+LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytesfree); -+LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_kbytesavail); -+LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_filestotal); -+LPROC_SEQ_FOPS_RO_TYPE(ldiskfs, dt_filesfree); -+ -+struct lprocfs_seq_vars lprocfs_osd_obd_vars[] = { -+ { .name = "blocksize", -+ .fops = &ldiskfs_dt_blksize_fops }, -+ { .name = "kbytestotal", -+ .fops = &ldiskfs_dt_kbytestotal_fops }, -+ { .name = "kbytesfree", -+ .fops = &ldiskfs_dt_kbytesfree_fops }, -+ { .name = "kbytesavail", -+ .fops = &ldiskfs_dt_kbytesavail_fops }, -+ { .name = "filestotal", -+ .fops = &ldiskfs_dt_filestotal_fops }, -+ { .name = "filesfree", -+ .fops = &ldiskfs_dt_filesfree_fops }, -+ { .name = "fstype", -+ .fops = &ldiskfs_osd_fstype_fops }, -+ { .name = "mntdev", -+ .fops = &ldiskfs_osd_mntdev_fops }, -+ { .name = "force_sync", -+ .fops = &ldiskfs_osd_force_sync_fops }, -+ { .name = "pdo", -+ .fops = &ldiskfs_osd_pdo_fops }, -+ { .name = "auto_scrub", -+ .fops = &ldiskfs_osd_auto_scrub_fops }, -+ { .name = "oi_scrub", -+ .fops = &ldiskfs_osd_oi_scrub_fops }, -+ { .name = "read_cache_enable", -+ .fops = &ldiskfs_osd_cache_fops }, -+ { .name = "writethrough_cache_enable", -+ .fops = &ldiskfs_osd_wcache_fops }, -+ { .name = "readcache_max_filesize", -+ .fops = &ldiskfs_osd_readcache_fops }, -+ { .name = "lma_self_repair", -+ .fops = &ldiskfs_osd_lma_self_repair_fops }, - { 0 } - }; - --struct lprocfs_vars lprocfs_osd_module_vars[] = { -- { "num_refs", lprocfs_rd_numrefs, 0, 0 }, -- { "track_declares_assert", lprocfs_osd_rd_track_declares_assert, -- lprocfs_osd_wr_track_declares_assert, -- 0 }, -- { 0 } -+struct lprocfs_seq_vars lprocfs_osd_module_vars[] = { -+ { .name = "track_declares_assert", -+ .fops = &ldiskfs_osd_track_declares_assert_fops }, -+ { 0 } - }; - -+ -+int osd_procfs_init(struct osd_device *osd, const char *name) -+{ -+ struct obd_type *type; -+ int rc; -+ ENTRY; -+ -+ if (osd->od_proc_entry) -+ RETURN(0); -+ -+ /* 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_OSD_LDISKFS_NAME); -+ -+ LASSERT(name != NULL); -+ LASSERT(type != NULL); -+ -+ /* Find the type procroot and add the proc entry for this device */ -+ osd->od_proc_entry = lprocfs_seq_register(name, type->typ_procroot, -+ lprocfs_osd_obd_vars, -+ &osd->od_dt_dev); -+ if (IS_ERR(osd->od_proc_entry)) { -+ rc = PTR_ERR(osd->od_proc_entry); -+ CERROR("Error %d setting up lprocfs for %s\n", -+ rc, name); -+ osd->od_proc_entry = NULL; -+ GOTO(out, rc); -+ } -+ -+ rc = osd_stats_init(osd); -+ -+ EXIT; -+out: -+ if (rc) -+ osd_procfs_fini(osd); -+ return rc; -+} -+ -+int osd_procfs_fini(struct osd_device *osd) -+{ -+ if (osd->od_stats) -+ lprocfs_free_stats(&osd->od_stats); -+ -+ if (osd->od_proc_entry) -+ lprocfs_remove(&osd->od_proc_entry); -+ RETURN(0); -+} - #endif -diff --git a/lustre/osd-ldiskfs/osd_scrub.c b/lustre/osd-ldiskfs/osd_scrub.c -index cce33af..1002913 100644 ---- a/lustre/osd-ldiskfs/osd_scrub.c -+++ b/lustre/osd-ldiskfs/osd_scrub.c -@@ -2578,80 +2578,69 @@ static const char *scrub_param_names[] = { - NULL - }; - --static int scrub_bits_dump(char **buf, int *len, int bits, const char *names[], -+static int scrub_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'); -+ rc = seq_printf(m, "%s:%c", prefix, bits != 0 ? ' ' : '\n'); - if (rc <= 0) - return -ENOSPC; - -- *buf += rc; -- *len -= rc; - for (i = 0, flag = 1; bits != 0; i++, flag = 1 << i) { - if (flag & bits) { - bits &= ~flag; -- rc = snprintf(*buf, *len, "%s%c", names[i], -- bits != 0 ? ',' : '\n'); -+ rc = seq_printf(m, "%s%c", names[i], -+ bits != 0 ? ',' : '\n'); - if (rc <= 0) - return -ENOSPC; -- -- *buf += rc; -- *len -= rc; - } - } -- return save - *len; -+ return 0; - } - --static int scrub_time_dump(char **buf, int *len, __u64 time, const char *prefix) -+static int scrub_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, -+ rc = seq_printf(m, "%s: "LPU64" seconds\n", prefix, - cfs_time_current_sec() - time); - else -- rc = snprintf(*buf, *len, "%s: N/A\n", prefix); -+ rc = seq_printf(m, "%s: N/A\n", prefix); - if (rc <= 0) - return -ENOSPC; - -- *buf += rc; -- *len -= rc; -- return rc; -+ return 0; - } - --static int scrub_pos_dump(char **buf, int *len, __u64 pos, const char *prefix) -+static int scrub_pos_dump(struct seq_file *m, __u64 pos, const char *prefix) - { - int rc; - - if (pos != 0) -- rc = snprintf(*buf, *len, "%s: "LPU64"\n", prefix, pos); -+ rc = seq_printf(m, "%s: "LPU64"\n", prefix, pos); - else -- rc = snprintf(*buf, *len, "%s: N/A\n", prefix); -+ rc = seq_printf(m, "%s: N/A\n", prefix); - if (rc <= 0) - return -ENOSPC; - -- *buf += rc; -- *len -= rc; - return rc; - } - --int osd_scrub_dump(struct osd_device *dev, char *buf, int len) -+int osd_scrub_dump(struct seq_file *m,struct osd_device *dev) - { - struct osd_scrub *scrub = &dev->od_scrub; - struct scrub_file *sf = &scrub->os_file; - __u64 checked; - __u64 speed; -- int save = len; - int ret = -ENOSPC; - int rc; - - down_read(&scrub->os_rwsem); -- rc = snprintf(buf, len, -+ rc = seq_printf(m, - "name: OI_scrub\n" - "magic: 0x%x\n" - "oi_files: %d\n" -@@ -2661,51 +2650,48 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) - if (rc <= 0) - goto out; - -- buf += rc; -- len -= rc; -- rc = scrub_bits_dump(&buf, &len, sf->sf_flags, scrub_flags_names, -+ rc = scrub_bits_dump(m, sf->sf_flags, scrub_flags_names, - "flags"); - if (rc < 0) - goto out; - -- rc = scrub_bits_dump(&buf, &len, sf->sf_param, scrub_param_names, -+ rc = scrub_bits_dump(m, sf->sf_param, scrub_param_names, - "param"); - if (rc < 0) - goto out; - -- rc = scrub_time_dump(&buf, &len, sf->sf_time_last_complete, -+ rc = scrub_time_dump(m, sf->sf_time_last_complete, - "time_since_last_completed"); - if (rc < 0) - goto out; - -- rc = scrub_time_dump(&buf, &len, sf->sf_time_latest_start, -+ rc = scrub_time_dump(m, sf->sf_time_latest_start, - "time_since_latest_start"); - if (rc < 0) - goto out; - -- rc = scrub_time_dump(&buf, &len, sf->sf_time_last_checkpoint, -+ rc = scrub_time_dump(m, sf->sf_time_last_checkpoint, - "time_since_last_checkpoint"); - if (rc < 0) - goto out; - -- rc = scrub_pos_dump(&buf, &len, sf->sf_pos_latest_start, -+ rc = scrub_pos_dump(m, sf->sf_pos_latest_start, - "latest_start_position"); - if (rc < 0) - goto out; - -- rc = scrub_pos_dump(&buf, &len, sf->sf_pos_last_checkpoint, -+ rc = scrub_pos_dump(m, sf->sf_pos_last_checkpoint, - "last_checkpoint_position"); - if (rc < 0) - goto out; - -- rc = scrub_pos_dump(&buf, &len, sf->sf_pos_first_inconsistent, -+ rc = scrub_pos_dump(m, sf->sf_pos_first_inconsistent, - "first_failure_position"); - if (rc < 0) - goto out; - - checked = sf->sf_items_checked + scrub->os_new_checked; -- rc = snprintf(buf, len, -- "checked: "LPU64"\n" -+ rc = seq_printf(m, "checked: "LPU64"\n" - "updated: "LPU64"\n" - "failed: "LPU64"\n" - "prior_updated: "LPU64"\n" -@@ -2718,8 +2704,6 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) - if (rc <= 0) - goto out; - -- buf += rc; -- len -= rc; - speed = checked; - if (thread_is_running(&scrub->os_thread)) { - cfs_duration_t duration = cfs_time_current() - -@@ -2732,8 +2716,7 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) - do_div(new_checked, duration); - if (rtime != 0) - do_div(speed, rtime); -- rc = snprintf(buf, len, -- "run_time: %u seconds\n" -+ rc = seq_printf(m, "run_time: %u seconds\n" - "average_speed: "LPU64" objects/sec\n" - "real-time_speed: "LPU64" objects/sec\n" - "current_position: %u\n" -@@ -2746,8 +2729,7 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) - } else { - if (sf->sf_run_time != 0) - do_div(speed, sf->sf_run_time); -- rc = snprintf(buf, len, -- "run_time: %u seconds\n" -+ rc = seq_printf(m, "run_time: %u seconds\n" - "average_speed: "LPU64" objects/sec\n" - "real-time_speed: N/A\n" - "current_position: N/A\n" -@@ -2759,10 +2741,7 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len) - } - if (rc <= 0) - goto out; -- -- buf += rc; -- len -= rc; -- ret = save - len; -+ ret = 0; - - out: - up_read(&scrub->os_rwsem); --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0011-LU-3319-lprocfs-client-side-cleanups.patch b/sys-cluster/lustre/files/0011-LU-3319-lprocfs-client-side-cleanups.patch deleted file mode 100644 index b3ff994d1..000000000 --- a/sys-cluster/lustre/files/0011-LU-3319-lprocfs-client-side-cleanups.patch +++ /dev/null @@ -1,463 +0,0 @@ -From cd81037fa6ecc7f6b36d3c49205a3d6f3e7aa0de Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Tue, 21 Jan 2014 12:06:59 -0500 -Subject: [PATCH 11/13] LU-3319 lprocfs: client side cleanups - -Now that all the client side seq_file patches it is -time to handle the issue that people pointed out but -were not severe enough to prevent landing. This patch -addresses all the concerns as well and move all struct -lprocfs_seq_var to be initialized C99 style. - -Change-Id: I89e8b719bd067ecf4e3cab481a2d4c62d5052af0 -Signed-off-by: James Simmons ---- - lustre/fid/lproc_fid.c | 21 ++++++--- - lustre/lmv/lproc_lmv.c | 15 ++++--- - lustre/lov/lproc_lov.c | 42 ++++++++++++------ - lustre/mdc/lproc_mdc.c | 52 ++++++++++++++-------- - lustre/mgc/lproc_mgc.c | 25 +++++++---- - lustre/obdclass/lprocfs_status.c | 1 - - lustre/obdecho/echo.c | 3 +- - lustre/osc/lproc_osc.c | 94 +++++++++++++++++++++++++++------------- - lustre/osc/osc_request.c | 2 +- - lustre/ost/ost_handler.c | 3 +- - lustre/ptlrpc/lproc_ptlrpc.c | 2 +- - lustre/quota/qmt_pool.c | 3 +- - lustre/quota/qsd_lib.c | 12 +++-- - 13 files changed, 183 insertions(+), 92 deletions(-) - -diff --git a/lustre/fid/lproc_fid.c b/lustre/fid/lproc_fid.c -index d89c4f6..3b9d170 100644 ---- a/lustre/fid/lproc_fid.c -+++ b/lustre/fid/lproc_fid.c -@@ -203,9 +203,12 @@ LPROC_SEQ_FOPS(lprocfs_server_fid_width); - LPROC_SEQ_FOPS_RO(lprocfs_server_fid_server); - - struct lprocfs_seq_vars seq_server_proc_list[] = { -- { "space", &lprocfs_server_fid_space_fops }, -- { "width", &lprocfs_server_fid_width_fops }, -- { "server", &lprocfs_server_fid_server_fops }, -+ { .name = "space", -+ .fops = &lprocfs_server_fid_space_fops }, -+ { .name = "width", -+ .fops = &lprocfs_server_fid_width_fops }, -+ { .name = "server", -+ .fops = &lprocfs_server_fid_server_fops }, - { NULL } - }; - -@@ -623,10 +626,14 @@ LPROC_SEQ_FOPS_RO(lprocfs_client_fid_server); - LPROC_SEQ_FOPS_RO(lprocfs_client_fid_fid); - - struct lprocfs_seq_vars seq_client_proc_list[] = { -- { "space", &lprocfs_client_fid_space_fops }, -- { "width", &lprocfs_client_fid_width_fops }, -- { "server", &lprocfs_client_fid_server_fops }, -- { "fid", &lprocfs_client_fid_fid_fops }, -+ { .name = "space", -+ .fops = &lprocfs_client_fid_space_fops }, -+ { .name = "width", -+ .fops = &lprocfs_client_fid_width_fops }, -+ { .name = "server", -+ .fops = &lprocfs_client_fid_server_fops }, -+ { .name = "fid", -+ .fops = &lprocfs_client_fid_fid_fops }, - { NULL } - }; - #endif -diff --git a/lustre/lmv/lproc_lmv.c b/lustre/lmv/lproc_lmv.c -index eea5927..5a7271a 100644 ---- a/lustre/lmv/lproc_lmv.c -+++ b/lustre/lmv/lproc_lmv.c -@@ -203,11 +203,16 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file) - LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid); - - struct lprocfs_seq_vars lprocfs_lmv_obd_vars[] = { -- { "numobd", &lmv_numobd_fops }, -- { "placement", &lmv_placement_fops }, -- { "activeobd", &lmv_activeobd_fops }, -- { "uuid", &lmv_uuid_fops }, -- { "desc_uuid", &lmv_desc_uuid_fops }, -+ { .name = "numobd", -+ .fops = &lmv_numobd_fops }, -+ { .name = "placement", -+ .fops = &lmv_placement_fops }, -+ { .name = "activeobd", -+ .fops = &lmv_activeobd_fops }, -+ { .name = "uuid", -+ .fops = &lmv_uuid_fops }, -+ { .name = "desc_uuid", -+ .fops = &lmv_desc_uuid_fops }, - { 0 } - }; - -diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c -index e400faf..7786513 100644 ---- a/lustre/lov/lproc_lov.c -+++ b/lustre/lov/lproc_lov.c -@@ -263,20 +263,34 @@ LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree); - LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail); - - struct lprocfs_seq_vars lprocfs_lov_obd_vars[] = { -- { "uuid", &lov_uuid_fops }, -- { "stripesize", &lov_stripesize_fops }, -- { "stripeoffset", &lov_stripeoffset_fops }, -- { "stripecount", &lov_stripecount_fops }, -- { "stripetype", &lov_stripetype_fops }, -- { "numobd", &lov_numobd_fops }, -- { "activeobd", &lov_activeobd_fops }, -- { "filestotal", &lov_filestotal_fops }, -- { "filesfree", &lov_filesfree_fops }, -- { "blocksize", &lov_blksize_fops }, -- { "kbytestotal", &lov_kbytestotal_fops }, -- { "kbytesfree", &lov_kbytesfree_fops }, -- { "kbytesavail", &lov_kbytesavail_fops }, -- { "desc_uuid", &lov_desc_uuid_fops }, -+ { .name = "uuid", -+ .fops = &lov_uuid_fops }, -+ { .name = "stripesize", -+ .fops = &lov_stripesize_fops }, -+ { .name = "stripeoffset", -+ .fops = &lov_stripeoffset_fops }, -+ { .name = "stripecount", -+ .fops = &lov_stripecount_fops }, -+ { .name = "stripetype", -+ .fops = &lov_stripetype_fops }, -+ { .name = "numobd", -+ .fops = &lov_numobd_fops }, -+ { .name = "activeobd", -+ .fops = &lov_activeobd_fops }, -+ { .name = "filestotal", -+ .fops = &lov_filestotal_fops }, -+ { .name = "filesfree", -+ .fops = &lov_filesfree_fops }, -+ { .name = "blocksize", -+ .fops = &lov_blksize_fops }, -+ { .name = "kbytestotal", -+ .fops = &lov_kbytestotal_fops }, -+ { .name = "kbytesfree", -+ .fops = &lov_kbytesfree_fops }, -+ { .name = "kbytesavail", -+ .fops = &lov_kbytesavail_fops }, -+ { .name = "desc_uuid", -+ .fops = &lov_desc_uuid_fops }, - { 0 } - }; - -diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c -index cba4f61..69e377f 100644 ---- a/lustre/mdc/lproc_mdc.c -+++ b/lustre/mdc/lproc_mdc.c -@@ -103,29 +103,47 @@ LPROC_SEQ_FOPS_RW_TYPE(mdc, import); - LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov); - - struct lprocfs_seq_vars lprocfs_mdc_obd_vars[] = { -- { "uuid", &mdc_uuid_fops, 0, 0 }, -- { "ping", &mdc_ping_fops, 0, 0222 }, -- { "connect_flags", &mdc_connect_flags_fops,0, 0 }, -- { "blocksize", &mdc_blksize_fops, 0, 0 }, -- { "kbytestotal", &mdc_kbytestotal_fops, 0, 0 }, -- { "kbytesfree", &mdc_kbytesfree_fops, 0, 0 }, -- { "kbytesavail", &mdc_kbytesavail_fops, 0, 0 }, -- { "filestotal", &mdc_filestotal_fops, 0, 0 }, -- { "filesfree", &mdc_filesfree_fops, 0, 0 }, -- { "mds_server_uuid", &mdc_server_uuid_fops, 0, 0 }, -- { "mds_conn_uuid", &mdc_conn_uuid_fops, 0, 0 }, -+ { .name = "uuid", -+ .fops = &mdc_uuid_fops }, -+ { .name = "ping", -+ .fops = &mdc_ping_fops, -+ .proc_mode = 0222 }, -+ { .name = "connect_flags", -+ .fops = &mdc_connect_flags_fops }, -+ { .name = "blocksize", -+ .fops = &mdc_blksize_fops }, -+ { .name = "kbytestotal", -+ .fops = &mdc_kbytestotal_fops }, -+ { .name = "kbytesfree", -+ .fops = &mdc_kbytesfree_fops }, -+ { .name = "kbytesavail", -+ .fops = &mdc_kbytesavail_fops }, -+ { .name = "filestotal", -+ .fops = &mdc_filestotal_fops }, -+ { .name = "filesfree", -+ .fops = &mdc_filesfree_fops }, -+ { .name = "mds_server_uuid", -+ .fops = &mdc_server_uuid_fops }, -+ { .name = "mds_conn_uuid", -+ .fops = &mdc_conn_uuid_fops }, - /* - * FIXME: below proc entry is provided, but not in used, instead - * sbi->sb_md_brw_size is used, the per obd variable should be used - * when CMD is enabled, and dir pages are managed in MDC layer. - * Remember to enable proc write function. - */ -- { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops }, -- { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops }, -- { "timeouts", &mdc_timeouts_fops }, -- { "import", &mdc_import_fops }, -- { "state", &mdc_state_fops }, -- { "pinger_recov", &mdc_pinger_recov_fops }, -+ { .name = "max_pages_per_rpc", -+ .fops = &mdc_obd_max_pages_per_rpc_fops }, -+ { .name = "max_rpcs_in_flight", -+ .fops = &mdc_max_rpcs_in_flight_fops }, -+ { .name = "timeouts", -+ .fops = &mdc_timeouts_fops }, -+ { .name = "import", -+ .fops = &mdc_import_fops }, -+ { .name = "state", -+ .fops = &mdc_state_fops }, -+ { .name = "pinger_recov", -+ .fops = &mdc_pinger_recov_fops }, - { 0 } - }; - #endif /* LPROCFS */ -diff --git a/lustre/mgc/lproc_mgc.c b/lustre/mgc/lproc_mgc.c -index 648b6e5..f818def 100644 ---- a/lustre/mgc/lproc_mgc.c -+++ b/lustre/mgc/lproc_mgc.c -@@ -59,14 +59,23 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v) - LPROC_SEQ_FOPS_RO(mgc_ir_state); - - struct lprocfs_seq_vars lprocfs_mgc_obd_vars[] = { -- { "uuid", &mgc_uuid_fops, 0, 0 }, -- { "ping", &mgc_ping_fops, 0, 0222 }, -- { "connect_flags", &mgc_connect_flags_fops,0, 0 }, -- { "mgs_server_uuid", &mgc_server_uuid_fops, 0, 0 }, -- { "mgs_conn_uuid", &mgc_conn_uuid_fops, 0, 0 }, -- { "import", &mgc_import_fops, 0, 0 }, -- { "state", &mgc_state_fops, 0, 0 }, -- { "ir_state", &mgc_ir_state_fops, 0, 0 }, -+ { .name = "uuid", -+ .fops = &mgc_uuid_fops }, -+ { .name = "ping", -+ .fops = &mgc_ping_fops, -+ .proc_mode = 0222 }, -+ { .name = "connect_flags", -+ .fops = &mgc_connect_flags_fops }, -+ { .name = "mgs_server_uuid", -+ .fops = &mgc_server_uuid_fops }, -+ { .name = "mgs_conn_uuid", -+ .fops = &mgc_conn_uuid_fops }, -+ { .name = "import", -+ .fops = &mgc_import_fops }, -+ { .name = "state", -+ .fops = &mgc_state_fops }, -+ { .name = "ir_state", -+ .fops = &mgc_ir_state_fops }, - { 0 } - }; - #endif /* LPROCFS */ -diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c -index f9cb944..abe5d71 100644 ---- a/lustre/obdclass/lprocfs_status.c -+++ b/lustre/obdclass/lprocfs_status.c -@@ -2581,7 +2581,6 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats) - EXPORT_SYMBOL(lprocfs_init_ldlm_stats); - - #ifdef HAVE_SERVER_SUPPORT --/* No one appears to be using this ?? */ - int lprocfs_exp_nid_seq_show(struct seq_file *m, void *data) - { - struct obd_export *exp = m->private; -diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c -index 6d63aff..8563e68 100644 ---- a/lustre/obdecho/echo.c -+++ b/lustre/obdecho/echo.c -@@ -561,7 +561,8 @@ commitrw_cleanup: - - LPROC_SEQ_FOPS_RO_TYPE(echo, uuid); - static struct lprocfs_seq_vars lprocfs_echo_obd_vars[] = { -- { "uuid", &echo_uuid_fops }, -+ { .name = "uuid", -+ .fops = &echo_uuid_fops }, - { 0 } - }; - -diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c -index d6e3703..ccfc212 100644 ---- a/lustre/osc/lproc_osc.c -+++ b/lustre/osc/lproc_osc.c -@@ -543,37 +543,69 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import); - LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov); - - struct lprocfs_seq_vars lprocfs_osc_obd_vars[] = { -- { "uuid", &osc_uuid_fops }, -- { "ping", &osc_ping_fops, 0, 0222 }, -- { "connect_flags", &osc_connect_flags_fops }, -- { "blocksize", &osc_blksize_fops }, -- { "kbytestotal", &osc_kbytestotal_fops }, -- { "kbytesfree", &osc_kbytesfree_fops }, -- { "kbytesavail", &osc_kbytesavail_fops }, -- { "filestotal", &osc_filestotal_fops }, -- { "filesfree", &osc_filesfree_fops }, -- { "ost_server_uuid", &osc_server_uuid_fops }, -- { "ost_conn_uuid", &osc_conn_uuid_fops }, -- { "active", &osc_active_fops }, -- { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops }, -- { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops }, -- { "destroys_in_flight", &osc_destroys_in_flight_fops }, -- { "max_dirty_mb", &osc_max_dirty_mb_fops }, -- { "osc_cached_mb", &osc_cached_mb_fops }, -- { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops }, -- { "cur_grant_bytes", &osc_cur_grant_bytes_fops }, -- { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops }, -- { "grant_shrink_interval", &osc_grant_shrink_interval_fops }, -- { "checksums", &osc_checksum_fops }, -- { "checksum_type", &osc_checksum_type_fops }, -- { "resend_count", &osc_resend_count_fops }, -- { "timeouts", &osc_timeouts_fops }, -- { "contention_seconds", &osc_contention_seconds_fops }, -- { "lockless_truncate", &osc_lockless_truncate_fops }, -- { "import", &osc_import_fops }, -- { "state", &osc_state_fops }, -- { "pinger_recov", &osc_pinger_recov_fops }, -- { "unstable_stats", &osc_unstable_stats_fops }, -+ { .name = "uuid", -+ .fops = &osc_uuid_fops }, -+ { .name = "ping", -+ .fops = &osc_ping_fops, -+ .proc_mode = 0222 }, -+ { .name = "connect_flags", -+ .fops = &osc_connect_flags_fops }, -+ { .name = "blocksize", -+ .fops = &osc_blksize_fops }, -+ { .name = "kbytestotal", -+ .fops = &osc_kbytestotal_fops }, -+ { .name = "kbytesfree", -+ .fops = &osc_kbytesfree_fops }, -+ { .name = "kbytesavail", -+ .fops = &osc_kbytesavail_fops }, -+ { .name = "filestotal", -+ .fops = &osc_filestotal_fops }, -+ { .name = "filesfree", -+ .fops = &osc_filesfree_fops }, -+ { .name = "ost_server_uuid", -+ .fops = &osc_server_uuid_fops }, -+ { .name = "ost_conn_uuid", -+ .fops = &osc_conn_uuid_fops }, -+ { .name = "active", -+ .fops = &osc_active_fops }, -+ { .name = "max_pages_per_rpc", -+ .fops = &osc_obd_max_pages_per_rpc_fops }, -+ { .name = "max_rpcs_in_flight", -+ .fops = &osc_max_rpcs_in_flight_fops }, -+ { .name = "destroys_in_flight", -+ .fops = &osc_destroys_in_flight_fops }, -+ { .name = "max_dirty_mb", -+ .fops = &osc_max_dirty_mb_fops }, -+ { .name = "osc_cached_mb", -+ .fops = &osc_cached_mb_fops }, -+ { .name = "cur_dirty_bytes", -+ .fops = &osc_cur_dirty_bytes_fops }, -+ { .name = "cur_grant_bytes", -+ .fops = &osc_cur_grant_bytes_fops }, -+ { .name = "cur_lost_grant_bytes", -+ .fops = &osc_cur_lost_grant_bytes_fops }, -+ { .name = "grant_shrink_interval", -+ .fops = &osc_grant_shrink_interval_fops }, -+ { .name = "checksums", -+ .fops = &osc_checksum_fops }, -+ { .name = "checksum_type", -+ .fops = &osc_checksum_type_fops }, -+ { .name = "resend_count", -+ .fops = &osc_resend_count_fops }, -+ { .name = "timeouts", -+ .fops = &osc_timeouts_fops }, -+ { .name = "contention_seconds", -+ .fops = &osc_contention_seconds_fops }, -+ { .name = "lockless_truncate", -+ .fops = &osc_lockless_truncate_fops }, -+ { .name = "import", -+ .fops = &osc_import_fops }, -+ { .name = "state", -+ .fops = &osc_state_fops }, -+ { .name = "pinger_recov", -+ .fops = &osc_pinger_recov_fops }, -+ { .name = "unstable_stats", -+ .fops = &osc_unstable_stats_fops }, - { 0 } - }; - -diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c -index b9d1b71..f95fb55 100644 ---- a/lustre/osc/osc_request.c -+++ b/lustre/osc/osc_request.c -@@ -3669,7 +3669,7 @@ int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) - { - int rc = class_process_proc_seq_param(PARAM_OSC, obd->obd_vars, - lcfg, obd); -- return(rc > 0 ? 0: rc); -+ return rc > 0 ? 0: rc; - } - - static int osc_process_config(struct obd_device *obd, obd_count len, void *buf) -diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c -index d4da00d..d20a30f 100644 ---- a/lustre/ost/ost_handler.c -+++ b/lustre/ost/ost_handler.c -@@ -75,7 +75,8 @@ static struct cfs_cpt_table *ost_io_cptable; - LPROC_SEQ_FOPS_RO_TYPE(ost, uuid); - - static struct lprocfs_seq_vars lprocfs_ost_obd_vars[] = { -- { "uuid", &ost_uuid_fops }, -+ { .name = "uuid", -+ .fops = &ost_uuid_fops }, - { 0 } - }; - #endif /* LPROCFS */ -diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c -index 8e5a397..bf21958 100644 ---- a/lustre/ptlrpc/lproc_ptlrpc.c -+++ b/lustre/ptlrpc/lproc_ptlrpc.c -@@ -1382,7 +1382,7 @@ lprocfs_import_seq_write(struct file *file, const char *buffer, size_t count, - - *ptr = 0; - do_reconn = 0; -- ptr += strlen("::"); -+ ptr += 2; /* Skip :: */ - inst = simple_strtol(ptr, &endptr, 10); - if (*endptr) { - CERROR("config: wrong instance # %s\n", ptr); -diff --git a/lustre/quota/qmt_pool.c b/lustre/quota/qmt_pool.c -index afd450c..df6d6fc 100644 ---- a/lustre/quota/qmt_pool.c -+++ b/lustre/quota/qmt_pool.c -@@ -171,7 +171,8 @@ static int qpi_state_seq_show(struct seq_file *m, void *data) - LPROC_SEQ_FOPS_RO(qpi_state); - - static struct lprocfs_seq_vars lprocfs_quota_qpi_vars[] = { -- { "info", &qpi_state_fops }, -+ { .name = "info", -+ .fops = &qpi_state_fops }, - { NULL } - }; - -diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c -index 990cfee..573473c 100644 ---- a/lustre/quota/qsd_lib.c -+++ b/lustre/quota/qsd_lib.c -@@ -208,10 +208,14 @@ qsd_timeout_seq_write(struct file *file, const char *buffer, - LPROC_SEQ_FOPS(qsd_timeout); - - static struct lprocfs_seq_vars lprocfs_quota_qsd_vars[] = { -- { "info", &qsd_state_fops }, -- { "enabled", &qsd_enabled_fops }, -- { "force_reint", &qsd_force_reint_fops }, -- { "timeout", &qsd_timeout_fops }, -+ { .name = "info", -+ .fops = &qsd_state_fops }, -+ { .name = "enabled", -+ .fops = &qsd_enabled_fops }, -+ { .name = "force_reint", -+ .fops = &qsd_force_reint_fops }, -+ { .name = "timeout", -+ .fops = &qsd_timeout_fops }, - { NULL } - }; - --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0011-LU-3974-llite-use-new-struct-dir_context.patch b/sys-cluster/lustre/files/0011-LU-3974-llite-use-new-struct-dir_context.patch new file mode 100644 index 000000000..c2ca77147 --- /dev/null +++ b/sys-cluster/lustre/files/0011-LU-3974-llite-use-new-struct-dir_context.patch @@ -0,0 +1,265 @@ +From da6a877ec27753ce11499d1bde68d392f90179c4 Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Mon, 20 Jan 2014 21:23:00 -0500 +Subject: [PATCH 11/12] LU-3974 llite: use new struct dir_context + +The readdir and nfs code over time has added more +parameters to be passed to be processed. For the 3.11 +kernel a new struct dir_context was introduced to +minimize the impact of future expansion. This patch +addresses this change. + +Conflicts: + lustre/llite/dir.c + +Signed-off-by: James Simmons +Change-Id: Ib42bf8cb06635a2a64e63b294d79e66ac82a1a5b +Signed-off-by: Alexey Shvetsov +--- + lustre/autoconf/lustre-core.m4 | 20 +++++++++++++ + lustre/llite/dir.c | 65 ++++++++++++++++++++++++++++++++++-------- + lustre/llite/llite_internal.h | 14 +++++++-- + lustre/llite/llite_nfs.c | 17 +++++++---- + 4 files changed, 96 insertions(+), 20 deletions(-) + +diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 +index e6207c9..f44a277 100644 +--- a/lustre/autoconf/lustre-core.m4 ++++ b/lustre/autoconf/lustre-core.m4 +@@ -1349,6 +1349,25 @@ LB_LINUX_TRY_COMPILE([ + ]) + + # ++# 3.11 readdir now takes the new struct dir_context ++# ++AC_DEFUN([LC_HAVE_DIR_CONTEXT], ++[AC_MSG_CHECKING([if dir_context exist]) ++LB_LINUX_TRY_COMPILE([ ++ #include ++],[ ++ struct dir_context ctx; ++ ++ ctx.pos = 0; ++],[ ++ AC_DEFINE(HAVE_DIR_CONTEXT, 1, [dir_context exist]) ++ AC_MSG_RESULT([yes]) ++],[ ++ AC_MSG_RESULT([no]) ++]) ++]) ++ ++# + # 3.11 dentry_operations.d_compare() taken 5 arguments. + # + AC_DEFUN([LC_D_COMPARE_5ARGS], +@@ -1523,6 +1542,7 @@ AC_DEFUN([LC_PROG_LINUX], + LC_BLKDEV_RELEASE_RETURN_INT + + # 3.11 ++ LC_HAVE_DIR_CONTEXT + LC_D_COMPARE_5ARGS + LC_HAVE_DCOUNT + +diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c +index dc5d623..5009934 100644 +--- a/lustre/llite/dir.c ++++ b/lustre/llite/dir.c +@@ -195,9 +195,27 @@ struct lu_dirent *ll_dir_entry_next(struct inode *dir, + return entry; + } + ++void ll_dir_entry_end(struct inode *dir, struct md_op_data *op_data, ++ struct lu_dirent *ent) ++{ ++ struct lu_dirent *entry; ++ struct md_callback cb_op; ++ ++ cb_op.md_blocking_ast = ll_md_blocking_ast; ++ op_data->op_cli_flags = CLI_READENT_END; ++ md_read_entry(ll_i2mdexp(dir), op_data, &cb_op, &entry); ++ return; ++} ++ ++#ifdef HAVE_DIR_CONTEXT ++int ll_dir_read(struct inode *inode, struct md_op_data *op_data, ++ struct dir_context *ctx) ++{ ++#else + int ll_dir_read(struct inode *inode, struct md_op_data *op_data, + void *cookie, filldir_t filldir) + { ++#endif + struct ll_sb_info *sbi = ll_i2sbi(inode); + struct ll_dir_chain chain; + struct lu_dirent *ent; +@@ -241,12 +259,17 @@ int ll_dir_read(struct inode *inode, struct md_op_data *op_data, + fid_le_to_cpu(&fid, &ent->lde_fid); + ino = cl_fid_build_ino(&fid, api32); + type = ll_dirent_type_get(ent); ++ ++#ifdef HAVE_DIR_CONTEXT + /* For 'll_nfs_get_name_filldir()', it will try + * to access the 'ent' through its 'lde_name', + * so the parameter 'name' for 'filldir()' must + * be part of the 'ent'. */ ++ done = !dir_emit(ctx, ent->lde_name, namelen, ino, type); ++#else + done = filldir(cookie, ent->lde_name, namelen, lhash, + ino, type); ++#endif + if (done) { + if (op_data->op_hash_offset != MDS_DIR_END_OFF) + op_data->op_hash_offset = last_hash; +@@ -268,7 +291,11 @@ int ll_dir_read(struct inode *inode, struct md_op_data *op_data, + RETURN(rc); + } + ++#ifdef HAVE_DIR_CONTEXT ++static int ll_iterate(struct file *filp, struct dir_context *ctx) ++#else + static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) ++#endif + { + struct inode *inode = filp->f_dentry->d_inode; + struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp); +@@ -305,22 +332,32 @@ static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) + + op_data->op_hash_offset = pos; + op_data->op_max_pages = sbi->ll_md_brw_size >> PAGE_CACHE_SHIFT; ++#ifdef HAVE_DIR_CONTEXT ++ ctx->pos = pos; ++ rc = ll_dir_read(inode, op_data, ctx); ++ pos = ctx->pos; ++#else + rc = ll_dir_read(inode, op_data, cookie, filldir); ++#endif + if (lfd != NULL) + lfd->lfd_pos = op_data->op_hash_offset; + + if (pos == MDS_DIR_END_OFF) { + if (api32) +- filp->f_pos = LL_DIR_END_OFF_32BIT; ++ pos = LL_DIR_END_OFF_32BIT; + else +- filp->f_pos = LL_DIR_END_OFF; ++ pos = LL_DIR_END_OFF; + } else { + if (api32 && hash64) +- filp->f_pos = op_data->op_hash_offset >> 32; ++ pos = op_data->op_hash_offset >> 32; + else +- filp->f_pos = op_data->op_hash_offset; ++ pos = op_data->op_hash_offset; + } +- ++#ifdef HAVE_DIR_CONTEXT ++ ctx->pos = pos; ++#else ++ filp->f_pos = pos; ++#endif + ll_finish_md_op_data(op_data); + filp->f_version = inode->i_version; + #ifdef HAVE_TOUCH_ATIME_1ARG +@@ -1702,11 +1739,15 @@ int ll_dir_release(struct inode *inode, struct file *file) + } + + struct file_operations ll_dir_operations = { +- .llseek = ll_dir_seek, +- .open = ll_dir_open, +- .release = ll_dir_release, +- .read = generic_read_dir, +- .readdir = ll_readdir, +- .unlocked_ioctl = ll_dir_ioctl, +- .fsync = ll_fsync, ++ .llseek = ll_dir_seek, ++ .open = ll_dir_open, ++ .release = ll_dir_release, ++ .read = generic_read_dir, ++#ifdef HAVE_DIR_CONTEXT ++ .iterate = ll_iterate, ++#else ++ .readdir = ll_readdir, ++#endif ++ .unlocked_ioctl = ll_dir_ioctl, ++ .fsync = ll_fsync, + }; +diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h +index 92b278e..c477b4c 100644 +--- a/lustre/llite/llite_internal.h ++++ b/lustre/llite/llite_internal.h +@@ -91,9 +91,12 @@ extern struct file_operations ll_pgcache_seq_fops; + #define REMOTE_PERM_HASHSIZE 16 + + struct ll_getname_data { +- char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ +- struct lu_fid lgd_fid; /* target fid we are looking for */ +- int lgd_found; /* inode matched? */ ++#ifdef HAVE_DIR_CONTEXT ++ struct dir_context ctx; ++#endif ++ char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ ++ struct lu_fid lgd_fid; /* target fid we are looking for */ ++ int lgd_found; /* inode matched? */ + }; + + /* llite setxid/access permission for user on remote client */ +@@ -719,8 +722,13 @@ static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {} + /* llite/dir.c */ + extern struct file_operations ll_dir_operations; + extern struct inode_operations ll_dir_inode_operations; ++#ifdef HAVE_DIR_CONTEXT ++int ll_dir_read(struct inode *inode, struct md_op_data *op_data, ++ struct dir_context *ctx); ++#else + int ll_dir_read(struct inode *inode, struct md_op_data *op_data, + void *cookie, filldir_t filldir); ++#endif + int ll_get_mdt_idx(struct inode *inode); + + struct lu_dirent *ll_dir_entry_start(struct inode *dir, +diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c +index 68616e9..faad453 100644 +--- a/lustre/llite/llite_nfs.c ++++ b/lustre/llite/llite_nfs.c +@@ -236,7 +236,14 @@ static int ll_get_name(struct dentry *dentry, char *name, + struct dentry *child) + { + struct inode *dir = dentry->d_inode; +- struct ll_getname_data lgd; ++ struct ll_getname_data lgd = { ++ .lgd_name = name, ++ .lgd_fid = ll_i2info(child->d_inode)->lli_fid, ++#ifdef HAVE_DIR_CONTEXT ++ .ctx.actor = ll_nfs_get_name_filldir, ++#endif ++ .lgd_found = 0, ++ }; + struct md_op_data *op_data; + int rc; + ENTRY; +@@ -247,10 +254,6 @@ static int ll_get_name(struct dentry *dentry, char *name, + if (!dir->i_fop) + GOTO(out, rc = -EINVAL); + +- lgd.lgd_name = name; +- lgd.lgd_fid = ll_i2info(child->d_inode)->lli_fid; +- lgd.lgd_found = 0; +- + op_data = ll_prep_md_op_data(NULL, dir, dir, NULL, 0, 0, + LUSTRE_OPC_ANY, dir); + if (IS_ERR(op_data)) +@@ -260,7 +263,11 @@ static int ll_get_name(struct dentry *dentry, char *name, + op_data->op_max_pages = + ll_i2sbi(dir)->ll_md_brw_size >> PAGE_CACHE_SHIFT; + mutex_lock(&dir->i_mutex); ++#ifdef HAVE_DIR_CONTEXT ++ rc = ll_dir_read(dir, op_data, &lgd.ctx); ++#else + rc = ll_dir_read(dir, op_data, &lgd, ll_nfs_get_name_filldir); ++#endif + mutex_unlock(&dir->i_mutex); + ll_finish_md_op_data(op_data); + if (!rc && !lgd.lgd_found) +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0012-LU-3974-llite-invalidatepage-api-changed.patch b/sys-cluster/lustre/files/0012-LU-3974-llite-invalidatepage-api-changed.patch new file mode 100644 index 000000000..63a3ec3e5 --- /dev/null +++ b/sys-cluster/lustre/files/0012-LU-3974-llite-invalidatepage-api-changed.patch @@ -0,0 +1,134 @@ +From 4e78aa55c404914cdc2d01060fb73fc1b0a6b63e Mon Sep 17 00:00:00 2001 +From: James Simmons +Date: Tue, 24 Sep 2013 12:29:47 -0400 +Subject: [PATCH 12/12] LU-3974 llite: invalidatepage api changed + +Until recently invalidating pages from the buffer cache +was dependent only on the page passed in and the start +in the page to invalidate. Starting with the 3.11 kernel +you can also specify the length of the data in the page +to invalidate. This patch enables us to handle the new +case. + +Signed-off-by: James Simmons +Change-Id: Iedf458b20b2604bc3099d5ae38bf0ad07df83bd3 +--- + lustre/autoconf/lustre-core.m4 | 20 ++++++++++++++++++++ + lustre/include/linux/lustre_patchless_compat.h | 19 +++++++++++-------- + lustre/llite/rw26.c | 24 +++++++++++++++++------- + 3 files changed, 48 insertions(+), 15 deletions(-) + +diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 +index f44a277..5409fde 100644 +--- a/lustre/autoconf/lustre-core.m4 ++++ b/lustre/autoconf/lustre-core.m4 +@@ -1349,6 +1349,25 @@ LB_LINUX_TRY_COMPILE([ + ]) + + # ++# 3.11 invalidatepage requires the length of the range to invalidate ++# ++AC_DEFUN([LC_INVALIDATE_RANGE], ++[AC_MSG_CHECKING([if address_space_operations.invalidatepage requires 3 arguments]) ++LB_LINUX_TRY_COMPILE([ ++ #include ++],[ ++ struct address_space_operations a_ops; ++ ++ a_ops.invalidatepage(NULL,0,0); ++],[ ++ AC_DEFINE(HAVE_INVALIDATE_RANGE, 1, [address_space_operations.invalidatepage needs 3 arguments]) ++ AC_MSG_RESULT([yes]) ++],[ ++ AC_MSG_RESULT([no]) ++]) ++]) ++ ++# + # 3.11 readdir now takes the new struct dir_context + # + AC_DEFUN([LC_HAVE_DIR_CONTEXT], +@@ -1542,6 +1561,7 @@ AC_DEFUN([LC_PROG_LINUX], + LC_BLKDEV_RELEASE_RETURN_INT + + # 3.11 ++ LC_INVALIDATE_RANGE + LC_HAVE_DIR_CONTEXT + LC_D_COMPARE_5ARGS + LC_HAVE_DCOUNT +diff --git a/lustre/include/linux/lustre_patchless_compat.h b/lustre/include/linux/lustre_patchless_compat.h +index 747bd4d..5b7bab6 100644 +--- a/lustre/include/linux/lustre_patchless_compat.h ++++ b/lustre/include/linux/lustre_patchless_compat.h +@@ -78,15 +78,18 @@ static inline void ll_delete_from_page_cache(struct page *page) + static inline void + truncate_complete_page(struct address_space *mapping, struct page *page) + { +- if (page->mapping != mapping) +- return; ++ if (page->mapping != mapping) ++ return; + +- if (PagePrivate(page)) +- page->mapping->a_ops->invalidatepage(page, 0); +- +- cancel_dirty_page(page, PAGE_SIZE); +- ClearPageMappedToDisk(page); +- ll_delete_from_page_cache(page); ++ if (PagePrivate(page)) ++#ifdef HAVE_INVALIDATE_RANGE ++ page->mapping->a_ops->invalidatepage(page, 0, PAGE_CACHE_SIZE); ++#else ++ page->mapping->a_ops->invalidatepage(page, 0); ++#endif ++ cancel_dirty_page(page, PAGE_SIZE); ++ ClearPageMappedToDisk(page); ++ ll_delete_from_page_cache(page); + } + #endif /* !HAVE_TRUNCATE_COMPLETE_PAGE */ + +diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c +index 447dc43..77151de 100644 +--- a/lustre/llite/rw26.c ++++ b/lustre/llite/rw26.c +@@ -76,7 +76,13 @@ + * aligned truncate). Lustre leaves partially truncated page in the cache, + * relying on struct inode::i_size to limit further accesses. + */ +-static void ll_invalidatepage(struct page *vmpage, unsigned long offset) ++static void ll_invalidatepage(struct page *vmpage, ++#ifdef HAVE_INVALIDATE_RANGE ++ unsigned int offset, unsigned int length ++#else ++ unsigned long offset ++#endif ++ ) + { + struct inode *inode; + struct lu_env *env; +@@ -88,12 +94,16 @@ static void ll_invalidatepage(struct page *vmpage, unsigned long offset) + LASSERT(PageLocked(vmpage)); + LASSERT(!PageWriteback(vmpage)); + +- /* +- * It is safe to not check anything in invalidatepage/releasepage +- * below because they are run with page locked and all our io is +- * happening with locked page too +- */ +- if (offset == 0) { ++ /* ++ * It is safe to not check anything in invalidatepage/releasepage ++ * below because they are run with page locked and all our io is ++ * happening with locked page too ++ */ ++#ifdef HAVE_INVALIDATE_RANGE ++ if (offset == 0 && length == PAGE_CACHE_SIZE) { ++#else ++ if (offset == 0) { ++#endif + env = cl_env_get(&refcheck); + if (!IS_ERR(env)) { + inode = vmpage->mapping->host; +-- +1.8.5.3 + diff --git a/sys-cluster/lustre/files/0012-LU-3974-llite-use-new-struct-dir_context.patch b/sys-cluster/lustre/files/0012-LU-3974-llite-use-new-struct-dir_context.patch deleted file mode 100644 index 7a5b843e3..000000000 --- a/sys-cluster/lustre/files/0012-LU-3974-llite-use-new-struct-dir_context.patch +++ /dev/null @@ -1,265 +0,0 @@ -From da6a877ec27753ce11499d1bde68d392f90179c4 Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Mon, 20 Jan 2014 21:23:00 -0500 -Subject: [PATCH 12/13] LU-3974 llite: use new struct dir_context - -The readdir and nfs code over time has added more -parameters to be passed to be processed. For the 3.11 -kernel a new struct dir_context was introduced to -minimize the impact of future expansion. This patch -addresses this change. - -Conflicts: - lustre/llite/dir.c - -Signed-off-by: James Simmons -Change-Id: Ib42bf8cb06635a2a64e63b294d79e66ac82a1a5b -Signed-off-by: Alexey Shvetsov ---- - lustre/autoconf/lustre-core.m4 | 20 +++++++++++++ - lustre/llite/dir.c | 65 ++++++++++++++++++++++++++++++++++-------- - lustre/llite/llite_internal.h | 14 +++++++-- - lustre/llite/llite_nfs.c | 17 +++++++---- - 4 files changed, 96 insertions(+), 20 deletions(-) - -diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 -index e6207c9..f44a277 100644 ---- a/lustre/autoconf/lustre-core.m4 -+++ b/lustre/autoconf/lustre-core.m4 -@@ -1349,6 +1349,25 @@ LB_LINUX_TRY_COMPILE([ - ]) - - # -+# 3.11 readdir now takes the new struct dir_context -+# -+AC_DEFUN([LC_HAVE_DIR_CONTEXT], -+[AC_MSG_CHECKING([if dir_context exist]) -+LB_LINUX_TRY_COMPILE([ -+ #include -+],[ -+ struct dir_context ctx; -+ -+ ctx.pos = 0; -+],[ -+ AC_DEFINE(HAVE_DIR_CONTEXT, 1, [dir_context exist]) -+ AC_MSG_RESULT([yes]) -+],[ -+ AC_MSG_RESULT([no]) -+]) -+]) -+ -+# - # 3.11 dentry_operations.d_compare() taken 5 arguments. - # - AC_DEFUN([LC_D_COMPARE_5ARGS], -@@ -1523,6 +1542,7 @@ AC_DEFUN([LC_PROG_LINUX], - LC_BLKDEV_RELEASE_RETURN_INT - - # 3.11 -+ LC_HAVE_DIR_CONTEXT - LC_D_COMPARE_5ARGS - LC_HAVE_DCOUNT - -diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c -index dc5d623..5009934 100644 ---- a/lustre/llite/dir.c -+++ b/lustre/llite/dir.c -@@ -195,9 +195,27 @@ struct lu_dirent *ll_dir_entry_next(struct inode *dir, - return entry; - } - -+void ll_dir_entry_end(struct inode *dir, struct md_op_data *op_data, -+ struct lu_dirent *ent) -+{ -+ struct lu_dirent *entry; -+ struct md_callback cb_op; -+ -+ cb_op.md_blocking_ast = ll_md_blocking_ast; -+ op_data->op_cli_flags = CLI_READENT_END; -+ md_read_entry(ll_i2mdexp(dir), op_data, &cb_op, &entry); -+ return; -+} -+ -+#ifdef HAVE_DIR_CONTEXT -+int ll_dir_read(struct inode *inode, struct md_op_data *op_data, -+ struct dir_context *ctx) -+{ -+#else - int ll_dir_read(struct inode *inode, struct md_op_data *op_data, - void *cookie, filldir_t filldir) - { -+#endif - struct ll_sb_info *sbi = ll_i2sbi(inode); - struct ll_dir_chain chain; - struct lu_dirent *ent; -@@ -241,12 +259,17 @@ int ll_dir_read(struct inode *inode, struct md_op_data *op_data, - fid_le_to_cpu(&fid, &ent->lde_fid); - ino = cl_fid_build_ino(&fid, api32); - type = ll_dirent_type_get(ent); -+ -+#ifdef HAVE_DIR_CONTEXT - /* For 'll_nfs_get_name_filldir()', it will try - * to access the 'ent' through its 'lde_name', - * so the parameter 'name' for 'filldir()' must - * be part of the 'ent'. */ -+ done = !dir_emit(ctx, ent->lde_name, namelen, ino, type); -+#else - done = filldir(cookie, ent->lde_name, namelen, lhash, - ino, type); -+#endif - if (done) { - if (op_data->op_hash_offset != MDS_DIR_END_OFF) - op_data->op_hash_offset = last_hash; -@@ -268,7 +291,11 @@ int ll_dir_read(struct inode *inode, struct md_op_data *op_data, - RETURN(rc); - } - -+#ifdef HAVE_DIR_CONTEXT -+static int ll_iterate(struct file *filp, struct dir_context *ctx) -+#else - static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) -+#endif - { - struct inode *inode = filp->f_dentry->d_inode; - struct ll_file_data *lfd = LUSTRE_FPRIVATE(filp); -@@ -305,22 +332,32 @@ static int ll_readdir(struct file *filp, void *cookie, filldir_t filldir) - - op_data->op_hash_offset = pos; - op_data->op_max_pages = sbi->ll_md_brw_size >> PAGE_CACHE_SHIFT; -+#ifdef HAVE_DIR_CONTEXT -+ ctx->pos = pos; -+ rc = ll_dir_read(inode, op_data, ctx); -+ pos = ctx->pos; -+#else - rc = ll_dir_read(inode, op_data, cookie, filldir); -+#endif - if (lfd != NULL) - lfd->lfd_pos = op_data->op_hash_offset; - - if (pos == MDS_DIR_END_OFF) { - if (api32) -- filp->f_pos = LL_DIR_END_OFF_32BIT; -+ pos = LL_DIR_END_OFF_32BIT; - else -- filp->f_pos = LL_DIR_END_OFF; -+ pos = LL_DIR_END_OFF; - } else { - if (api32 && hash64) -- filp->f_pos = op_data->op_hash_offset >> 32; -+ pos = op_data->op_hash_offset >> 32; - else -- filp->f_pos = op_data->op_hash_offset; -+ pos = op_data->op_hash_offset; - } -- -+#ifdef HAVE_DIR_CONTEXT -+ ctx->pos = pos; -+#else -+ filp->f_pos = pos; -+#endif - ll_finish_md_op_data(op_data); - filp->f_version = inode->i_version; - #ifdef HAVE_TOUCH_ATIME_1ARG -@@ -1702,11 +1739,15 @@ int ll_dir_release(struct inode *inode, struct file *file) - } - - struct file_operations ll_dir_operations = { -- .llseek = ll_dir_seek, -- .open = ll_dir_open, -- .release = ll_dir_release, -- .read = generic_read_dir, -- .readdir = ll_readdir, -- .unlocked_ioctl = ll_dir_ioctl, -- .fsync = ll_fsync, -+ .llseek = ll_dir_seek, -+ .open = ll_dir_open, -+ .release = ll_dir_release, -+ .read = generic_read_dir, -+#ifdef HAVE_DIR_CONTEXT -+ .iterate = ll_iterate, -+#else -+ .readdir = ll_readdir, -+#endif -+ .unlocked_ioctl = ll_dir_ioctl, -+ .fsync = ll_fsync, - }; -diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h -index 92b278e..c477b4c 100644 ---- a/lustre/llite/llite_internal.h -+++ b/lustre/llite/llite_internal.h -@@ -91,9 +91,12 @@ extern struct file_operations ll_pgcache_seq_fops; - #define REMOTE_PERM_HASHSIZE 16 - - struct ll_getname_data { -- char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ -- struct lu_fid lgd_fid; /* target fid we are looking for */ -- int lgd_found; /* inode matched? */ -+#ifdef HAVE_DIR_CONTEXT -+ struct dir_context ctx; -+#endif -+ char *lgd_name; /* points to a buffer with NAME_MAX+1 size */ -+ struct lu_fid lgd_fid; /* target fid we are looking for */ -+ int lgd_found; /* inode matched? */ - }; - - /* llite setxid/access permission for user on remote client */ -@@ -719,8 +722,13 @@ static void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {} - /* llite/dir.c */ - extern struct file_operations ll_dir_operations; - extern struct inode_operations ll_dir_inode_operations; -+#ifdef HAVE_DIR_CONTEXT -+int ll_dir_read(struct inode *inode, struct md_op_data *op_data, -+ struct dir_context *ctx); -+#else - int ll_dir_read(struct inode *inode, struct md_op_data *op_data, - void *cookie, filldir_t filldir); -+#endif - int ll_get_mdt_idx(struct inode *inode); - - struct lu_dirent *ll_dir_entry_start(struct inode *dir, -diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c -index 68616e9..faad453 100644 ---- a/lustre/llite/llite_nfs.c -+++ b/lustre/llite/llite_nfs.c -@@ -236,7 +236,14 @@ static int ll_get_name(struct dentry *dentry, char *name, - struct dentry *child) - { - struct inode *dir = dentry->d_inode; -- struct ll_getname_data lgd; -+ struct ll_getname_data lgd = { -+ .lgd_name = name, -+ .lgd_fid = ll_i2info(child->d_inode)->lli_fid, -+#ifdef HAVE_DIR_CONTEXT -+ .ctx.actor = ll_nfs_get_name_filldir, -+#endif -+ .lgd_found = 0, -+ }; - struct md_op_data *op_data; - int rc; - ENTRY; -@@ -247,10 +254,6 @@ static int ll_get_name(struct dentry *dentry, char *name, - if (!dir->i_fop) - GOTO(out, rc = -EINVAL); - -- lgd.lgd_name = name; -- lgd.lgd_fid = ll_i2info(child->d_inode)->lli_fid; -- lgd.lgd_found = 0; -- - op_data = ll_prep_md_op_data(NULL, dir, dir, NULL, 0, 0, - LUSTRE_OPC_ANY, dir); - if (IS_ERR(op_data)) -@@ -260,7 +263,11 @@ static int ll_get_name(struct dentry *dentry, char *name, - op_data->op_max_pages = - ll_i2sbi(dir)->ll_md_brw_size >> PAGE_CACHE_SHIFT; - mutex_lock(&dir->i_mutex); -+#ifdef HAVE_DIR_CONTEXT -+ rc = ll_dir_read(dir, op_data, &lgd.ctx); -+#else - rc = ll_dir_read(dir, op_data, &lgd, ll_nfs_get_name_filldir); -+#endif - mutex_unlock(&dir->i_mutex); - ll_finish_md_op_data(op_data); - if (!rc && !lgd.lgd_found) --- -1.8.5.3 - diff --git a/sys-cluster/lustre/files/0013-LU-3974-llite-invalidatepage-api-changed.patch b/sys-cluster/lustre/files/0013-LU-3974-llite-invalidatepage-api-changed.patch deleted file mode 100644 index ccca80629..000000000 --- a/sys-cluster/lustre/files/0013-LU-3974-llite-invalidatepage-api-changed.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 4e78aa55c404914cdc2d01060fb73fc1b0a6b63e Mon Sep 17 00:00:00 2001 -From: James Simmons -Date: Tue, 24 Sep 2013 12:29:47 -0400 -Subject: [PATCH 13/13] LU-3974 llite: invalidatepage api changed - -Until recently invalidating pages from the buffer cache -was dependent only on the page passed in and the start -in the page to invalidate. Starting with the 3.11 kernel -you can also specify the length of the data in the page -to invalidate. This patch enables us to handle the new -case. - -Signed-off-by: James Simmons -Change-Id: Iedf458b20b2604bc3099d5ae38bf0ad07df83bd3 ---- - lustre/autoconf/lustre-core.m4 | 20 ++++++++++++++++++++ - lustre/include/linux/lustre_patchless_compat.h | 19 +++++++++++-------- - lustre/llite/rw26.c | 24 +++++++++++++++++------- - 3 files changed, 48 insertions(+), 15 deletions(-) - -diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 -index f44a277..5409fde 100644 ---- a/lustre/autoconf/lustre-core.m4 -+++ b/lustre/autoconf/lustre-core.m4 -@@ -1349,6 +1349,25 @@ LB_LINUX_TRY_COMPILE([ - ]) - - # -+# 3.11 invalidatepage requires the length of the range to invalidate -+# -+AC_DEFUN([LC_INVALIDATE_RANGE], -+[AC_MSG_CHECKING([if address_space_operations.invalidatepage requires 3 arguments]) -+LB_LINUX_TRY_COMPILE([ -+ #include -+],[ -+ struct address_space_operations a_ops; -+ -+ a_ops.invalidatepage(NULL,0,0); -+],[ -+ AC_DEFINE(HAVE_INVALIDATE_RANGE, 1, [address_space_operations.invalidatepage needs 3 arguments]) -+ AC_MSG_RESULT([yes]) -+],[ -+ AC_MSG_RESULT([no]) -+]) -+]) -+ -+# - # 3.11 readdir now takes the new struct dir_context - # - AC_DEFUN([LC_HAVE_DIR_CONTEXT], -@@ -1542,6 +1561,7 @@ AC_DEFUN([LC_PROG_LINUX], - LC_BLKDEV_RELEASE_RETURN_INT - - # 3.11 -+ LC_INVALIDATE_RANGE - LC_HAVE_DIR_CONTEXT - LC_D_COMPARE_5ARGS - LC_HAVE_DCOUNT -diff --git a/lustre/include/linux/lustre_patchless_compat.h b/lustre/include/linux/lustre_patchless_compat.h -index 747bd4d..5b7bab6 100644 ---- a/lustre/include/linux/lustre_patchless_compat.h -+++ b/lustre/include/linux/lustre_patchless_compat.h -@@ -78,15 +78,18 @@ static inline void ll_delete_from_page_cache(struct page *page) - static inline void - truncate_complete_page(struct address_space *mapping, struct page *page) - { -- if (page->mapping != mapping) -- return; -+ if (page->mapping != mapping) -+ return; - -- if (PagePrivate(page)) -- page->mapping->a_ops->invalidatepage(page, 0); -- -- cancel_dirty_page(page, PAGE_SIZE); -- ClearPageMappedToDisk(page); -- ll_delete_from_page_cache(page); -+ if (PagePrivate(page)) -+#ifdef HAVE_INVALIDATE_RANGE -+ page->mapping->a_ops->invalidatepage(page, 0, PAGE_CACHE_SIZE); -+#else -+ page->mapping->a_ops->invalidatepage(page, 0); -+#endif -+ cancel_dirty_page(page, PAGE_SIZE); -+ ClearPageMappedToDisk(page); -+ ll_delete_from_page_cache(page); - } - #endif /* !HAVE_TRUNCATE_COMPLETE_PAGE */ - -diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c -index 447dc43..77151de 100644 ---- a/lustre/llite/rw26.c -+++ b/lustre/llite/rw26.c -@@ -76,7 +76,13 @@ - * aligned truncate). Lustre leaves partially truncated page in the cache, - * relying on struct inode::i_size to limit further accesses. - */ --static void ll_invalidatepage(struct page *vmpage, unsigned long offset) -+static void ll_invalidatepage(struct page *vmpage, -+#ifdef HAVE_INVALIDATE_RANGE -+ unsigned int offset, unsigned int length -+#else -+ unsigned long offset -+#endif -+ ) - { - struct inode *inode; - struct lu_env *env; -@@ -88,12 +94,16 @@ static void ll_invalidatepage(struct page *vmpage, unsigned long offset) - LASSERT(PageLocked(vmpage)); - LASSERT(!PageWriteback(vmpage)); - -- /* -- * It is safe to not check anything in invalidatepage/releasepage -- * below because they are run with page locked and all our io is -- * happening with locked page too -- */ -- if (offset == 0) { -+ /* -+ * It is safe to not check anything in invalidatepage/releasepage -+ * below because they are run with page locked and all our io is -+ * happening with locked page too -+ */ -+#ifdef HAVE_INVALIDATE_RANGE -+ if (offset == 0 && length == PAGE_CACHE_SIZE) { -+#else -+ if (offset == 0) { -+#endif - env = cl_env_get(&refcheck); - if (!IS_ERR(env)) { - inode = vmpage->mapping->host; --- -1.8.5.3 - -- cgit v1.2.3-65-gdbad