Whamcloud - gitweb
LU-2484 mgs: remove unused md_stats
authorJohn L. Hammond <john.hammond@intel.com>
Tue, 12 Mar 2013 03:44:09 +0000 (22:44 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 22 Mar 2013 18:15:50 +0000 (14:15 -0400)
Do not allocate md_stats or create /proc/.../MGS/md_stats for mgs
devices since they do not implement the md_ops interface.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: I8b417bc2433484a0e008ff9bf7fef69ba1e62416
Reviewed-on: http://review.whamcloud.com/4813
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mgs/lproc_mgs.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_internal.h

index 65513fd..323fd02 100644 (file)
@@ -145,24 +145,35 @@ out:
 
 LPROC_SEQ_FOPS_RO(mgsself_srpc);
 
 
 LPROC_SEQ_FOPS_RO(mgsself_srpc);
 
-int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name)
+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 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);
+       if (rc != 0)
+               GOTO(out, rc);
 
         rc = lprocfs_obd_seq_create(obd, "filesystems", 0444,
                                     &mgs_fs_fops, obd);
 
         rc = lprocfs_obd_seq_create(obd, "filesystems", 0444,
                                     &mgs_fs_fops, obd);
+       if (rc != 0)
+               GOTO(out, rc);
+
        rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0400,
                                    &mgsself_srpc_fops, obd);
        rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0400,
                                    &mgsself_srpc_fops, obd);
+       if (rc != 0)
+               GOTO(out, rc);
 
         mgs->mgs_proc_live = lprocfs_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 = lprocfs_register("live", obd->obd_proc_entry,
                                               NULL, NULL);
         if (IS_ERR(mgs->mgs_proc_live)) {
                 rc = PTR_ERR(mgs->mgs_proc_live);
-                CERROR("error %d setting up lprocfs for %s\n", rc, "live");
                 mgs->mgs_proc_live = NULL;
                 mgs->mgs_proc_live = NULL;
+               GOTO(out, rc);
         }
 
         obd->obd_proc_exports_entry = lprocfs_register("exports",
         }
 
         obd->obd_proc_exports_entry = lprocfs_register("exports",
@@ -170,8 +181,8 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name)
                                                        NULL, NULL);
         if (IS_ERR(obd->obd_proc_exports_entry)) {
                 rc = PTR_ERR(obd->obd_proc_exports_entry);
                                                        NULL, NULL);
         if (IS_ERR(obd->obd_proc_exports_entry)) {
                 rc = PTR_ERR(obd->obd_proc_exports_entry);
-                CERROR("error %d setting up lprocfs for %s\n", rc, "exports");
                 obd->obd_proc_exports_entry = NULL;
                 obd->obd_proc_exports_entry = NULL;
+               GOTO(out, rc);
         }
 
        mgs->mgs_proc_osd = lprocfs_add_symlink("osd",
         }
 
        mgs->mgs_proc_osd = lprocfs_add_symlink("osd",
@@ -181,19 +192,23 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name)
                                                osd_len, /* Strip "-osd". */
                                                osd_name);
        if (mgs->mgs_proc_osd == NULL)
                                                osd_len, /* Strip "-osd". */
                                                osd_name);
        if (mgs->mgs_proc_osd == NULL)
-               rc = -ENOMEM;
+               GOTO(out, rc = -ENOMEM);
 
        mgs->mgs_proc_mntdev = lprocfs_add_symlink("mntdev",
                                                   obd->obd_proc_entry,
                                                   "osd/mntdev");
        if (mgs->mgs_proc_mntdev == NULL)
 
        mgs->mgs_proc_mntdev = lprocfs_add_symlink("mntdev",
                                                   obd->obd_proc_entry,
                                                   "osd/mntdev");
        if (mgs->mgs_proc_mntdev == NULL)
-               rc = -ENOMEM;
+               GOTO(out, rc = -ENOMEM);
 
        mgs->mgs_proc_fstype = lprocfs_add_symlink("fstype",
                                                   obd->obd_proc_entry,
                                                   "osd/fstype");
        if (mgs->mgs_proc_fstype == NULL)
 
        mgs->mgs_proc_fstype = lprocfs_add_symlink("fstype",
                                                   obd->obd_proc_entry,
                                                   "osd/fstype");
        if (mgs->mgs_proc_fstype == NULL)
