+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;
+
+ rc = mgs_find_or_make_fsdb(&env, mgs, MGSSELF_NAME, &fsdb);
+ if (rc)
+ goto out;
+
+ 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)
+{
+ 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;
+
+ rc = lprocfs_obd_seq_create(obd, "filesystems", 0444,
+ &mgs_fs_fops, obd);
+ rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0400,
+ &mgsself_srpc_fops, obd);
+
+ 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;
+ }
+
+ obd->obd_proc_exports_entry = lprocfs_register("exports",
+ obd->obd_proc_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;
+ }
+
+ mgs->mgs_proc_osd = lprocfs_add_symlink("osd",
+ obd->obd_proc_entry,
+ "../../%s/%.*s",
+ osd_obd->obd_type->typ_name,
+ osd_len, /* Strip "-osd". */
+ osd_name);
+ if (mgs->mgs_proc_osd == NULL)
+ rc = -ENOMEM;
+
+ mgs->mgs_proc_mntdev = lprocfs_add_symlink("mntdev",
+ obd->obd_proc_entry,
+ "osd/mntdev");
+ if (mgs->mgs_proc_mntdev == NULL)
+ rc = -ENOMEM;
+
+ mgs->mgs_proc_fstype = lprocfs_add_symlink("fstype",
+ obd->obd_proc_entry,
+ "osd/fstype");
+ if (mgs->mgs_proc_fstype == NULL)
+ rc = -ENOMEM;
+
+ return rc;
+}
+
+void lproc_mgs_cleanup(struct mgs_device *mgs)
+{
+ struct obd_device *obd = mgs->mgs_obd;
+
+ if (obd == NULL)
+ return;
+
+ if (mgs->mgs_proc_osd != NULL)
+ lprocfs_remove(&mgs->mgs_proc_osd);
+
+ if (mgs->mgs_proc_fstype != NULL)
+ lprocfs_remove(&mgs->mgs_proc_fstype);
+
+ if (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;
+ }
+ lprocfs_free_per_client_stats(obd);
+ lprocfs_obd_cleanup(obd);
+ lprocfs_free_obd_stats(obd);
+ lprocfs_free_md_stats(obd);
+}
+
+static int mgs_live_seq_show(struct seq_file *seq, void *v)