Whamcloud - gitweb
LU-8066 exports: move procfs exports to debugfs 13/57013/12
authorJames Simmons <jsimmons@infradead.org>
Tue, 25 Feb 2025 23:08:12 +0000 (18:08 -0500)
committerOleg Drokin <green@whamcloud.com>
Wed, 19 Mar 2025 23:32:27 +0000 (23:32 +0000)
The server side has a exports proc directory with several entries.
Upstreaming requires Lustre not to use the proc directory so
we can move the exports directory to debugfs. This is server side
so the root only issue should be limited. This step will make
more of the stats Netlink work much easier.

Change-Id: I73e38813f049cf563cdc7e277e4fadecd5a94e98
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57013
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
13 files changed:
lustre/include/lprocfs_status.h
lustre/include/lustre_export.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/mdt/mdt_fs.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lproc.c
lustre/mgs/lproc_mgs.c
lustre/mgs/mgs_fs.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/lprocfs_status_server.c
lustre/ofd/lproc_ofd.c
lustre/ofd/ofd_obd.c

index cb7c602..13696b9 100644 (file)
@@ -550,8 +550,8 @@ lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
 extern void lprocfs_free_per_client_stats(struct obd_device *obd);
 #ifdef HAVE_SERVER_SUPPORT
 extern ssize_t
-lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
-                                       size_t count, loff_t *off);
+ldebugfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
+                                  size_t count, loff_t *off);
 extern int lprocfs_nid_stats_clear_seq_show(struct seq_file *file, void *data);
 #endif
 extern int lprocfs_stats_register(struct proc_dir_entry *root, const char *name,
@@ -1025,20 +1025,6 @@ static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
 }
 
 #ifdef HAVE_SERVER_SUPPORT
