*/
#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>
+#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_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_device* temp=(struct obd_device*)data;
- int len=0;
- len+=snprintf(page, count, "%s\n", temp->obd_uuid);
- return len;
-}
-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, 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_bsize));
- return len;
+#else
-}
-int rd_blktotal(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, 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_blocks));
- return len;
-
-}
+ struct obd_device* dev = (struct obd_device*) data;
+ struct mds_obd *mds;
-int rd_blkfree(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_bfree));
- return len;
-
+ LASSERT(dev != NULL);
+ mds = &dev->u.mds;
+ return vfs_statfs(mds->mds_sb, sfs);
}
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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* temp=(struct obd_device*)data;
- struct mds_obd *mds=&temp->u.mds;
- struct statfs mystats;
- int rc, blk_size, len=0;
-
- rc = vfs_statfs(mds->mds_sb, &mystats);
- if (rc) {
- CERROR("mds: statfs failed: rc %d\n", rc);
- return 0;
- }
- blk_size=mystats.f_bsize;
- len+=snprintf(page, count, LPU64"\n",
- (__u64)((mystats.f_bfree)/(blk_size*1024)));
- return len;
-
-}
+ struct obd_device *obd = (struct obd_device *)data;
-int rd_fstype(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;
- int len=0;
- len+=snprintf(page, count, "%s\n", mds->mds_fstype);
- return len;
-
+ 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_ffiles(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_files));
- return len;
-
-}
+struct lprocfs_vars lprocfs_mds_obd_vars[] = {
+ { "uuid", lprocfs_rd_uuid, 0, 0 },
+ { "blocksize", rd_blksize, 0, 0 },
+ { "bytestotal", 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 },
+ { 0 }
+};
-int rd_inodesfree(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;
-}
+struct lprocfs_vars lprocfs_mds_module_vars[] = {
+ { "num_refs", lprocfs_rd_numrefs, 0, 0 },
+ { 0 }
+};
-int rd_filesets(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},
- {"status/f_blocksize",rd_blksize, 0},
- {"status/f_blockstotal",rd_blktotal, 0},
- {"status/f_blocksfree",rd_blkfree, 0},
- {"status/f_kbytesfree", rd_kbfree, 0},
- {"status/f_fstype", rd_fstype, 0},
- {"status/f_files", rd_ffiles, 0},
- {"status/f_inodesfree", rd_inodesfree, 0},
- {"status/f_filesets", rd_filesets, 0},
- {0}
+struct lprocfs_vars lprocfs_mdt_obd_vars[] = {
+ { "uuid", lprocfs_rd_uuid, 0, 0 },
+ { 0 }
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- struct obd_type* class=(struct obd_type*)data;
- int len=0;
- len+=snprintf(page, count, "%d\n", class->typ_refcnt);
- return len;
-}
-struct lprocfs_vars status_class_var[]={
- {"status/num_devices", rd_numdevices, 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)))