Whamcloud - gitweb
b=11089
[fs/lustre-release.git] / lustre / mgs / lproc_mgs.c
index acfab55..f5586c2 100644 (file)
 #define DEBUG_SUBSYSTEM S_CLASS
 
 #include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
 #include <asm/statfs.h>
-#endif
 #include <obd.h>
 #include <obd_class.h>
 #include <lprocfs_status.h>
+#include <lustre_param.h>
 #include "mgs_internal.h"
 
-
 #ifdef LPROCFS
 
 static int lprocfs_mgs_rd_mntdev(char *page, char **start, off_t off, int count,
@@ -87,13 +85,64 @@ int lproc_mgs_setup(struct obd_device *obd)
         rc = lprocfs_obd_seq_create(obd, "filesystems", 0444,
                                     &mgs_fs_fops, obd);
         mgs->mgs_proc_live = proc_mkdir("live", obd->obd_proc_entry);
+        obd->obd_proc_exports_entry = proc_mkdir("exports", obd->obd_proc_entry);
 
         return rc;
 }
 
+int lproc_mgs_cleanup(struct obd_device *obd)
+{
+        struct mgs_obd *mgs;
+
+        if (!obd)
+                RETURN(-EINVAL);
+
+        mgs = &obd->u.mgs;
+        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_obd_stats(obd);
+
+        return lprocfs_obd_cleanup(obd);
+}
+
+static void seq_show_srpc_rule(struct seq_file *seq, const char *tgtname,
+                               struct sptlrpc_rule_set *rset)
+{
+        struct sptlrpc_rule    *r;
+        char                    dirbuf[10];
+        char                    flvrbuf[40];
+        char                   *net;
+        int                     i;
+
+        for (i = 0; i < rset->srs_nrule; i++) {
+                r = &rset->srs_rules[i];
+
+                if (r->sr_netid == LNET_NIDNET(LNET_NID_ANY))
+                        net = "default";
+                else
+                        net = libcfs_net2str(r->sr_netid);
+
+                if (r->sr_from == LUSTRE_SP_ANY && r->sr_to == LUSTRE_SP_ANY)
+                        dirbuf[0] = '\0';
+                else
+                        snprintf(dirbuf, sizeof(dirbuf), ".%s2%s",
+                                 sptlrpc_part2name(r->sr_from),
+                                 sptlrpc_part2name(r->sr_to));
+
+                sptlrpc_flavor2name(&r->sr_flvr, flvrbuf, sizeof(flvrbuf));
+                seq_printf(seq, "%s.srpc.flavor.%s%s=%s\n", tgtname,
+                           net, dirbuf, flvrbuf);
+        }
+}
+
 static int mgs_live_seq_show(struct seq_file *seq, void *v) 
 {
-        struct fs_db *fsdb = seq->private;
+        struct fs_db             *fsdb = seq->private;
+        struct mgs_tgt_srpc_conf *srpc_tgt;
         int i;
         
         down(&fsdb->fsdb_sem);
@@ -103,10 +152,22 @@ static int mgs_live_seq_show(struct seq_file *seq, void *v)
                    fsdb->fsdb_flags, fsdb->fsdb_gen);
         for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
                  if (test_bit(i, fsdb->fsdb_mdt_index_map)) 
-                         seq_printf(seq, "%.8s-MDT%04x\n", fsdb->fsdb_name, i);
+                         seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i);
         for (i = 0; i < INDEX_MAP_SIZE * 8; i++)
                  if (test_bit(i, fsdb->fsdb_ost_index_map)) 
-                         seq_printf(seq, "%.8s-OST%04x\n", fsdb->fsdb_name, i);
+                         seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i);
+
+        seq_printf(seq, "\nSecure RPC Config Rules:\n");
+#if 0
+        seq_printf(seq, "%s.%s=%s\n", fsdb->fsdb_name,
+                   PARAM_SRPC_UDESC, fsdb->fsdb_srpc_fl_udesc ? "yes" : "no");
+#endif
+        for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt;
+             srpc_tgt = srpc_tgt->mtsc_next) {
+                seq_show_srpc_rule(seq, srpc_tgt->mtsc_tgt,
+                                   &srpc_tgt->mtsc_rset);
+        }
+        seq_show_srpc_rule(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen);
 
         up(&fsdb->fsdb_sem);
         return 0;
@@ -142,6 +203,7 @@ struct lprocfs_vars lprocfs_mgs_obd_vars[] = {
         { "fstype",          lprocfs_rd_fstype,      0, 0 },
         { "mntdev",          lprocfs_mgs_rd_mntdev,  0, 0 },
         { "num_exports",     lprocfs_rd_num_exports, 0, 0 },
+        { "evict_client",    0, lprocfs_wr_evict_client, 0 },
         { 0 }
 };
 
@@ -149,5 +211,27 @@ struct lprocfs_vars lprocfs_mgs_module_vars[] = {
         { 0 }
 };
 
-LPROCFS_INIT_VARS(mgs, lprocfs_mgs_module_vars, lprocfs_mgs_obd_vars);
+void mgs_counter_incr(struct obd_export *exp, int opcode)
+{
+        lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode);
+        if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL)
+                lprocfs_counter_incr(exp->exp_nid_stats->nid_stats, opcode);
+}
+
+void mgs_stats_counter_init(struct lprocfs_stats *stats)
+{
+        lprocfs_counter_init(stats, LPROC_MGS_CONNECT, 0, "connect", "reqs");
+        lprocfs_counter_init(stats, LPROC_MGS_DISCONNECT, 0, "disconnect",
+                             "reqs");
+        lprocfs_counter_init(stats, LPROC_MGS_EXCEPTION, 0, "exception",
+                             "reqs");
+        lprocfs_counter_init(stats, LPROC_MGS_TARGET_REG, 0, "tgtreg", "reqs");
+        lprocfs_counter_init(stats, LPROC_MGS_TARGET_DEL, 0, "tgtdel", "reqs");
+}
+
+void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
+{
+    lvars->module_vars  = lprocfs_mgs_module_vars;
+    lvars->obd_vars     = lprocfs_mgs_obd_vars;
+}
 #endif