-static inline
-ssize_t lprocfs_nid_stats_seq_write(struct file *file,
-                                   const char __user *buffer,
-                                   size_t count, loff_t *off)
-{
-       return 0;
-}
-
-static inline int lprocfs_nid_stats_clear_seq_show(struct seq_file *m,
-                                                  void *data)
-{
-       return 0;
-}
-
 static inline int lprocfs_exp_setup(struct obd_export *exp,
                                    struct lnet_nid *peer_nid)
 {
index d9fef16..251408f 100644 (file)
@@ -127,7 +127,7 @@ struct nid_stat {
        struct hlist_node        nid_hash;
        struct list_head         nid_list;
        struct obd_device       *nid_obd;
-       struct proc_dir_entry   *nid_proc;
+       struct dentry           *nid_debugfs;
        struct lprocfs_stats    *nid_stats;
        struct lprocfs_stats    *nid_ldlm_stats;
        /* for obd_nid_stats_hash exp_nid_stats */
@@ -299,6 +299,23 @@ struct obd_export {
 #define exp_filter_data u.eu_filter_data
 #define exp_ec_data     u.eu_ec_data
 
+static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp)
+{
+       /* Always add in ldlm_stats */
+       tmp->nid_ldlm_stats =
+               lprocfs_stats_alloc(LDLM_LAST_OPC - LDLM_FIRST_OPC,
+                                   LPROCFS_STATS_FLAG_NOPERCPU);
+       if (!tmp->nid_ldlm_stats)
+               return -ENOMEM;
+
+       lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
+
+       debugfs_create_file("ldlm_stats", 0644, tmp->nid_debugfs,
+                           tmp->nid_stats, &ldebugfs_stats_seq_fops);
+
+       return 0;
+}
+
 static inline __u64 *exp_connect_flags_ptr(struct obd_export *exp)
 {
        return &exp->exp_connect_data.ocd_connect_flags;
index 2e8c184..9d9c9ca 100644 (file)
@@ -736,9 +736,9 @@ struct obd_device {
        struct dentry                   *obd_debugfs_entry;
        struct dentry                   *obd_debugfs_gss_dir;
        struct proc_dir_entry   *obd_proc_entry;
-       struct proc_dir_entry   *obd_proc_exports_entry;
+       struct dentry                   *obd_debugfs_exports;
        struct dentry                   *obd_svc_debugfs_entry;
-       struct lprocfs_stats    *obd_svc_stats;
+       struct lprocfs_stats            *obd_svc_stats;
        const struct attribute         **obd_attrs;
        struct lprocfs_vars     *obd_vars;
        struct ldebugfs_vars    *obd_debugfs_vars;
index 5fcafbb..1fb3be2 100644 (file)
@@ -484,22 +484,6 @@ do {                                                               \
        }                                                       \
 } while (0)
 
-
-static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat* tmp)
-{
-       /* Always add in ldlm_stats */
-       tmp->nid_ldlm_stats =
-               lprocfs_stats_alloc(LDLM_LAST_OPC - LDLM_FIRST_OPC,
-                                   LPROCFS_STATS_FLAG_NOPERCPU);
-       if (tmp->nid_ldlm_stats == NULL)
-               return -ENOMEM;
-
-       lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
-
-       return lprocfs_stats_register(tmp->nid_proc, "ldlm_stats",
-                                     tmp->nid_ldlm_stats);
-}
-
 static inline int exp_check_ops(struct obd_export *exp)
 {
        if (exp == NULL) {
index 775c97e..f56a9c3 100644 (file)
 #include <libcfs/linux/linux-fs.h>
 #include "mdt_internal.h"
 
-static const struct proc_ops mdt_open_files_seq_fops = {
-       PROC_OWNER(THIS_MODULE)
-       .proc_open              = lprocfs_mdt_open_files_seq_open,
-       .proc_read              = seq_read,
-       .proc_lseek             = seq_lseek,
-       .proc_release           = single_release,
+static const struct file_operations mdt_open_files_seq_fops = {
+       .owner          = THIS_MODULE,
+       .open           = ldebugfs_mdt_open_files_seq_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
 };
 
 /**
@@ -44,10 +44,11 @@ int mdt_export_stats_init(struct obd_device *obd, struct obd_export *exp,
                          void *localdata)
 {
        struct lnet_nid *client_nid = localdata;
+       char param[MAX_OBD_NAME * 4];
        struct nid_stat *stats;
        int rc;
-       ENTRY;
 
+       ENTRY;
        rc = lprocfs_exp_setup(exp, client_nid);
 
        if (rc != 0)
@@ -55,30 +56,22 @@ int mdt_export_stats_init(struct obd_device *obd, struct obd_export *exp,
                RETURN(rc == -EALREADY ? 0 : rc);
 
        stats = exp->exp_nid_stats;
-       stats->nid_stats = lprocfs_stats_alloc(LPROC_MDT_LAST,
+       scnprintf(param, sizeof(param), "mdt.%s.exports.%s.stats",
+                 obd->obd_name, libcfs_nidstr(client_nid));
+       stats->nid_stats = ldebugfs_stats_alloc(LPROC_MDT_LAST, param,
+                                               stats->nid_debugfs,
                                                LPROCFS_STATS_FLAG_NOPERCPU);
-       if (stats->nid_stats == NULL)
+       if (!stats->nid_stats)
                RETURN(-ENOMEM);
 
        mdt_stats_counter_init(stats->nid_stats, 0, LPROCFS_CNTR_HISTOGRAM);
 
-       rc = lprocfs_stats_register(stats->nid_proc, "stats", stats->nid_stats);
-       if (rc != 0) {
-               lprocfs_stats_free(&stats->nid_stats);
-               GOTO(out, rc);
-       }
-
        rc = lprocfs_nid_ldlm_stats_init(stats);
        if (rc != 0)
                GOTO(out, rc);
 
-       rc = lprocfs_seq_create(stats->nid_proc, "open_files",
-                               0444, &mdt_open_files_seq_fops, stats);
-       if (rc != 0) {
-               CWARN("%s: error adding the open_files file: rc = %d\n",
-                       obd->obd_name, rc);
-               GOTO(out, rc);
-       }
+       debugfs_create_file("open_files", 0444, stats->nid_debugfs, stats,
+                           &mdt_open_files_seq_fops);
 out:
        RETURN(rc);
 }
index 7da4efb..67b39e7 100644 (file)
@@ -1329,8 +1329,8 @@ int mdt_tunables_init(struct mdt_device *mdt, const char *name);
 void mdt_tunables_fini(struct mdt_device *mdt);
 
 /* lustre/mdt_mdt_lproc.c */
-int lprocfs_mdt_open_files_seq_open(struct inode *inode,
-                                   struct file *file);
+int ldebugfs_mdt_open_files_seq_open(struct inode *inode,
+                                    struct file *file);
 void mdt_rename_counter_tally(struct mdt_thread_info *info,
                              struct mdt_device *mdt,
                              struct ptlrpc_request *req,
index 450258b..b2f87b7 100644 (file)
@@ -1411,12 +1411,14 @@ LPROC_SEQ_FOPS_RO(mdt_checksum_type);
 LPROC_SEQ_FOPS_RO_TYPE(mdt, hash);
 LPROC_SEQ_FOPS_WR_ONLY(mdt, mds_evict_client);
 LPROC_SEQ_FOPS_RW_TYPE(mdt, checksum_dump);
+LPROC_SEQ_FOPS_RO_TYPE(mdt, recovery_status);
+/* belongs to export directory */
+LDEBUGFS_SEQ_FOPS_RW_TYPE(mdt, nid_stats_clear);
+
 LUSTRE_RW_ATTR(job_cleanup_interval);
 LUSTRE_RW_ATTR(job_xattr);
-LPROC_SEQ_FOPS_RW_TYPE(mdt, nid_stats_clear);
 LUSTRE_RW_ATTR(hsm_control);
 
-LPROC_SEQ_FOPS_RO_TYPE(mdt, recovery_status);
 LUSTRE_RW_ATTR(recovery_time_hard);
 LUSTRE_RW_ATTR(recovery_time_soft);
 LUSTRE_RW_ATTR(ir_factor);
@@ -1539,7 +1541,7 @@ static struct ldebugfs_vars ldebugfs_mdt_gss_vars[] = {
 };
 
 static int
-lprocfs_mdt_print_open_files(struct obd_export *exp, void *v)
+ldebugfs_mdt_print_open_files(struct obd_export *exp, void *v)
 {
        struct seq_file         *seq = v;
 
@@ -1558,25 +1560,25 @@ lprocfs_mdt_print_open_files(struct obd_export *exp, void *v)
        return 0;
 }
 
-static int lprocfs_mdt_open_files_seq_show(struct seq_file *seq, void *v)
+static int ldebugfs_mdt_open_files_seq_show(struct seq_file *seq, void *v)
 {
        struct nid_stat *stats = seq->private;
 
        return obd_nid_export_for_each(stats->nid_obd, &stats->nid,
-                                      lprocfs_mdt_print_open_files, seq);
+                                      ldebugfs_mdt_print_open_files, seq);
 }
 
-int lprocfs_mdt_open_files_seq_open(struct inode *inode, struct file *file)
+int ldebugfs_mdt_open_files_seq_open(struct inode *inode, struct file *file)
 {
        struct seq_file         *seq;
        int                     rc;
 
-       rc = single_open(file, &lprocfs_mdt_open_files_seq_show, NULL);
+       rc = single_open(file, &ldebugfs_mdt_open_files_seq_show, NULL);
        if (rc != 0)
                return rc;
 
        seq = file->private_data;
-       seq->private = pde_data(inode);
+       seq->private = inode->i_private;
 
        return 0;
 }
@@ -1685,15 +1687,19 @@ int mdt_tunables_init(struct mdt_device *mdt, const char *name)
 
        obd->obd_debugfs_gss_dir = debugfs_create_dir("gss",
                                                      obd->obd_debugfs_entry);
-       if (obd->obd_debugfs_gss_dir)
-               ldebugfs_add_vars(obd->obd_debugfs_gss_dir,
-                                 ldebugfs_mdt_gss_vars, obd);
+       if (IS_ERR(obd->obd_debugfs_gss_dir))
+               obd->obd_debugfs_gss_dir = NULL;
+
+       ldebugfs_add_vars(obd->obd_debugfs_gss_dir,
+                         ldebugfs_mdt_gss_vars, obd);
+
+       obd->obd_debugfs_exports = debugfs_create_dir("exports",
+                                                     obd->obd_debugfs_entry);
+       if (IS_ERR(obd->obd_debugfs_exports))
+               obd->obd_debugfs_exports = NULL;
 
-       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",
-                                  obd, &mdt_nid_stats_clear_fops);
+       debugfs_create_file("clear", 0644, obd->obd_debugfs_exports,
+                           obd, &mdt_nid_stats_clear_fops);
 
        rc = lprocfs_alloc_md_stats(obd, ARRAY_SIZE(mdt_stats));
        if (rc)
@@ -1717,11 +1723,6 @@ void mdt_tunables_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_tunables is disabled earlier than this to avoid
         * coordinator restart.
index ca03239..6be3812 100644 (file)
@@ -187,7 +187,8 @@ int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb)
 LPROC_SEQ_FOPS_RO_TYPE(mgs, hash);
 LPROC_SEQ_FOPS_WR_ONLY(mgs, evict_client);
 LPROC_SEQ_FOPS_RW_TYPE(mgs, ir_timeout);
-LPROC_SEQ_FOPS_RW_TYPE(mgs, nid_stats_clear);
+/* belongs to export directory */
+LDEBUGFS_SEQ_FOPS_RW_TYPE(mgs, nid_stats_clear);
 
 static struct lprocfs_vars lprocfs_mgs_obd_vars[] = {
        { .name =       "hash_stats",
@@ -292,21 +293,19 @@ int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
 
        obd->obd_debugfs_gss_dir = debugfs_create_dir("gss",
                                                      obd->obd_debugfs_entry);
-       if (obd->obd_debugfs_gss_dir)
-               ldebugfs_add_vars(obd->obd_debugfs_gss_dir,
-                                 ldebugfs_ofd_gss_vars, obd);
-
-       obd->obd_proc_exports_entry = lprocfs_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;
-               GOTO(out, rc);
-        }
-       if (obd->obd_proc_exports_entry)
-               lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
-                                  obd, &mgs_nid_stats_clear_fops);
+       if (IS_ERR(obd->obd_debugfs_gss_dir))
+               obd->obd_debugfs_gss_dir = NULL;
+
+       ldebugfs_add_vars(obd->obd_debugfs_gss_dir,
+                         ldebugfs_ofd_gss_vars, obd);
+
+       obd->obd_debugfs_exports = debugfs_create_dir("exports",
+                                                     obd->obd_debugfs_entry);
+       if (IS_ERR(obd->obd_debugfs_exports))
+               obd->obd_debugfs_exports = NULL;
+
+       debugfs_create_file("clear", 0644, obd->obd_debugfs_exports,
+                           obd, &mgs_nid_stats_clear_fops);
 
        rc = sysfs_create_link(&obd->obd_kset.kobj, &mgs->mgs_bottom->dd_kobj,
                               "osd");
index 3501c21..af46305 100644 (file)
@@ -38,35 +38,28 @@ int mgs_export_stats_init(struct obd_device *obd, struct obd_export *exp,
                          void *localdata)
 {
        struct lnet_nid *client_nid = localdata;
+       char param[MAX_OBD_NAME * 4];
        struct nid_stat *stats;
        int rc;
 
        ENTRY;
-
        rc = lprocfs_exp_setup(exp, client_nid);
        if (rc != 0)
-               /* Mask error for already created /proc entries */
+               /* Mask error for already created /sysfs entries */
                RETURN(rc == -EALREADY ? 0 : rc);
 
        stats = exp->exp_nid_stats;
-       stats->nid_stats = lprocfs_stats_alloc(LPROC_MGS_LAST,
-                                              LPROCFS_STATS_FLAG_NOPERCPU);
-       if (stats->nid_stats == NULL)
+       scnprintf(param, sizeof(param), "mgs.MGS.exports.%s.stats",
+                 libcfs_nidstr(client_nid));
+       stats->nid_stats = ldebugfs_stats_alloc(LPROC_MGS_LAST, param,
+                                               stats->nid_debugfs,
+                                               LPROCFS_STATS_FLAG_NOPERCPU);
+       if (!stats->nid_stats)
                RETURN(-ENOMEM);
 
        mgs_stats_counter_init(stats->nid_stats);
 
-       rc = lprocfs_stats_register(stats->nid_proc, "stats", stats->nid_stats);
-       if (rc != 0) {
-               lprocfs_stats_free(&stats->nid_stats);
-               GOTO(out, rc);
-       }
-
        rc = lprocfs_nid_ldlm_stats_init(stats);
-       if (rc != 0)
-               GOTO(out, rc);
-
-out:
        RETURN(rc);
 }
 
index b27008d..7973079 100644 (file)
@@ -1147,13 +1147,11 @@ int lprocfs_obd_cleanup(struct obd_device *obd)
 
        debugfs_remove_recursive(obd->obd_debugfs_gss_dir);
        obd->obd_debugfs_gss_dir = NULL;
-
-       if (obd->obd_proc_exports_entry) {
-               /* Should be no exports left */
-               lprocfs_remove(&obd->obd_proc_exports_entry);
-               obd->obd_proc_exports_entry = NULL;
-       }
-
+#ifdef HAVE_SERVER_SUPPORT
+       /* Should be no exports left */
+       debugfs_remove_recursive(obd->obd_debugfs_exports);
+       obd->obd_debugfs_exports = NULL;
+#endif
        if (obd->obd_proc_entry) {
                lprocfs_remove(&obd->obd_proc_entry);
                obd->obd_proc_entry = NULL;
@@ -1805,23 +1803,6 @@ void lprocfs_free_md_stats(struct obd_device *obd)
 }
 EXPORT_SYMBOL(lprocfs_free_md_stats);
 
-void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
-{
-       lprocfs_counter_init(ldlm_stats, LDLM_ENQUEUE - LDLM_FIRST_OPC,
-                            LPROCFS_TYPE_REQS, "ldlm_enqueue");
-       lprocfs_counter_init(ldlm_stats, LDLM_CONVERT - LDLM_FIRST_OPC,
-                            LPROCFS_TYPE_REQS, "ldlm_convert");
-       lprocfs_counter_init(ldlm_stats, LDLM_CANCEL - LDLM_FIRST_OPC,
-                            LPROCFS_TYPE_REQS, "ldlm_cancel");
-       lprocfs_counter_init(ldlm_stats, LDLM_BL_CALLBACK - LDLM_FIRST_OPC,
-                            LPROCFS_TYPE_REQS, "ldlm_bl_callback");
-       lprocfs_counter_init(ldlm_stats, LDLM_CP_CALLBACK - LDLM_FIRST_OPC,
-                            LPROCFS_TYPE_REQS, "ldlm_cp_callback");
-       lprocfs_counter_init(ldlm_stats, LDLM_GL_CALLBACK - LDLM_FIRST_OPC,
-                            LPROCFS_TYPE_REQS, "ldlm_gl_callback");
-}
-EXPORT_SYMBOL(lprocfs_init_ldlm_stats);
-
 __s64 lprocfs_read_helper(struct lprocfs_counter *lc,
                          struct lprocfs_counter_header *header,
                          enum lprocfs_stats_flags flags,
index a75b101..683d0ab 100644 (file)
@@ -207,8 +207,25 @@ static int obd_export_flags2str(struct obd_export *exp, struct seq_file *m)
        return 0;
 }
 
+void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
+{
+       lprocfs_counter_init(ldlm_stats, LDLM_ENQUEUE - LDLM_FIRST_OPC,
+                            LPROCFS_TYPE_REQS, "ldlm_enqueue");
+       lprocfs_counter_init(ldlm_stats, LDLM_CONVERT - LDLM_FIRST_OPC,
+                            LPROCFS_TYPE_REQS, "ldlm_convert");
+       lprocfs_counter_init(ldlm_stats, LDLM_CANCEL - LDLM_FIRST_OPC,
+                            LPROCFS_TYPE_REQS, "ldlm_cancel");
+       lprocfs_counter_init(ldlm_stats, LDLM_BL_CALLBACK - LDLM_FIRST_OPC,
+                            LPROCFS_TYPE_REQS, "ldlm_bl_callback");
+       lprocfs_counter_init(ldlm_stats, LDLM_CP_CALLBACK - LDLM_FIRST_OPC,
+                            LPROCFS_TYPE_REQS, "ldlm_cp_callback");
+       lprocfs_counter_init(ldlm_stats, LDLM_GL_CALLBACK - LDLM_FIRST_OPC,
+                            LPROCFS_TYPE_REQS, "ldlm_gl_callback");
+}
+EXPORT_SYMBOL(lprocfs_init_ldlm_stats);
+
 static int
-lprocfs_exp_print_export_seq(struct obd_export *exp, void *cb_data)
+ldebugfs_exp_print_export_seq(struct obd_export *exp, void *cb_data)
 {
        struct seq_file         *m = cb_data;
        struct obd_device       *obd;
@@ -255,7 +272,7 @@ out:
 /**
  * RPC connections are composed of an import and an export. Using the
  * lctl utility we can extract important information about the state.
- * The lprocfs_exp_export_seq_show routine displays the state information
+ * The ldebugfs_exp_export_seq_show routine displays the state information
  * for the export.
  *
  * \param[in] m                seq file
@@ -275,26 +292,25 @@ out:
  *        export_flags: [ ... ]
  *
  */
-static int lprocfs_exp_export_seq_show(struct seq_file *m, void *data)
+static int ldebugfs_exp_export_seq_show(struct seq_file *m, void *data)
 {
        struct nid_stat *stats = m->private;
 
        return obd_nid_export_for_each(stats->nid_obd, &stats->nid,
-                                      lprocfs_exp_print_export_seq, m);
+                                      ldebugfs_exp_print_export_seq, m);
 }
-LPROC_SEQ_FOPS_RO(lprocfs_exp_export);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_exp_export);
 
 static void lprocfs_free_client_stats(struct nid_stat *client_stat)
 {
        CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
-              client_stat->nid_proc, client_stat->nid_stats);
+              client_stat->nid_debugfs, client_stat->nid_stats);
 
        LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
                 "nid %s:count %d\n", libcfs_nidstr(&client_stat->nid),
                 atomic_read(&client_stat->nid_exp_ref_count));
 
