Whamcloud - gitweb
- merge 0.7rc1 from b_devel to HEAD (20030612 merge point)
[fs/lustre-release.git] / lustre / mds / lproc_mds.c
index 37c7bc8..5d6fa57 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 <linux/lustre_lite.h>
 #include <linux/lustre_fsfilt.h>
 #include <linux/lprocfs_status.h>
 
-int rd_uuid(char *page, char **start, off_t off, int count, int *eof,
-            void *data)
-{
-        struct obd_device* temp = (struct obd_device*)data;
-        return snprintf(page, count, "%s\n", temp->obd_uuid);
-}
+#ifndef LPROCFS
+struct lprocfs_vars lprocfs_mds_obd_vars[]  = { {0} };
+struct lprocfs_vars lprocfs_mds_module_vars[] = { {0} };
+struct lprocfs_vars lprocfs_mdt_obd_vars[] = { {0} };
+struct lprocfs_vars lprocfs_mdt_module_vars[] = { {0} };
 
-int rd_blksize(char *page, char **start, off_t off, int count, int *eof,
-               void *data)
-{
-        struct obd_device* temp = (struct obd_device*)data;
-        struct mds_obd *mds = &temp->u.mds;
-        struct statfs mystats;
-        int rc;
-
-        rc = vfs_statfs(mds->mds_sb, &mystats);
-        if (rc) {
-                CERROR("mds: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        return snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
-}
+#else
 
-int rd_kbtotal(char *page, char **start, off_t off, int count, int *eof,
-               void *data)
+static inline int lprocfs_mds_statfs(void *data, struct statfs *sfs)
 {
-        struct obd_device* temp = (struct obd_device*)data;
-        struct mds_obd *mds = &temp->u.mds;
-        struct statfs mystats;
-        int rc;
-        __u32 blk_size;
-        __u64 result;
-
-        rc = vfs_statfs(mds->mds_sb, &mystats);
-        if (rc) {
-                CERROR("mds: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-
-        blk_size = mystats.f_bsize;
-        blk_size >>= 10;
-        result = mystats.f_blocks;
-        while(blk_size >>= 1)
-                result <<= 1;
-
-        return snprintf(page, count, LPU64"\n", result);
-}
+        struct obd_device* dev = (struct obd_device*) data;
+        struct mds_obd *mds;
 
-int rd_kbfree(char *page, char **start, off_t off, int count, int *eof,
-              void *data)
-{
-        struct obd_device* temp = (struct obd_device*)data;
-        struct mds_obd *mds = &temp->u.mds;
-        struct statfs mystats;
-        int rc;
-        __u32 blk_size;
-        __u64 result;
-
-        rc = vfs_statfs(mds->mds_sb, &mystats);
-        if (rc) {
-                CERROR("mds: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        blk_size = mystats.f_bsize;
-        blk_size >>= 10;
-        result = mystats.f_blocks;
-        while (blk_size >>= 1)
-                result <<= 1;
-
-        return snprintf(page, count, LPU64"\n", result);
+        LASSERT(dev != NULL);
+        mds = &dev->u.mds;
+        return vfs_statfs(mds->mds_sb, sfs);
 }
 
+DEFINE_LPROCFS_STATFS_FCT(rd_blksize,     lprocfs_mds_statfs);
+DEFINE_LPROCFS_STATFS_FCT(rd_kbytestotal, lprocfs_mds_statfs);
+DEFINE_LPROCFS_STATFS_FCT(rd_kbytesfree,  lprocfs_mds_statfs);
+DEFINE_LPROCFS_STATFS_FCT(rd_filestotal,  lprocfs_mds_statfs);
+DEFINE_LPROCFS_STATFS_FCT(rd_filesfree,   lprocfs_mds_statfs);
+DEFINE_LPROCFS_STATFS_FCT(rd_filegroups,  lprocfs_mds_statfs);
+
 int rd_fstype(char *page, char **start, off_t off, int count, int *eof,
               void *data)
 {
         struct obd_device *obd = (struct obd_device *)data;
 
+        LASSERT(obd != NULL);
+        LASSERT(obd->obd_fsops != NULL);
+        LASSERT(obd->obd_fsops->fs_type != NULL);
         return snprintf(page, count, "%s\n", obd->obd_fsops->fs_type);
 }
 
-int rd_filestotal(char *page, char **start, off_t off, int count, int *eof,
-                  void *data)
+int lprocfs_mds_rd_mntdev(char *page, char **start, off_t off, int count,
+                          int *eof, void *data)
 {
-        struct obd_device* temp = (struct obd_device*)data;
-        struct mds_obd *mds = &temp->u.mds;
-        struct statfs mystats;
-        int rc;
-
-        rc = vfs_statfs(mds->mds_sb, &mystats);
-        if (rc) {
-                CERROR("mds: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        return snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
-}
+        struct obd_device* obd = (struct obd_device *)data;
 
-int rd_filesfree(char *page, char **start, off_t off, int count, int *eof,
-                 void *data)
-{
-        struct obd_device* temp = (struct obd_device*)data;
-        struct mds_obd *mds = &temp->u.mds;
-        struct statfs mystats;
-        int rc, len = 0;
-
-        rc = vfs_statfs(mds->mds_sb, &mystats);
-        if (rc) {
-                CERROR("mds: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-
-        len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
-        return len;
+        LASSERT(obd != NULL);
+        LASSERT(obd->u.mds.mds_vfsmnt->mnt_devname);
+        *eof = 1;
+        return snprintf(page, count, "%s\n",
+                        obd->u.mds.mds_vfsmnt->mnt_devname);
 }
 
-int rd_filegroups(char *page, char **start, off_t off, int count, int *eof,
-                  void *data)
-{
-        return 0;
-}
-struct lprocfs_vars status_var_nm_1[]={
-        {"status/uuid", rd_uuid, 0, 0},
-        {"status/blocksize",rd_blksize, 0, 0},
-        {"status/kbytestotal",rd_kbtotal, 0, 0},
-        {"status/kbytesfree", rd_kbfree, 0, 0},
-        {"status/fstype", rd_fstype, 0, 0},
-        {"status/filestotal", rd_filestotal, 0, 0},
-        {"status/filesfree", rd_filesfree, 0, 0},
-        {"status/filegroups", rd_filegroups, 0, 0},
-        {0}
+struct lprocfs_vars lprocfs_mds_obd_vars[] = {
+        { "uuid",       lprocfs_rd_uuid, 0, 0 },
+        { "blocksize",  rd_blksize,      0, 0 },
+        { "kbytestotal",rd_kbytestotal,  0, 0 },
+        { "kbytesfree", rd_kbytesfree,   0, 0 },
+        { "fstype",     rd_fstype,       0, 0 },
+        { "filestotal", rd_filestotal,   0, 0 },
+        { "filesfree",  rd_filesfree,    0, 0 },
+        { "filegroups", rd_filegroups,   0, 0 },
+        { "mntdev",     lprocfs_mds_rd_mntdev,    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;
+struct lprocfs_vars lprocfs_mds_module_vars[] = {
+        { "num_refs",   lprocfs_rd_numrefs, 0, 0 },
+        { 0 }
+};
 
-        return snprintf(page, count, "%d\n", class->typ_refcnt);
-}
+struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
+        { "uuid",       lprocfs_rd_uuid, 0, 0 },
+        { 0 }
+};
 
-struct lprocfs_vars status_class_var[]={
-        {"status/num_refs", rd_numrefs, 0, 0},
-        {0}
+struct lprocfs_vars lprocfs_mdt_module_vars[] = {
+        { "num_refs",   lprocfs_rd_numrefs, 0, 0 },
+        { 0 }
 };
+
+#endif
+struct lprocfs_static_vars lprocfs_array_vars[] = { {lprocfs_mds_module_vars,
+                                                     lprocfs_mds_obd_vars},
+                                                    {lprocfs_mdt_module_vars,
+                                                     lprocfs_mdt_obd_vars}};
+
+LPROCFS_INIT_MULTI_VARS(lprocfs_array_vars,
+                        (sizeof(lprocfs_array_vars) /
+                         sizeof(struct lprocfs_static_vars)))