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",
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",
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;
}
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);
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;
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)) {
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)