-       if (client_stat->nid_proc)
-               lprocfs_remove(&client_stat->nid_proc);
+       debugfs_remove_recursive(client_stat->nid_debugfs);
 
        if (client_stat->nid_stats)
                lprocfs_stats_free(&client_stat->nid_stats);
@@ -325,7 +341,7 @@ void lprocfs_free_per_client_stats(struct obd_device *obd)
 EXPORT_SYMBOL(lprocfs_free_per_client_stats);
 
 static int
-lprocfs_exp_print_nodemap_seq(struct obd_export *exp, void *cb_data)
+ldebugfs_exp_print_nodemap_seq(struct obd_export *exp, void *cb_data)
 {
        struct lu_nodemap *nodemap = exp->exp_target_data.ted_nodemap;
        struct seq_file *m = cb_data;
@@ -336,17 +352,17 @@ lprocfs_exp_print_nodemap_seq(struct obd_export *exp, void *cb_data)
 }
 
 static int
-lprocfs_exp_nodemap_seq_show(struct seq_file *m, void *data)
+ldebugfs_exp_nodemap_seq_show(struct seq_file *m, void *data)
 {
        struct nid_stat *stats = m->private;
 
        return obd_nid_export_for_each(stats->nid_obd, &stats->nid,
-                                      lprocfs_exp_print_nodemap_seq, m);
+                                      ldebugfs_exp_print_nodemap_seq, m);
 }
