Whamcloud - gitweb
collect more info in checkstack
[fs/lustre-release.git] / lustre / cobd / lproc_cache.c
index 5adcaf8..a40f42d 100644 (file)
  */
 #define DEBUG_SUBSYSTEM S_CLASS
 
-#include <linux/lustre_lite.h>
+#include <linux/obd_class.h>
 #include <linux/lprocfs_status.h>
 
-/*
- * Common STATUS namespace
- */
-
-static int rd_uuid (char *page, char **start, off_t off, int count,
-                    int *eof, void *data)
+#ifndef LPROCFS
+static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
+static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
+#else
+/* Common STATUS namespace */
+static int cobd_rd_target(char *page, char **start, off_t off, int count,
+                          int *eof, void *data)
 {
-        struct obd_device* dev = (struct obd_device*)data;
-
-        return (snprintf(page, count, "%s\n", dev->obd_uuid));
-}
+        struct obd_device *cobd = (struct obd_device *)data;
+        int    rc;
 
-static int rd_target (char *page, char **start, off_t off, int count,
-                      int *eof, void *data)
-{
-        struct obd_device    *dev = (struct obd_device*)data;
-        struct cache_obd     *cobd = &dev->u.cobd;
-       struct lustre_handle *conn = &cobd->cobd_target;
-       struct obd_export    *exp;
-       int    rc;
+        LASSERT(cobd != NULL);
 
-       if ((dev->obd_flags & OBD_SET_UP) == 0)
-               rc = snprintf (page, count, "not set up\n");
-       else {
-               exp = class_conn2export (conn);
-               LASSERT (exp != NULL);
-               rc = snprintf(page, count, "%s\n", exp->exp_obd->obd_uuid);
-       }
-       return (rc);
+        if (!cobd->obd_set_up) {
+                rc = snprintf(page, count, "not set up\n");
+        } else {
+                struct obd_device *tgt =
+                        class_exp2obd(cobd->u.cobd.master_exp);
+                LASSERT(tgt != NULL);
+                rc = snprintf(page, count, "%s\n", tgt->obd_uuid.uuid);
+        }
+        return rc;
 }
 
-static int rd_cache(char *page, char **start, off_t off, int count,
-                    int *eof, void *data)
+static int cobd_rd_cache(char *page, char **start, off_t off, int count,
+                         int *eof, void *data)
 {
-        struct obd_device    *dev = (struct obd_device*)data;
-       struct cache_obd     *cobd = &dev->u.cobd;
-       struct lustre_handle *conn = &cobd->cobd_cache;
-       struct obd_export    *exp;
-       int    rc;
+        struct obd_device *cobd = (struct obd_device*)data;
+        int    rc;
+
+        LASSERT(cobd != NULL);
 
-       if ((dev->obd_flags & OBD_SET_UP) == 0)
-               rc = snprintf (page, count, "not set up\n");
-       else {
-               exp = class_conn2export (conn);
-               LASSERT (exp != NULL);
-               rc = snprintf(page, count, "%s\n", exp->exp_obd->obd_uuid);
-       }
-       return (rc);
+        if (!cobd->obd_set_up) {
+                rc = snprintf(page, count, "not set up\n");
+        } else {
+                struct obd_device *cache =
+                        class_exp2obd(cobd->u.cobd.cache_exp);
+                LASSERT(cache != NULL);
+                rc = snprintf(page, count, "%s\n", cache->obd_uuid.uuid);
+        }
+        return rc;
 }
 
-struct lprocfs_vars status_var_nm_1[] = {
-        {"status/uuid", rd_uuid, 0, 0},
-        {"status/target_uuid", rd_target, 0, 0},
-        {"status/cache_uuid", rd_cache, 0, 0},
-        {0}
+static struct lprocfs_vars lprocfs_obd_vars[] = {
+        { "uuid",         lprocfs_rd_uuid,        0, 0 },
+        { "target_uuid",  cobd_rd_target,         0, 0 },
+        { "cache_uuid",   cobd_rd_cache,          0, 0 },
+        { 0 }
 };
 
-int rd_numrefs(char *page, char **start, off_t off, int count,
-               int *eof, void *data)
-{
-        struct obd_type* class = (struct obd_type*)data;
-
-        return (snprintf(page, count, "%d\n", class->typ_refcnt));
-}
-
-struct lprocfs_vars status_class_var[] = {
-        {"status/num_refs", rd_numrefs, 0, 0},
-        {0}
+struct lprocfs_vars lprocfs_module_vars[] = {
+        { "num_refs",     lprocfs_rd_numrefs,     0, 0 },
+        { 0 }
 };
+#endif /* LPROCFS */
+
+LPROCFS_INIT_VARS(cobd, lprocfs_module_vars, lprocfs_obd_vars)