/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=8:tabstop=8:
*
- * Copyright (C) 2002 Cluster File Systems, Inc.
+ * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
*
* This file is part of Lustre, http://www.lustre.org.
*
*
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len=0;
- struct obd_device* dev=(struct obd_device*)data;
- len+=snprintf(page, count, "%s\n", dev->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 statfs mystats;
+#include <linux/version.h>
+#include <linux/lprocfs_status.h>
+#include <linux/obd.h>
- int rc, len=0;
+#include "filter_internal.h"
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
- return len;
-
+#ifndef LPROCFS
+static struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
+static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
+#else
-}
-int rd_blktotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+static int lprocfs_filter_rd_mntdev(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
- struct obd_device* temp=(struct obd_device*)data;
- struct statfs mystats;
-
- int rc, len=0;
+ struct obd_device* obd = (struct obd_device *)data;
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: statfs failed: rc %d\n", rc);
- return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_blocks));
- return len;
+ LASSERT(obd != NULL);
+ LASSERT(obd->u.filter.fo_vfsmnt->mnt_devname);
+ *eof = 1;
+ return snprintf(page, count, "%s\n",
+ obd->u.filter.fo_vfsmnt->mnt_devname);
}
-int rd_blkfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+static int lprocfs_filter_rd_last_id(char *page, char **start, off_t off,
+ int count, int *eof, void *data)
{
- struct obd_device* temp=(struct obd_device*)data;
- struct statfs mystats;
-
- int rc, len=0;
+ struct obd_device *obd = data;
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: statfs failed: rc %d\n", rc);
+ if (obd == NULL)
return 0;
- }
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree));
- return len;
-}
-
-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 statfs mystats;
-
- int rc, len=0, blk_size=0;
-
- rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
- if (rc) {
- CERROR("obdfilter: 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;
-
+ return snprintf(page, count, LPU64"\n",
+ filter_last_id(&obd->u.filter, 0));
}
-int rd_fstype(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->u.filter.fo_fstype);
- return len;
-
-}
+static struct lprocfs_vars lprocfs_obd_vars[] = {
+ { "uuid", lprocfs_rd_uuid, 0, 0 },
+ { "blocksize", lprocfs_rd_blksize, 0, 0 },
+ { "kbytestotal", lprocfs_rd_kbytestotal, 0, 0 },
+ { "kbytesfree", lprocfs_rd_kbytesfree, 0, 0 },
+ { "filestotal", lprocfs_rd_filestotal, 0, 0 },
+ { "filesfree", lprocfs_rd_filesfree, 0, 0 },
+ //{ "filegroups", lprocfs_rd_filegroups, 0, 0 },
+ { "fstype", lprocfs_rd_fstype, 0, 0 },
+ { "mntdev", lprocfs_filter_rd_mntdev, 0, 0 },
+ { "last_id", lprocfs_filter_rd_last_id, 0, 0 },
+ { 0 }
+};
-lprocfs_vars_t snmp_var_nm_1[]={
- {"snmp/uuid", rd_uuid, 0},
- {"snmp/f_blocksize",rd_blksize, 0},
- {"snmp/f_blockstotal",rd_blktotal, 0},
- {"snmp/f_blocksfree",rd_blkfree, 0},
- {"snmp/f_kbytesfree", rd_kbfree, 0},
- {"snmp/f_fstype", rd_fstype, 0},
- {0}
+static struct lprocfs_vars lprocfs_module_vars[] = {
+ { "num_refs", lprocfs_rd_numrefs, 0, 0 },
+ { 0 }
};
+
+#endif /* LPROCFS */
+LPROCFS_INIT_VARS(filter,lprocfs_module_vars, lprocfs_obd_vars)