-LPROC_SEQ_FOPS_RO(lprocfs_exp_nodemap);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_exp_nodemap);
 
 static int
-lprocfs_exp_print_uuid_seq(struct obd_export *exp, void *cb_data)
+ldebugfs_exp_print_uuid_seq(struct obd_export *exp, void *cb_data)
 {
        struct seq_file *m = cb_data;
 
@@ -355,14 +371,14 @@ lprocfs_exp_print_uuid_seq(struct obd_export *exp, void *cb_data)
        return 0;
 }
 
-static int lprocfs_exp_uuid_seq_show(struct seq_file *m, void *data)
+static int ldebugfs_exp_uuid_seq_show(struct seq_file *m, void *data)
 {
        struct nid_stat *stats = m->private;
 
        return obd_nid_export_for_each(stats->nid_obd, &stats->nid,
-                                      lprocfs_exp_print_uuid_seq, m);
+                                      ldebugfs_exp_print_uuid_seq, m);
 }
-LPROC_SEQ_FOPS_RO(lprocfs_exp_uuid);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_exp_uuid);
 
 #define HASH_NAME_LEN  16
 
@@ -403,8 +419,7 @@ static void ldebugfs_rhash_seq_show(const char *name, struct rhashtable *ht,
 }
 
 static int
-lprocfs_exp_print_hash_seq(struct obd_export *exp, void *cb_data)
-
+ldebugfs_exp_print_hash_seq(struct obd_export *exp, void *cb_data)
 {
        struct obd_device *obd = exp->exp_obd;
        struct seq_file *m = cb_data;
@@ -417,17 +432,17 @@ lprocfs_exp_print_hash_seq(struct obd_export *exp, void *cb_data)
        return 0;
 }
 
