From 7def1195e535add766f47c3fe679e5b60f0f1184 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 11 Mar 2013 22:44:09 -0500 Subject: [PATCH] LU-2484 mgs: remove unused md_stats 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 Change-Id: I8b417bc2433484a0e008ff9bf7fef69ba1e62416 Reviewed-on: http://review.whamcloud.com/4813 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Keith Mannthey Reviewed-by: Oleg Drokin --- lustre/mgs/lproc_mgs.c | 43 ++++++++++++++++++++++++++++++------------- lustre/mgs/mgs_handler.c | 13 +++++-------- lustre/mgs/mgs_internal.h | 9 ++++----- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 65513fd..323fd02 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -145,24 +145,35 @@ out: 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 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); + if (rc != 0) + GOTO(out, rc); + 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); - CERROR("error %d setting up lprocfs for %s\n", rc, "live"); mgs->mgs_proc_live = NULL; + GOTO(out, rc); } 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); - CERROR("error %d setting up lprocfs for %s\n", rc, "exports"); obd->obd_proc_exports_entry = NULL; + GOTO(out, rc); } 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) - 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) - 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) - rc = -ENOMEM; + GOTO(out, rc = -ENOMEM); + +out: + if (rc != 0) + lproc_mgs_cleanup(mgs); 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_mntdev) + if (mgs->mgs_proc_mntdev != NULL) 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); diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 4086200..3c2221b 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -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 lprocfs_static_vars lvars = { 0 }; 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); - /* 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)) { diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index df1217c..73e4eef 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -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); -#define strsuf(buf, suffix) (strcmp((buf)+strlen(buf)-strlen(suffix), (suffix))) #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 -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;} +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) -- 1.8.3.1