-               rc = -ENOMEM;
+               GOTO(out, rc = -ENOMEM);
+
+out:
+       if (rc != 0)
+               lproc_mgs_cleanup(mgs);
 
        return rc;
 }
 
        return rc;
 }
@@ -211,14 +226,16 @@ void lproc_mgs_cleanup(struct mgs_device *mgs)
        if (mgs->mgs_proc_fstype != NULL)
                lprocfs_remove(&mgs->mgs_proc_fstype);
 
        if (mgs->mgs_proc_fstype != NULL)
                lprocfs_remove(&mgs->mgs_proc_fstype);
 
-       if (mgs->mgs_proc_mntdev)
+       if (mgs->mgs_proc_mntdev != NULL)
                lprocfs_remove(&mgs->mgs_proc_mntdev);
                lprocfs_remove(&mgs->mgs_proc_mntdev);
-        if (mgs->mgs_proc_live) {
-                /* Should be no live entries */
-                LASSERT(mgs->mgs_proc_live->subdir == NULL);
-                lprocfs_remove(&mgs->mgs_proc_live);
-                mgs->mgs_proc_live = NULL;
-        }
+
+       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;
+       }
+
         lprocfs_free_per_client_stats(obd);
        lprocfs_obd_cleanup(obd);
         lprocfs_free_obd_stats(obd);
         lprocfs_free_per_client_stats(obd);
        lprocfs_obd_cleanup(obd);
         lprocfs_free_obd_stats(obd);
index 4086200..3c2221b 100644 (file)
@@ -1058,7 +1058,6 @@ static int mgs_init0(const struct lu_env *env, struct mgs_device *mgs,
                     struct lu_device_type *ldt, struct lustre_cfg *lcfg)
 {
        static struct ptlrpc_service_conf        conf;
                     struct lu_device_type *ldt, struct lustre_cfg *lcfg)
 {
        static struct ptlrpc_service_conf        conf;
-       struct lprocfs_static_vars               lvars = { 0 };
        struct obd_device                       *obd;
        struct lustre_mount_info                *lmi;
        struct llog_ctxt                        *ctxt;
        struct obd_device                       *obd;
        struct lustre_mount_info                *lmi;
        struct llog_ctxt                        *ctxt;
@@ -1124,13 +1123,11 @@ static int mgs_init0(const struct lu_env *env, struct mgs_device *mgs,
        mgs->mgs_start_time = cfs_time_current_sec();
        spin_lock_init(&mgs->mgs_lock);
 
        mgs->mgs_start_time = cfs_time_current_sec();
        spin_lock_init(&mgs->mgs_lock);
 
-       /* Setup proc */
-       lprocfs_mgs_init_vars(&lvars);
-       if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
-               lproc_mgs_setup(mgs, lustre_cfg_string(lcfg, 3));
-               rc = lprocfs_alloc_md_stats(obd, LPROC_MGS_LAST);
-               if (rc)
-                       GOTO(err_llog, rc);
+       rc = lproc_mgs_setup(mgs, lustre_cfg_string(lcfg, 3));
+       if (rc != 0) {
+               CERROR("%s: cannot initialize proc entry: rc = %d\n",
+                      obd->obd_name, rc);
+               GOTO(err_llog, rc);
        }
 
        conf = (typeof(conf)) {
        }
 
        conf = (typeof(conf)) {
index df1217c..73e4eef 100644 (file)
@@ -239,18 +239,17 @@ int mgs_client_free(struct obd_export *exp);
 int mgs_fs_setup(const struct lu_env *env, struct mgs_device *m);
 int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *m);
 
 int mgs_fs_setup(const struct lu_env *env, struct mgs_device *m);
 int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *m);
 
-#define strsuf(buf, suffix) (strcmp((buf)+strlen(buf)-strlen(suffix), (suffix)))
 #ifdef LPROCFS
 #ifdef LPROCFS
-int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name);
+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
 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)
-{return 0;}
-static inline int lproc_mgs_cleanup(struct mgs_device *mgs)
+static inline int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name)
 {return 0;}
 {return 0;}
+static inline void lproc_mgs_cleanup(struct mgs_device *mgs)
+{}
 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)
 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)