-static int lprocfs_exp_hash_seq_show(struct seq_file *m, void *data)
+static int ldebugfs_exp_hash_seq_show(struct seq_file *m, void *data)
 {
        struct nid_stat *stats = m->private;
 
        return obd_nid_export_for_each(stats->nid_obd, &stats->nid,
-                                      lprocfs_exp_print_hash_seq, m);
+                                      ldebugfs_exp_print_hash_seq, m);
 }
-LPROC_SEQ_FOPS_RO(lprocfs_exp_hash);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_exp_hash);
 
-static int lprocfs_exp_print_replydata_seq(struct obd_export *exp,
-                                          void *cb_data)
+static int ldebugfs_exp_print_replydata_seq(struct obd_export *exp,
+                                           void *cb_data)
 
 {
        struct seq_file *m = cb_data;
@@ -444,17 +459,17 @@ static int lprocfs_exp_print_replydata_seq(struct obd_export *exp,
        return 0;
 }
 
-static int lprocfs_exp_replydata_seq_show(struct seq_file *m, void *data)
+static int ldebugfs_exp_replydata_seq_show(struct seq_file *m, void *data)
 {
        struct nid_stat *stats = m->private;
 
        return obd_nid_export_for_each(stats->nid_obd, &stats->nid,
-                                      lprocfs_exp_print_replydata_seq, m);
+                                      ldebugfs_exp_print_replydata_seq, m);
 }
