* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
static int mgsself_srpc_seq_show(struct seq_file *seq, void *v)
{
- struct obd_device *obd = seq->private;
- struct mgs_device *mgs;
- struct fs_db *fsdb;
- struct lu_env env;
- int rc;
-
- LASSERT(obd != NULL);
- LASSERT(obd->obd_lu_dev != NULL);
- mgs = lu2mgs_dev(obd->obd_lu_dev);
-
- rc = lu_env_init(&env, LCT_MG_THREAD);
- if (rc)
- return rc;
+ struct obd_device *obd = seq->private;
+ struct mgs_device *mgs = lu2mgs_dev(obd->obd_lu_dev);
+ struct lu_target *tgt = &mgs->mgs_lut;
- rc = mgs_find_or_make_fsdb(&env, mgs, MGSSELF_NAME, &fsdb);
- if (rc)
- goto out;
+ read_lock(&tgt->lut_sptlrpc_lock);
+ seq_show_srpc_rules(seq, MGSSELF_NAME, &tgt->lut_sptlrpc_rset);
+ read_unlock(&tgt->lut_sptlrpc_lock);
- mutex_lock(&fsdb->fsdb_mutex);
- seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen);
- mutex_unlock(&fsdb->fsdb_mutex);
-
-out:
- lu_env_fini(&env);
return 0;
}
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);