Whamcloud - gitweb
LU-4405 mdc: use ibits_known mask for lock match
[fs/lustre-release.git] / lustre / mgs / lproc_mgs.c
index 65513fd..ffa2d0d 100644 (file)
@@ -27,7 +27,7 @@
  * 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/
@@ -116,53 +116,48 @@ static void seq_show_srpc_rules(struct seq_file *seq, const char *tgtname,
 
 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",
@@ -170,8 +165,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 +176,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 +210,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);