-LPROC_SEQ_FOPS_RO(lprocfs_exp_replydata);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_exp_replydata);
 
-static int lprocfs_exp_print_fmd_count_seq(struct obd_export *exp,
-                                          void *cb_data)
+static int ldebugfs_exp_print_fmd_count_seq(struct obd_export *exp,
+                                           void *cb_data)
 {
        struct seq_file *m = cb_data;
        struct tg_export_data *ted = &exp->exp_target_data;
@@ -464,14 +479,14 @@ static int lprocfs_exp_print_fmd_count_seq(struct obd_export *exp,
        return 0;
 }
 
-static int lprocfs_exp_fmd_count_seq_show(struct seq_file *m, void *data)
+static int ldebugfs_exp_fmd_count_seq_show(struct seq_file *m, void *data)
 {
        struct nid_stat *stats = m->private;
 
        return obd_nid_export_for_each(stats->nid_obd, &stats->nid,
-                                      lprocfs_exp_print_fmd_count_seq, m);
+                                      ldebugfs_exp_print_fmd_count_seq, m);
 }
-LPROC_SEQ_FOPS_RO(lprocfs_exp_fmd_count);
+LDEBUGFS_SEQ_FOPS_RO(ldebugfs_exp_fmd_count);
 
 int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
 {
@@ -480,7 +495,7 @@ int lprocfs_nid_stats_clear_seq_show(struct seq_file *m, void *data)
 }
 EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_show);
 
-static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
+static int ldebugfs_nid_stats_clear_write_cb(void *obj, void *data)
 {
        struct nid_stat *stat = obj;
        ENTRY;
@@ -501,8 +516,8 @@ static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
 }
 
 ssize_t
-lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
-                                       size_t count, loff_t *off)
+ldebugfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
+                                  size_t count, loff_t *off)
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
@@ -510,7 +525,7 @@ lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
        LIST_HEAD(free_list);
 
        cfs_hash_cond_del(obd->obd_nid_stats_hash,
-                         lprocfs_nid_stats_clear_write_cb, &free_list);
+                         ldebugfs_nid_stats_clear_write_cb, &free_list);
 
        while (!list_empty(&free_list)) {
                client_stat = list_first_entry(&free_list, struct nid_stat,
@@ -520,25 +535,40 @@ lprocfs_nid_stats_clear_seq_write(struct file *file, const char __user *buffer,
        }
        return count;
 }
-EXPORT_SYMBOL(lprocfs_nid_stats_clear_seq_write);
+EXPORT_SYMBOL(ldebugfs_nid_stats_clear_seq_write);
+
+struct ldebugfs_vars ldebugfs_obd_exports_vars[] = {
+       { .name =       "nodemap",
+         .fops =       &ldebugfs_exp_nodemap_fops      },
+       { .name =       "uuid",
+         .fops =       &ldebugfs_exp_uuid_fops         },
+       { .name =       "hash",
+         .fops =       &ldebugfs_exp_hash_fops         },
+       { .name =       "export",
+         .fops =       &ldebugfs_exp_export_fops       },
+       { .name =       "reply_data",
+         .fops =       &ldebugfs_exp_replydata_fops    },
+       { .name =       "fmd_count",
+         .fops =       &ldebugfs_exp_fmd_count_fops    },
+       { NULL }
+};
 
 int lprocfs_exp_setup(struct obd_export *exp, struct lnet_nid *nid)
 {
        struct nid_stat *new_stat, *old_stat;
        struct obd_device *obd = NULL;
-       struct proc_dir_entry *entry;
        char nidstr[LNET_NIDSTR_SIZE];
        int rc = 0;
-       ENTRY;
 
-       if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
+       ENTRY;
+       if (!exp || !exp->exp_obd || !exp->exp_obd->obd_debugfs_exports ||
            !exp->exp_obd->obd_nid_stats_hash)
                RETURN(-EINVAL);
 
        /* not test against zero because eric say:
         * You may only test nid against another nid, or LNET_NID_ANY.
         * Anything else is nonsense.*/
-       if (nid == NULL || LNET_NID_IS_ANY(nid))
+       if (LNET_NID_IS_ANY(nid))
                RETURN(-EALREADY);
 
        libcfs_nidstr_r(nid, nidstr, sizeof(nidstr));
@@ -581,72 +611,15 @@ int lprocfs_exp_setup(struct obd_export *exp, struct lnet_nid *nid)
                spin_unlock(&exp->exp_lock);
                GOTO(destroy_new, rc = -EALREADY);
        }
-       /* not found - create */
-       new_stat->nid_proc = lprocfs_register(nidstr,
-                                             obd->obd_proc_exports_entry,
-                                             NULL, NULL);
-
-       if (IS_ERR(new_stat->nid_proc)) {
-               rc = PTR_ERR(new_stat->nid_proc);
-               new_stat->nid_proc = NULL;
-               CERROR("%s: cannot create proc entry for export %s: rc = %d\n",
-                      obd->obd_name, nidstr, rc);
-               GOTO(destroy_new_ns, rc);
-       }
-
-       entry = lprocfs_add_simple(new_stat->nid_proc, "nodemap", new_stat,
-                                  &lprocfs_exp_nodemap_fops);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CWARN("%s: error adding the nodemap file: rc = %d\n",
-                     obd->obd_name, rc);
-               GOTO(destroy_new_ns, rc);
-       }
 
-       entry = lprocfs_add_simple(new_stat->nid_proc, "uuid", new_stat,
-                                  &lprocfs_exp_uuid_fops);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CWARN("%s: error adding the NID stats file: rc = %d\n",
-                     obd->obd_name, rc);
-               GOTO(destroy_new_ns, rc);
-       }
-
-       entry = lprocfs_add_simple(new_stat->nid_proc, "hash", new_stat,
-                                  &lprocfs_exp_hash_fops);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CWARN("%s: error adding the hash file: rc = %d\n",
-                     obd->obd_name, rc);
-               GOTO(destroy_new_ns, rc);
-       }
-
-       entry = lprocfs_add_simple(new_stat->nid_proc, "export",
-                                  new_stat, &lprocfs_exp_export_fops);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CWARN("%s: error adding the export file: rc = %d\n",
-                     obd->obd_name, rc);
-               GOTO(destroy_new_ns, rc);
-       }
+       /* not found - create */
+       new_stat->nid_debugfs = debugfs_create_dir(nidstr,
+                                                  obd->obd_debugfs_exports);
+       if (IS_ERR(new_stat->nid_debugfs))
+               new_stat->nid_debugfs = NULL;
 
-       entry = lprocfs_add_simple(new_stat->nid_proc, "reply_data", new_stat,
-                                  &lprocfs_exp_replydata_fops);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CWARN("%s: error adding the reply_data file: rc = %d\n",
-                     obd->obd_name, rc);
-               GOTO(destroy_new_ns, rc);
-       }
-
-       entry = lprocfs_add_simple(new_stat->nid_proc, "fmd_count", new_stat,
-                                  &lprocfs_exp_fmd_count_fops);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CWARN("%s: error adding the fmd_count file: rc = %d\n",
-                     obd->obd_name, rc);
-               GOTO(destroy_new_ns, rc);
-       }
+       ldebugfs_add_vars(new_stat->nid_debugfs,
+                         ldebugfs_obd_exports_vars, new_stat);
 
        spin_lock(&exp->exp_lock);
        exp->exp_nid_stats = new_stat;
@@ -659,12 +632,6 @@ int lprocfs_exp_setup(struct obd_export *exp, struct lnet_nid *nid)
 
        RETURN(0);
 
-destroy_new_ns:
-       if (new_stat->nid_proc != NULL)
-               lprocfs_remove(&new_stat->nid_proc);
-       cfs_hash_del(obd->obd_nid_stats_hash, &new_stat->nid,
-                    &new_stat->nid_hash);
-
 destroy_new:
        nidstat_putref(new_stat);
        OBD_FREE_PTR(new_stat);
index bd1fea4..c7a27ad 100644 (file)
@@ -1029,7 +1029,8 @@ void ofd_stats_counter_init(struct lprocfs_stats *stats, unsigned int offset,
                             LPROCFS_TYPE_LATENCY & (~cntr_umask), "prealloc");
 }
 
-LPROC_SEQ_FOPS(lprocfs_nid_stats_clear);
+/* belongs to export directory */
+LDEBUGFS_SEQ_FOPS_RW_TYPE(ofd, nid_stats_clear);
 
 LUSTRE_OBD_UINT_PARAM_ATTR(at_min);
 LUSTRE_OBD_UINT_PARAM_ATTR(at_max);
@@ -1087,7 +1088,6 @@ KOBJ_ATTRIBUTE_GROUPS(ofd); /* creates ofd_groups from ofd_attrs */
 int ofd_tunables_init(struct ofd_device *ofd)
 {
        struct obd_device *obd = ofd_obd(ofd);
-       struct proc_dir_entry *entry;
        int rc = 0;
 
        ENTRY;
@@ -1120,27 +1120,19 @@ int ofd_tunables_init(struct ofd_device *ofd)
 
        obd->obd_debugfs_gss_dir = debugfs_create_dir("gss",
                                                      obd->obd_debugfs_entry);
-       if (obd->obd_debugfs_gss_dir)
-               ldebugfs_add_vars(obd->obd_debugfs_gss_dir,
-                                 ldebugfs_ofd_gss_vars, obd);
-
-       entry = lprocfs_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",
-                      obd->obd_name, rc, "exports");
-               GOTO(obd_free_stats, rc);
-       }
-       obd->obd_proc_exports_entry = entry;
+       if (IS_ERR(obd->obd_debugfs_gss_dir))
+               obd->obd_debugfs_gss_dir = NULL;
 
-       entry = lprocfs_add_simple(obd->obd_proc_exports_entry, "clear",
-                                  obd, &lprocfs_nid_stats_clear_fops);
-       if (IS_ERR(entry)) {
-               rc = PTR_ERR(entry);
-               CERROR("%s: add proc entry 'clear' failed: %d.\n",
-                      obd->obd_name, rc);
-               GOTO(obd_free_stats, rc);
-       }
+       ldebugfs_add_vars(obd->obd_debugfs_gss_dir,
+                         ldebugfs_ofd_gss_vars, obd);
+
+       obd->obd_debugfs_exports = debugfs_create_dir("exports",
+                                                     obd->obd_debugfs_entry);
+       if (IS_ERR(obd->obd_debugfs_exports))
+               obd->obd_debugfs_exports = NULL;
+
+       debugfs_create_file("clear", 0644, obd->obd_debugfs_exports,
+                           obd, &ofd_nid_stats_clear_fops);
 
        ofd_stats_counter_init(obd->obd_stats, 0, LPROCFS_CNTR_HISTOGRAM);
 
index d42dfb2..d5cf3d8 100644 (file)
@@ -47,12 +47,12 @@ static int ofd_export_stats_init(struct ofd_device *ofd,
                                 struct obd_export *exp,
                                 struct lnet_nid *client_nid)
 {
-       struct obd_device       *obd = ofd_obd(ofd);
-       struct nid_stat         *stats;
-       int                      rc;
+       struct obd_device *obd = ofd_obd(ofd);
+       char param[MAX_OBD_NAME * 4];
+       struct nid_stat *stats;
+       int rc;
 
        ENTRY;
-
        if (obd_uuid_equals(&exp->exp_client_uuid, &obd->obd_uuid))
                /* Self-export gets no proc entry */
                RETURN(0);
@@ -63,24 +63,17 @@ static int ofd_export_stats_init(struct ofd_device *ofd,
                RETURN(rc == -EALREADY ? 0 : rc);
 
        stats = exp->exp_nid_stats;
-       stats->nid_stats = lprocfs_stats_alloc(LPROC_OFD_STATS_LAST,
-                                              LPROCFS_STATS_FLAG_NOPERCPU);
+       scnprintf(param, sizeof(param), "obdfilter.%s.exports.%s.stats",
+                 obd->obd_name, libcfs_nidstr(client_nid));
+       stats->nid_stats = ldebugfs_stats_alloc(LPROC_OFD_STATS_LAST, param,
+                                               stats->nid_debugfs,
+                                               LPROCFS_STATS_FLAG_NOPERCPU);
        if (!stats->nid_stats)
                RETURN(-ENOMEM);
 
        ofd_stats_counter_init(stats->nid_stats, 0, LPROCFS_CNTR_HISTOGRAM);
 
-       rc = lprocfs_stats_register(stats->nid_proc, "stats", stats->nid_stats);
-       if (rc != 0) {
-               lprocfs_stats_free(&stats->nid_stats);
-               GOTO(out, rc);
-       }
-
        rc = lprocfs_nid_ldlm_stats_init(stats);
-       if (rc != 0)
-               GOTO(out, rc);
-
-out:
        RETURN(rc);
 }