to insert two devices with the same ID in a router configuration.
2. Added LDLM counters into /proc/lustre hierarchy
3. Fixes for Andreas's comments in Bug #357.
4. Bug #332 fixed, num_devices replaced with num_refs
5. Removed file proc_lustre.c, which was dead code.
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Top level header file for LProc SNMP
+ * Author: Hariharan Thantry thantry@users.sourceforge.net
*/
#ifndef _LPROCFS_SNMP_H
#define _LPROCFS_SNMP_H
-/*
+
#ifndef LPROC_SNMP
#define LPROC_SNMP
#endif
-*/
#include <linux/proc_fs.h>
+typedef enum {
+ E_LPROC_OK = 0
+} lproc_error_t;
+
struct lprocfs_vars{
- char *name;
- read_proc_t *read_fptr;
- write_proc_t *write_fptr;
+
+ char* name;
+ read_proc_t* read_fptr;
+ write_proc_t* write_fptr;
+ void* data;
};
#ifdef LPROC_SNMP
static inline struct proc_dir_entry* lprocfs_reg_mnt(char *name)
{
- return 0;
+ return NULL;
}
static inline int lprocfs_dereg_mnt(struct proc_dir_entry* root)
struct list_head ns_root_list; /* all root resources in ns */
struct lustre_lock ns_lock; /* protects hash, refcount, list */
struct list_head ns_list_chain; /* position in global NS list */
+ /*
struct proc_dir_entry *ns_proc_dir;
+ */
struct list_head ns_unused_list; /* all root resources in ns */
unsigned int ns_nr_unused;
obd_uuid_t ll_sb_uuid;
struct lustre_handle ll_mdc_conn;
struct lustre_handle ll_osc_conn;
- struct proc_dir_entry* ll_mnt_root;
+ struct proc_dir_entry* ll_proc_root;
obd_id ll_rootino; /* number of root inode */
int ll_flags;
spinlock_t ldlm_namespace_lock = SPIN_LOCK_UNLOCKED;
struct list_head ldlm_namespace_list = LIST_HEAD_INIT(ldlm_namespace_list);
static struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
-extern struct proc_dir_entry proc_root;
int ldlm_proc_setup(struct obd_device *obd)
{
ENTRY;
-
LASSERT(ldlm_ns_proc_dir == NULL);
-
- ldlm_ns_proc_dir = proc_mkdir("ldlm", &proc_root);
- if (ldlm_ns_proc_dir == NULL) {
- CERROR("Couldn't create /proc/ldlm\n");
- RETURN(-EPERM);
- }
+ ldlm_ns_proc_dir=obd->obd_type->typ_procroot;
RETURN(0);
}
void ldlm_proc_cleanup(struct obd_device *obd)
{
- remove_proc_entry("ldlm", &proc_root);
+ ldlm_ns_proc_dir = NULL;
}
-/* FIXME: This can go away when we start to really use lprocfs */
-static int ldlm_proc_ll_rd(char *page, char **start, off_t off,
- int count, int *eof, void *data)
+#define MAX_STRING_SIZE 100
+void ldlm_proc_namespace(struct ldlm_namespace *ns)
{
- int len;
- __u64 *temp = (__u64 *)data;
-
- len = snprintf(page, count, "%Lu\n", *temp);
+ struct lprocfs_vars lock_vars[2];
+ char lock_names[MAX_STRING_SIZE];
+
+ memset(lock_vars, 0, sizeof(lock_vars));
+ snprintf(lock_names, MAX_STRING_SIZE, "%s/resource_count",
+ ns->ns_name);
+ lock_names[MAX_STRING_SIZE] = '\0';
+ lock_vars[0].name = lock_names;
+ lock_vars[0].read_fptr = lprocfs_ll_rd;
+ lock_vars[0].write_fptr = NULL;
+ lock_vars[0].data = &ns->ns_resources;
+ lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
+
+ memset(lock_vars, 0, sizeof(lock_vars));
+ snprintf(lock_names, MAX_STRING_SIZE, "%s/lock_count", ns->ns_name);
+ lock_names[MAX_STRING_SIZE] = '\0';
+ lock_vars[0].name = lock_names;
+ lock_vars[0].read_fptr = lprocfs_ll_rd;
+ lock_vars[0].write_fptr = NULL;
+ lock_vars[0].data = &ns->ns_locks;
+ lprocfs_add_vars(ldlm_ns_proc_dir, lock_vars, 0);
- return len;
}
+#undef MAX_STRING_SIZE
#define LDLM_MAX_UNUSED 20
struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 client)
{
struct ldlm_namespace *ns = NULL;
struct list_head *bucket;
- struct proc_dir_entry *proc_entry;
+
+
OBD_ALLOC(ns, sizeof(*ns));
if (!ns) {
spin_lock(&ldlm_namespace_lock);
list_add(&ns->ns_list_chain, &ldlm_namespace_list);
spin_unlock(&ldlm_namespace_lock);
-
- ns->ns_proc_dir = proc_mkdir(ns->ns_name, ldlm_ns_proc_dir);
- if (ns->ns_proc_dir == NULL)
- CERROR("Unable to create proc directory for namespace.\n");
- proc_entry = create_proc_entry("resource_count", 0444, ns->ns_proc_dir);
- proc_entry->read_proc = ldlm_proc_ll_rd;
- proc_entry->data = &ns->ns_resources;
- proc_entry = create_proc_entry("lock_count", 0444, ns->ns_proc_dir);
- proc_entry->read_proc = ldlm_proc_ll_rd;
- proc_entry->data = &ns->ns_locks;
-
+ ldlm_proc_namespace(ns);
RETURN(ns);
out:
spin_lock(&ldlm_namespace_lock);
list_del(&ns->ns_list_chain);
- remove_proc_entry("resource_count", ns->ns_proc_dir);
- remove_proc_entry("lock_count", ns->ns_proc_dir);
- remove_proc_entry(ns->ns_name, ldlm_ns_proc_dir);
+
spin_unlock(&ldlm_namespace_lock);
ldlm_namespace_cleanup(ns, 0);
#include <linux/lprocfs_status.h>
-
-int rd_path(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_path(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
-
return 0;
-
}
-int rd_fstype(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_fstype(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
+ int len = 0;
+ struct super_block *sb = (struct super_block*)data;
- len+=snprintf(page, count, "%s\n", sb->s_type->name);
+ len += snprintf(page, count, "%s\n", sb->s_type->name);
return len;
}
-int rd_blksize(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_blksize(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
+ int len = 0;
+ struct super_block *sb = (struct super_block*)data;
struct statfs mystats;
+
(sb->s_op->statfs)(sb, &mystats);
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
+ len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
return len;
}
-int rd_kbytestotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbytestotal(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
+ int len = 0;
+ struct super_block *sb = (struct super_block*)data;
struct statfs mystats;
- (sb->s_op->statfs)(sb, &mystats);
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_blocks));
- return len;
-
-}
+ __u32 blk_size;
+ __u64 result;
-int rd_blkfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
- struct statfs mystats;
(sb->s_op->statfs)(sb, &mystats);
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree));
+ blk_size = mystats.f_bsize;
+ blk_size >>= 10;
+ result = mystats.f_blocks;
+
+ while(blk_size >>= 1){
+ result <<= 1;
+ }
+
+ len += snprintf(page, count, LPU64"\n", result);
return len;
-
}
-int rd_kbytesfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+
+int rd_kbytesfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
+ int len = 0;
+ struct super_block *sb = (struct super_block*)data;
struct statfs mystats;
- long blk_size=0;
-
+ __u32 blk_size;
+ __u64 result;
+
(sb->s_op->statfs)(sb, &mystats);
- blk_size=mystats.f_bsize;
-
- len+=snprintf(page, count, LPU64"\n",
- (__u64)((mystats.f_bfree)/(blk_size*1024)));
- return len;
+ blk_size = mystats.f_bsize;
+ blk_size >>= 10;
+ result = mystats.f_bfree;
+
+ while(blk_size >>= 1){
+ result <<= 1;
+ }
+
+ len += snprintf(page, count, LPU64"\n", result);
+ return len;
+
}
-int rd_filestotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_filestotal(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
-
+ int len = 0;
+ struct super_block *sb = (struct super_block*)data;
struct statfs mystats;
-
(sb->s_op->statfs)(sb, &mystats);
-
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
+ len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
return len;
}
-int rd_filesfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_filesfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
-
+ int len = 0;
+ struct super_block *sb = (struct super_block*)data;
struct statfs mystats;
-
(sb->s_op->statfs)(sb, &mystats);
-
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
+ len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
return len;
}
-int rd_filegroups(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_filegroups(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_uuid(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- struct super_block *sb=(struct super_block*)data;
- struct ll_sb_info *sbi=ll_s2sbi(sb);
- len+=snprintf(page, count, "%s\n", sbi->ll_sb_uuid);
+ int len = 0;
+ struct super_block *sb = (struct super_block*)data;
+ struct ll_sb_info *sbi = ll_s2sbi(sb);
+ len += snprintf(page, count, "%s\n", sbi->ll_sb_uuid);
return len;
}
-int rd_dev_name(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_dev_name(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_name);
+ int len = 0;
+ struct obd_device* dev = (struct obd_device*)data;
+ len += snprintf(page, count, "%s\n", dev->obd_name);
return len;
}
-int rd_dev_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_dev_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);
+ int len = 0;
+ struct obd_device* dev = (struct obd_device*)data;
+ len += snprintf(page, count, "%s\n", dev->obd_uuid);
return len;
}
-struct lprocfs_vars status_var_nm_1[]={
- {"status/uuid", rd_uuid, 0},
- {"status/mntpt_path", rd_path, 0},
- {"status/fs_type", rd_fstype, 0},
- {"status/blocksize",rd_blksize, 0},
- {"status/kbytestotal",rd_kbytestotal, 0},
- {"status/kbytesfree", rd_kbytesfree, 0},
- {"status/filestotal", rd_filestotal, 0},
- {"status/filesfree", rd_filesfree, 0},
- {"status/filegroups", rd_filegroups, 0},
+struct lprocfs_vars status_var_nm_1[] = {
+ {"status/uuid", rd_uuid, 0, 0},
+ {"status/mntpt_path", rd_path, 0, 0},
+ {"status/fs_type", rd_fstype, 0, 0},
+ {"status/blocksize",rd_blksize, 0, 0},
+ {"status/kbytestotal",rd_kbytestotal, 0, 0},
+ {"status/kbytesfree", rd_kbytesfree, 0, 0},
+ {"status/filestotal", rd_filestotal, 0, 0},
+ {"status/filesfree", rd_filesfree, 0, 0},
+ {"status/filegroups", rd_filegroups, 0, 0},
{0}
};
+
+/*
+ * Proc registration function for Lustre
+ * file system
+ */
+
+
+#define MAX_STRING_SIZE 100
+void ll_proc_namespace(struct super_block* sb, char* osc, char* mdc)
+{
+ char mnt_name[MAX_STRING_SIZE];
+ char uuid_name[MAX_STRING_SIZE];
+ struct lprocfs_vars d_vars[3];
+ struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct obd_device* obd;
+ int err;
+
+
+ /* Register this mount instance with LProcFS */
+ snprintf(mnt_name, 100, "mount_%s", sbi->ll_sb_uuid);
+ sbi->ll_proc_root = lprocfs_reg_mnt(mnt_name);
+ if (!sbi->ll_proc_root)
+ CDEBUG(D_OTHER, "Could not register FS");
+ /* Add the static configuration info */
+ err = lprocfs_add_vars(sbi->ll_proc_root,status_var_nm_1, sb);
+ if (err)
+ CDEBUG(D_OTHER, "Unable to add procfs variables\n");
+
+ /* MDC */
+ obd = class_uuid2obd(mdc);
+
+
+ snprintf(mnt_name, MAX_STRING_SIZE, "status/%s/common_name",
+ obd->obd_type->typ_name);
+
+ memset(d_vars, 0, sizeof(d_vars));
+ d_vars[0].read_fptr = rd_dev_name;
+ d_vars[0].write_fptr = NULL;
+ d_vars[0].name = mnt_name;
+
+ snprintf(uuid_name, MAX_STRING_SIZE, "status/%s/uuid",
+ obd->obd_type->typ_name);
+ d_vars[1].read_fptr = rd_dev_uuid;
+ d_vars[1].write_fptr = NULL;
+ d_vars[1].name = uuid_name;
+
+ err = lprocfs_add_vars(sbi->ll_proc_root, d_vars, obd);
+ if (err)
+ CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
+
+ /* OSC or LOV*/
+ obd = class_uuid2obd(osc);
+
+ /* Reuse mnt_name */
+ snprintf(mnt_name, MAX_STRING_SIZE, "status/%s/common_name",
+ obd->obd_type->typ_name);
+
+ memset(d_vars, 0, sizeof(d_vars));
+ d_vars[0].read_fptr = rd_dev_name;
+ d_vars[0].write_fptr = NULL;
+ d_vars[0].name = mnt_name;
+
+ snprintf(uuid_name, MAX_STRING_SIZE, "status/%s/uuid",
+ obd->obd_type->typ_name);
+ d_vars[1].read_fptr = rd_dev_uuid;
+ d_vars[1].write_fptr = NULL;
+ d_vars[1].name = uuid_name;
+
+ err = lprocfs_add_vars(sbi->ll_proc_root, d_vars, obd);
+ if (err)
+ CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
+
+}
+#undef MAX_STRING_SIZE
#include <linux/fs.h>
#include <linux/lprocfs_status.h>
-
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
kmem_cache_t *ll_file_data_slab;
extern struct address_space_operations ll_aops;
extern int ll_commitcbd_setup(struct ll_sb_info *);
extern int ll_commitcbd_cleanup(struct ll_sb_info *);
-extern int rd_dev_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data);
-
-extern int rd_dev_name(char* page, char **start, off_t off,
- int count, int *eof, void *data);
-
-
-extern struct lprocfs_vars status_var_nm_1[];
+extern void ll_proc_namespace(struct super_block* sb, char* osc, char* mdc);
static char *ll_read_opt(const char *opt, char *data)
{
struct ll_read_inode2_cookie lic;
class_uuid_t uuid;
- /* Lprocfs variables */
- char mnt_name[100];
- char uuid_name[100];
- struct lprocfs_vars d_vars[3];
+
ENTRY;
MOD_INC_USE_COUNT;
ptlrpc_req_finished(request);
request = NULL;
-
- /* Register this mount instance with LProcFS */
- snprintf(mnt_name, 100, "mount_%s", sbi->ll_sb_uuid);
- sbi->ll_mnt_root = lprocfs_reg_mnt(mnt_name);
- if (!sbi->ll_mnt_root)
- goto out_dev;
-
- /* Add the static configuration info */
- err = lprocfs_add_vars(sbi->ll_mnt_root,
- (struct lprocfs_vars *)status_var_nm_1, sb);
- if (err)
- CDEBUG(D_OTHER, "Unable to add procfs variables\n");
-
- /* MDC */
- obd = class_uuid2obd(mdc);
-
- /* Reuse mnt_name */
- sprintf(mnt_name, "status/%s/common_name", obd->obd_type->typ_name);
-
- memset(d_vars, 0, sizeof(d_vars));
- d_vars[0].read_fptr = rd_dev_name;
- d_vars[0].write_fptr = NULL;
- d_vars[0].name = mnt_name;
-
- snprintf(uuid_name, strlen(uuid_name), "status/%s/uuid",
- obd->obd_type->typ_name);
- d_vars[1].read_fptr = rd_dev_uuid;
- d_vars[1].write_fptr = NULL;
- d_vars[1].name = uuid_name;
-
- err = lprocfs_add_vars(sbi->ll_mnt_root, (struct lprocfs_vars *)d_vars,
- obd);
- if (err)
- CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
-
- /* OSC or LOV*/
- obd = class_uuid2obd(osc);
-
- /* Reuse mnt_name */
- snprintf(mnt_name, strlen(mnt_name), "status/%s/common_name",
- obd->obd_type->typ_name);
-
- memset(d_vars, 0, sizeof(d_vars));
- d_vars[0].read_fptr = rd_dev_name;
- d_vars[0].write_fptr = NULL;
- d_vars[0].name = mnt_name;
-
- snprintf(uuid_name, strlen(uuid_name), "status/%s/uuid",
- obd->obd_type->typ_name);
- d_vars[1].read_fptr = rd_dev_uuid;
- d_vars[1].write_fptr = NULL;
- d_vars[1].name = uuid_name;
-
- err = lprocfs_add_vars(sbi->ll_mnt_root, (struct lprocfs_vars *)d_vars,
- obd);
- if (err)
- CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables\n");
+ ll_proc_namespace(sb, osc, mdc);
out_dev:
if (mdc)
*/
mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
- lprocfs_dereg_mnt(sbi->ll_mnt_root);
+ lprocfs_dereg_mnt(sbi->ll_proc_root);
+ sbi->ll_proc_root=0;
+
obd_disconnect(&sbi->ll_mdc_conn);
spin_lock(&dcache_lock);
#include <linux/lustre_dlm.h>
#include <linux/init.h>
#include <linux/fs.h>
+#include <linux/lprocfs_status.h>
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
kmem_cache_t *ll_file_data_slab;
extern int ll_commitcbd_cleanup(struct ll_sb_info *);
int ll_read_inode2(struct inode *inode, void *opaque);
+extern void ll_proc_namespace(struct super_block* sb, char* osc, char* mdc)
+
static char *ll_read_opt(const char *opt, char *data)
{
char *value;
ptlrpc_req_finished(request);
request = NULL;
-
+ ll_proc_namespace(sb, osc, mdc)
out_dev:
if (mdc)
OBD_FREE(mdc, strlen(mdc) + 1);
*/
mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
+ lprocfs_dereg_mnt(sbi->ll_proc_root);
+ sbi->ll_proc_root=0;
+
obd_disconnect(&sbi->ll_mdc_conn);
OBD_FREE(sbi, sizeof(*sbi));
int lov_attach(struct obd_device *dev,
obd_count len, void *data)
{
- int rc;
- rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return rc;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int lov_detach(struct obd_device *dev)
{
- int rc;
- rc = lprocfs_dereg_obd(dev);
- return rc;
-
- }
+ return lprocfs_dereg_obd(dev);
+}
struct obd_ops lov_obd_ops = {
o_attach: lov_attach,
static int __init lov_init(void)
{
int rc;
-
printk(KERN_INFO "Lustre Logical Object Volume driver " LOV_VERSION
", info@clusterfs.com\n");
lov_file_cache = kmem_cache_create("ll_lov_file_data",
0, 0, NULL, NULL);
if (!lov_file_cache)
RETURN(-ENOMEM);
-
- rc = class_register_type(&lov_obd_ops,
- (struct lprocfs_vars*)status_class_var,
+ rc = class_register_type(&lov_obd_ops, status_class_var,
OBD_LOV_DEVICENAME);
- if (rc)
- RETURN(rc);
-
- return 0;
+ RETURN(rc);
}
static void __exit lov_exit(void)
* Common STATUS namespace
*/
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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);
+ int len = 0;
+ struct obd_device* dev = (struct obd_device*)data;
+ len += snprintf(page, count, "%s\n", dev->obd_uuid);
return len;
}
-int rd_stripesize(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_stripesize(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0;
- struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n",
- (__u64)(lov->desc.ld_default_stripe_size));
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0;
+ struct lov_obd* lov = &dev->u.lov;
+ len += snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_default_stripe_size));
return len;
}
-int rd_stripeoffset(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_stripeoffset(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0;
- struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n",
- lov->desc.ld_default_stripe_offset);
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0;
+ struct lov_obd* lov = &dev->u.lov;
+ len += snprintf(page, count, LPU64"\n",
+ lov->desc.ld_default_stripe_offset);
return len;
}
-int rd_stripetype(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_stripetype(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0;
- struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n",
- (__u64)(lov->desc.ld_pattern));
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0;
+ struct lov_obd* lov = &dev->u.lov;
+ len += snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_pattern));
return len;
}
-int rd_stripecount(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_stripecount(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0;
- struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n",
- (__u64)(lov->desc.ld_default_stripe_count));
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0;
+ struct lov_obd* lov = &dev->u.lov;
+ len += snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_default_stripe_count));
return len;
}
-int rd_numobd(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numobd(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0;
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0;
struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n",
- (__u64)(lov->desc.ld_tgt_count));
+ len += snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_tgt_count));
return len;
}
-int rd_activeobd(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_activeobd(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0;
- struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, LPU64"\n",
- (__u64)(lov->desc.ld_active_tgt_count));
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0;
+ struct lov_obd* lov = &dev->u.lov;
+ len += snprintf(page, count, LPU64"\n",
+ (__u64)(lov->desc.ld_active_tgt_count));
return len;
}
-int rd_blksize(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_blksize(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_blktotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbtotal(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_blkfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- return 0;
-}
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_numobjects(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numobjects(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_objfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_objfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_objgroups(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_objgroups(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_target(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_target(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0, i=0;
- struct lov_obd* lov=&dev->u.lov;
- struct lov_tgt_desc* tgts=lov->tgts;
- while(i<lov->desc.ld_tgt_count){
- len+=snprintf(page, count, "%d: %s\n", i, tgts->uuid);
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0, i = 0;
+ struct lov_obd* lov = &dev->u.lov;
+ struct lov_tgt_desc* tgts = lov->tgts;
+ while(i < lov->desc.ld_tgt_count){
+ len += snprintf(page, count, "%d: %s\n", i, tgts->uuid);
i++;
tgts++;
}
return len;
}
-int rd_mdc(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_mdc(char* page, char **start, off_t off, int count, int *eof, void *data)
{
- struct obd_device* dev=(struct obd_device*)data;
- int len=0;
- struct lov_obd* lov=&dev->u.lov;
- len+=snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid);
+ struct obd_device* dev = (struct obd_device*)data;
+ int len = 0;
+ struct lov_obd* lov = &dev->u.lov;
+ len += snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid);
return len;
}
-struct lprocfs_vars status_var_nm_1[]={
- {"status/uuid", rd_uuid, 0},
- {"status/stripesize",rd_stripesize, 0},
- {"status/stripeoffset",rd_stripeoffset, 0},
- {"status/stripecount",rd_stripecount, 0},
- {"status/stripetype", rd_stripetype, 0},
- {"status/numobd",rd_numobd, 0},
- {"status/activeobd", rd_activeobd, 0},
- {"status/objects", rd_numobjects, 0},
- {"status/objectsfree", rd_objfree, 0},
- {"status/objectgroups", rd_objgroups, 0},
- {"status/blocksize", rd_blksize, 0},
- {"status/blockstotal", rd_blktotal, 0},
- {"status/kbytesfree", rd_kbfree, 0},
- {"status/blocksfree", rd_blkfree, 0},
- {"status/target_obd", rd_target, 0},
- {"status/target_mdc", rd_mdc, 0},
+struct lprocfs_vars status_var_nm_1[] = {
+ {"status/uuid", rd_uuid, 0, 0},
+ {"status/stripesize",rd_stripesize, 0, 0},
+ {"status/stripeoffset",rd_stripeoffset, 0, 0},
+ {"status/stripecount",rd_stripecount, 0, 0},
+ {"status/stripetype", rd_stripetype, 0, 0},
+ {"status/numobd",rd_numobd, 0, 0},
+ {"status/activeobd", rd_activeobd, 0, 0},
+ {"status/objects", rd_numobjects, 0, 0},
+ {"status/objectsfree", rd_objfree, 0, 0},
+ {"status/objectgroups", rd_objgroups, 0, 0},
+ {"status/blocksize", rd_blksize, 0, 0},
+ {"status/kbytestotal", rd_kbtotal, 0, 0},
+ {"status/kbytesfree", rd_kbfree, 0, 0},
+ {"status/target_obd", rd_target, 0, 0},
+ {"status/target_mdc", rd_mdc, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
#include <linux/lprocfs_status.h>
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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);
+ 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)
+int rd_blksize(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
-
return 0;
-
}
-int rd_kbtotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbtotal(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_files(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_files(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_filesfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_filesfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_filegroups(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_filegroups(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_conn_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_conn_uuid(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* temp=(struct obd_device*)data;
- struct client_obd* cli=&temp->u.cli;
- struct obd_import* imp=&cli->cl_import;
- int len=0;
- len+=snprintf(page, count, "%s\n",imp->imp_connection->c_remote_uuid);
+ struct obd_device* temp = (struct obd_device*)data;
+ struct client_obd* cli = &temp->u.cli;
+ struct obd_import* imp = &cli->cl_import;
+ int len = 0;
+
+ len += snprintf(page, count, "%s\n",imp->imp_connection->c_remote_uuid);
return len;
}
-int rd_server_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_server_uuid(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* temp=(struct obd_device*)data;
- struct client_obd* cli=&temp->u.cli;
- int len=0;
- len+=snprintf(page, count, "%s\n",cli->cl_target_uuid);
+ struct obd_device* temp = (struct obd_device*)data;
+ struct client_obd* cli = &temp->u.cli;
+ int len = 0;
+
+ len += snprintf(page, count, "%s\n",cli->cl_target_uuid);
return len;
}
-int rd_server_name(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_server_name(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/blocksize",rd_blksize, 0},
- {"status/kbytestotal",rd_kbtotal, 0},
- {"status/kbytesfree", rd_kbfree, 0},
- {"status/files", rd_files, 0},
- {"status/filesfree", rd_filesfree, 0},
- {"status/filegroups", rd_filegroups, 0},
- {"status/server_uuid", rd_server_uuid, 0},
- {"status/conn_uuid", rd_conn_uuid, 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/files", rd_files, 0, 0},
+ {"status/filesfree", rd_filesfree, 0, 0},
+ {"status/filegroups", rd_filegroups, 0, 0},
+ {"status/mds_server_uuid", rd_server_uuid, 0, 0},
+ {"status/mds_conn_uuid", rd_conn_uuid, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+struct lprocfs_vars status_class_var[] = {
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
int mdc_attach(struct obd_device *dev,
obd_count len, void *data)
{
- int rc;
- rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return rc;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int mdc_detach(struct obd_device *dev)
{
- int rc;
- rc = lprocfs_dereg_obd(dev);
- return rc;
-
+ return lprocfs_dereg_obd(dev);
}
struct obd_ops mdc_obd_ops = {
o_attach: mdc_attach,
static int __init ptlrpc_request_init(void)
{
- int rc;
- rc = class_register_type(&mdc_obd_ops,
- (struct lprocfs_vars*)status_class_var,
- LUSTRE_MDC_NAME);
- if(rc)
- RETURN(rc);
- return 0;
-
+ return class_register_type(&mdc_obd_ops, status_class_var,
+ LUSTRE_MDC_NAME);
}
static void __exit ptlrpc_request_exit(void)
{
-
class_unregister_type(LUSTRE_MDC_NAME);
-
}
MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
int mds_attach(struct obd_device *dev,
obd_count len, void *data)
{
- int rc;
- rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return rc;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int mds_detach(struct obd_device *dev)
{
- int rc;
- rc = lprocfs_dereg_obd(dev);
- return rc;
-
+ return lprocfs_dereg_obd(dev);
}
static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
if (mds_file_cache == NULL)
return -ENOMEM;
- class_register_type(&mds_obd_ops,
- (struct lprocfs_vars*)status_class_var,
- LUSTRE_MDS_NAME);
+ class_register_type(&mds_obd_ops, status_class_var, LUSTRE_MDS_NAME);
class_register_type(&mdt_obd_ops, 0, LUSTRE_MDT_NAME);
-
ldlm_register_intent(ldlm_intent_policy);
-
return 0;
}
#include <linux/lustre_lite.h>
#include <linux/lprocfs_status.h>
-
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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);
+ 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)
+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 obd_device* temp = (struct obd_device*)data;
+ struct mds_obd *mds = &temp->u.mds;
struct statfs mystats;
- int rc, len=0;
+ 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));
+ len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize));
return len;
}
-int rd_blktotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbtotal(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 obd_device* temp = (struct obd_device*)data;
+ struct mds_obd *mds = &temp->u.mds;
struct statfs mystats;
- int rc, len=0;
+ int rc, len = 0;
+ __u32 blk_size;
+ __u64 result;
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;
-
-}
-
-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;
+ blk_size = mystats.f_bsize;
+ blk_size >>= 10;
+ result = mystats.f_blocks;
+ while(blk_size >>= 1){
+ result <<= 1;
}
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree));
+ len += snprintf(page, count, LPU64"\n", result);
return len;
}
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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 obd_device* temp = (struct obd_device*)data;
+ struct mds_obd *mds = &temp->u.mds;
struct statfs mystats;
- int rc, blk_size, len=0;
+ int rc, len = 0;
+ __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;
- len+=snprintf(page, count, LPU64"\n",
- (__u64)((mystats.f_bfree)/(blk_size*1024)));
+ blk_size = mystats.f_bsize;
+ blk_size >>= 10;
+ result = mystats.f_blocks;
+ while(blk_size >>= 1){
+ result <<= 1;
+ }
+ len += snprintf(page, count, LPU64"\n", result);
return len;
-
+
}
-int rd_fstype(char* page, char **start, off_t off,
- int count, int *eof, void *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);
+ 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;
}
-int rd_ffiles(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_files(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 obd_device* temp = (struct obd_device*)data;
+ struct mds_obd *mds = &temp->u.mds;
struct statfs mystats;
- int rc, len=0;
+ int rc, len = 0;
rc = vfs_statfs(mds->mds_sb, &mystats);
if (rc) {
return 0;
}
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
+ len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
return len;
}
-int rd_inodesfree(char* page, char **start, off_t off,
- int count, int *eof, void *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 obd_device* temp = (struct obd_device*)data;
+ struct mds_obd *mds = &temp->u.mds;
struct statfs mystats;
- int rc, len=0;
+ int rc, len = 0;
rc = vfs_statfs(mds->mds_sb, &mystats);
if (rc) {
return 0;
}
- len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
+ len += snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
return len;
}
-int rd_filesets(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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},
+ {"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/files", rd_files, 0, 0},
+ {"status/filesfree", rd_filesfree, 0, 0},
+ {"status/filesets", rd_filesets, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
MODULE = obdclass
modulefs_DATA = obdclass.o
EXTRA_PROGRAMS = obdclass
-obdclass_SOURCES = debug.c genops.c proc_lustre.c class_obd.c sysctl.c uuid.c \
- lprocfs_status.c
-
+obdclass_SOURCES = debug.c genops.c class_obd.c sysctl.c uuid.c lprocfs_status.c
include $(top_srcdir)/Rules
list_add(&type->typ_chain, &obd_types);
memcpy(type->typ_ops, ops, sizeof(*type->typ_ops));
strcpy(type->typ_name, nm);
- rc = lprocfs_reg_class(type, (struct lprocfs_vars*)vars, (void*)type);
+ rc = lprocfs_reg_class(type, vars, type);
RETURN(rc);
}
* You should have received a copy of the GNU General Public License
* along with Lustre; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
+ *
+ * Author: Hariharan Thantry thantry@users.sourceforge.net
*/
-
#define EXPORT_SYMTAB
#include <linux/config.h>
#include <linux/module.h>
#include <linux/types.h>
#define DEBUG_SUBSYSTEM S_CLASS
-#define MAX_STRING_SIZE 100
-
#include <linux/lustre_lite.h>
#include <linux/lprocfs_status.h>
struct proc_dir_entry *parent)
{
struct proc_dir_entry *child_dir_entry;
-
child_dir_entry = proc_mkdir(dname, parent);
-
if (!child_dir_entry)
CERROR("lustre: failed to create /proc entry %s\n", dname);
-
return child_dir_entry;
}
const char* name)
{
struct proc_dir_entry* temp;
-
if (!head)
return NULL;
-
temp = head->subdir;
while (temp != NULL) {
if (!strcmp(temp->name, name))
return temp;
temp = temp->next;
}
-
return NULL;
}
}
}
+#define MAX_STRING_SIZE 100
struct proc_dir_entry* lprocfs_new_dir(struct proc_dir_entry* root,
const char* string, const char* tok)
{
- struct proc_dir_entry* new_root = 0;
- struct proc_dir_entry* temp_entry = 0;
+ struct proc_dir_entry* new_root;
+ struct proc_dir_entry* temp_entry;
char temp_string[MAX_STRING_SIZE];
char* my_str;
char* mover_str;
strncpy(temp_string, string, MAX_STRING_SIZE-1);
- temp_string[strlen(string) + 1] = '\0';
+ temp_string[MAX_STRING_SIZE] = '\0';
new_root = root;
mover_str = temp_string;
CDEBUG(D_OTHER, "SEARCH= %s\t, ROOT=%s\n", my_str,
new_root->name);
temp_entry = lprocfs_srch(new_root, my_str);
- if (temp_entry == 0) {
+ if (temp_entry == NULL) {
CDEBUG(D_OTHER, "Adding: %s\n", my_str);
temp_entry = lprocfs_mkdir(my_str, new_root);
- if (temp_entry == 0) {
+ if (temp_entry == NULL) {
CDEBUG(D_OTHER,
"! Did not create new dir %s !!\n",
my_str);
- return 0;
+ return temp_entry;
}
}
new_root = temp_entry;
}
-
return new_root;
}
-int lprocfs_new_vars(struct proc_dir_entry* root, struct lprocfs_vars* list,
+int lprocfs_new_vars(struct proc_dir_entry* root,
+ struct lprocfs_vars* list,
const char* tok, void* data)
{
struct proc_dir_entry *temp_root;
while (list->name) {
temp_root = lprocfs_new_dir(root, list->name, tok);
-
- if (!temp_root) {
+ if (temp_root == NULL) {
CDEBUG(D_OTHER, "!LProcFS: Mods: No root!");
- return -EINVAL;
+ return PTR_ERR(temp_root);
}
/* Convert the last element into a leaf-node */
strncpy(temp_string, temp_root->name, MAX_STRING_SIZE-1);
- temp_string[strlen(temp_root->name) + 1] = '\0';
+ temp_string[MAX_STRING_SIZE] = '\0';
new_parent = temp_root->parent;
remove_proc_entry(temp_root->name, new_parent);
-
new_leaf = create_proc_entry(temp_string, DEFAULT_MODE,
new_parent);
new_leaf->read_proc = list->read_fptr;
new_leaf->write_proc = list->write_fptr;
- new_leaf->data = data;
+ if (data)
+ new_leaf->data=data;
+ else
+ new_leaf->data=list->data;
list++;
}
return 0;
-}
+}
+#undef MAX_STRING_SIZE
/*
* API implementations
*/
int lprocfs_reg_obd(struct obd_device *device, struct lprocfs_vars *list,
void *data)
{
+ struct proc_dir_entry* this_dev_root = NULL;
int retval = 0;
- struct proc_dir_entry* this_dev_root = 0;
+
+ if(lprocfs_srch(device->obd_type->typ_procroot, device->obd_name)){
+ CDEBUG(D_OTHER, "Device with name [%s] exists!",
+ device->obd_name);
+ return 0;
+ }
/* Obtain this device root */
this_dev_root = lprocfs_mkdir(device->obd_name,
CDEBUG(D_OTHER, "! LProcfs: Null pointer !\n");
return 0;
}
-
+ if (!device->obd_proc_entry) {
+ CDEBUG(D_OTHER, "! Proc entry non-existent !");
+ return 0;
+ }
lprocfs_remove_all(device->obd_proc_entry);
-
+ device->obd_proc_entry = 0;
if (device->counters)
OBD_FREE(device->counters, device->cntr_mem_size);
struct proc_dir_entry* lprocfs_reg_mnt(char* mnt_name)
{
+ if(lprocfs_srch(proc_lustre_fs_root, mnt_name)){
+ CDEBUG(D_OTHER, "Mount with same name exists!");
+ return 0;
+ }
return lprocfs_mkdir(mnt_name, proc_lustre_fs_root);
}
int lprocfs_dereg_mnt(struct proc_dir_entry* root)
{
+ if(root == NULL){
+ CDEBUG(D_OTHER, "Non-existent root!");
+ return 0;
+ }
lprocfs_remove_all(root);
return 0;
}
int lprocfs_reg_class(struct obd_type* type, struct lprocfs_vars* list,
void* data)
{
+
struct proc_dir_entry* root;
int retval;
-
root = lprocfs_mkdir(type->typ_name, proc_lustre_dev_root);
-
+ lprocfs_add_vars(root, list, data);
type->typ_procroot = root;
-
retval = lprocfs_add_vars(root, list, data);
-
return retval;
}
class->typ_name);
return 0;
}
-
lprocfs_remove_all(class->typ_procroot);
-
+ class->typ_procroot = 0;
CDEBUG(D_OTHER, "LPROCFS removed = %s\n", class->typ_name);
-
return 0;
}
int lprocfs_reg_main()
{
proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
- if (!proc_lustre_root) {
+ if (proc_lustre_root == NULL) {
CERROR(" !! Cannot create /proc/lustre !! \n");
return -EINVAL;
}
proc_lustre_dev_root = lprocfs_mkdir("devices", proc_lustre_root);
- if (!proc_lustre_dev_root) {
+ if (proc_lustre_dev_root == NULL) {
CERROR(" !! Cannot create /proc/lustre/devices !! \n");
return -EINVAL;
}
proc_lustre_fs_root = lprocfs_mkdir("mnt_pnt", proc_lustre_root);
- if (!proc_lustre_fs_root) {
+ if (proc_lustre_fs_root == NULL) {
CERROR(" !! Cannot create /proc/lustre/mnt_pnt !! \n");
return -EINVAL;
}
{
__u64 *temp = (__u64 *)data;
int len;
-
len = snprintf(page, count, LPU64"\n", *temp);
-
return len;
}
+++ /dev/null
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- * proc_lustre.c manages /proc/lustre
- *
- * Copyright (c) 2001 Rumi Zahir <rumi.zahir@intel.com>
- *
- * This file is part of Lustre, http://www.lustre.org.
- *
- * Lustre is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public
- * License as published by the Free Software Foundation.
- *
- * Lustre is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Lustre; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-/* OBD devices materialize in /proc as a directory:
- * /proc/lustre/obd/<number>
- * when /dev/obd<number> is opened. When the device is closed, the
- * directory entry disappears.
- *
- * For each open OBD device, code in this file also creates a file
- * named <status>. "cat /proc/lustre/obd/<number>/status" gives
- * information about the OBD device's configuration.
- * The class driver manages the "status" entry.
- *
- * Other logical drivers can create their own entries. For example,
- * the obdtrace driver creates /proc/lustre/obd/<obdid>/stats entry.
- *
- * This file defines three functions
- * proc_lustre_register_obd_device() - called at device attach time
- * proc_lustre_release_obd_device() - called at detach
- * proc_lustre_remove_obd_entry()
- * that dynamically create/delete /proc/lustre/obd entries:
- *
- * proc_lustre_register_obd_device() registers an obd device,
- * and, if this is the first OBD device, creates /proc/lustre/obd.
- *
- * proc_lustre_release_obd_device() removes device information
- * from /proc/lustre/obd, and if this is the last OBD device
- * removes /proc/lustre/obd.
- *
- * proc_lustre_remove_obd_entry() removes a
- * /proc/lustre/obd/<obdid>/ entry by name. This is the only
- * function that is exported to other modules.
- */
-
-#define EXPORT_SYMTAB
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/proc_fs.h>
-
-#define DEBUG_SUBSYSTEM S_CLASS
-
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-
-#ifdef CONFIG_PROC_FS
-extern struct proc_dir_entry proc_root;
-static struct proc_dir_entry *proc_lustre_dir_entry = NULL;
-static struct proc_dir_entry *proc_lustre_obd_dir_entry = NULL;
-
-static int read_lustre_status(char *page, char **start, off_t offset,
- int count, int *eof, void *data)
-{
- struct obd_device * obddev = (struct obd_device *)data;
- int p;
-
-#warning FIXME: This function is madness, completely unsafe, a disaster waiting to happen.
-
- p = sprintf(&page[0], "device=%d\n", obddev->obd_minor);
- p += sprintf(&page[p], "name=%s\n", MKSTR(obddev->obd_name));
- p += sprintf(&page[p], "uuid=%s\n", obddev->obd_uuid);
- p += sprintf(&page[p], "attached=1\n");
- p += sprintf(&page[p], "type=%s\n", MKSTR(obddev->obd_type->typ_name));
-
- if (obddev->obd_flags & OBD_SET_UP)
- p += sprintf(&page[p], "setup=1\n");
-
- /* print exports */
- {
- struct list_head *lh;
- struct obd_export *export = NULL;
-
- lh = &obddev->obd_exports;
- while ((lh = lh->next) != &obddev->obd_exports) {
- p += sprintf(&page[p],
- ((export == NULL) ? ", connections(" : ",") );
- export = list_entry(lh, struct obd_export,
- exp_obd_chain);
- p += sprintf(&page[p], "%p", export);
- }
- if (export != 0) { /* there was at least one export */
- p += sprintf(&page[p], ")");
- }
- }
-
- p += sprintf(&page[p], "\n");
-
- /* Compute eof and return value */
- if (offset + count >= p) {
- *eof = 1;
- return (p - offset);
- }
- return count;
-}
-
-struct proc_dir_entry *proc_lustre_register_obd_device(struct obd_device *obd)
-{
- struct proc_dir_entry *obd_dir;
- struct proc_dir_entry *obd_status = NULL;
-
- if (!proc_lustre_dir_entry) {
- proc_lustre_dir_entry = proc_mkdir("lustre", &proc_root);
- if (IS_ERR(proc_lustre_dir_entry))
- return 0;
-
- proc_lustre_obd_dir_entry =
- proc_mkdir("devices", proc_lustre_dir_entry);
- if (IS_ERR(proc_lustre_obd_dir_entry))
- return 0;
- }
- obd_dir = proc_mkdir(obd->obd_name, proc_lustre_obd_dir_entry);
-
- if (obd_dir)
- obd_status = create_proc_entry("status", S_IRUSR | S_IFREG,
- obd_dir);
-
- if (obd_status) {
- obd_status->read_proc = read_lustre_status;
- obd_status->data = (void *)obd;
- }
-
- return obd_dir;
-}
-
-void proc_lustre_remove_obd_entry(const char *name, struct obd_device *obd)
-{
- struct proc_dir_entry *obd_entry = NULL;
- struct proc_dir_entry *obd_dir = obd->obd_proc_entry;
-
- remove_proc_entry(name, obd_dir);
-
- while (obd_dir->subdir == NULL) {
- /* if we removed last entry in this directory, then
- * remove parent directory unless this is /proc itself */
- if (obd_dir == &proc_root)
- break;
-
- obd_entry = obd_dir;
- obd_dir = obd_dir->parent;
-
- /* If /proc/lustre/obd/foo or /proc/lustre/obd or
- * /proc/lustre is being removed, then reset internal
- * variables */
-
- if (obd_entry == obd->obd_proc_entry)
- obd->obd_proc_entry = NULL; /* /proc/lustre/obd/foo */
- else if (obd_entry == proc_lustre_obd_dir_entry)
- proc_lustre_obd_dir_entry = NULL; /* /proc/lustre/obd */
- else if (obd_entry == proc_lustre_dir_entry)
- proc_lustre_dir_entry = NULL; /* /proc/lustre */
-
- remove_proc_entry(obd_entry->name, obd_dir);
- }
- obd->obd_proc_entry = NULL;
-}
-
-void proc_lustre_release_obd_device(struct obd_device *obd)
-{
- proc_lustre_remove_obd_entry("status", obd);
-}
-
-
-#else /* CONFIG_PROC_FS */
-
-struct proc_dir_entry *proc_lustre_register_obd_device(struct obd_device *obd)
-{
- return 0;
-}
-
-void proc_lustre_remove_obd_entry(const char* name, struct obd_device *obd)
-{
-}
-
-void proc_lustre_release_obd_device(struct obd_device *obd)
-{
-}
-
-#endif /* CONFIG_PROC_FS */
-
-EXPORT_SYMBOL(proc_lustre_remove_obd_entry);
* and Andreas Dilger <adilger@clusterfs.com>
*/
-static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.46 2002/11/08 19:02:41 adilger Exp $";
-#define OBDECHO_VERSION "$Revision: 1.46 $"
+static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.47 2002/11/13 02:46:41 thantry Exp $";
+#define OBDECHO_VERSION "$Revision: 1.47 $"
#define EXPORT_SYMTAB
int echo_attach(struct obd_device *dev,
obd_count len, void *data)
{
- int rc;
- rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return rc;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int echo_detach(struct obd_device *dev)
{
- int rc;
- rc = lprocfs_dereg_obd(dev);
- return rc;
-
+ return lprocfs_dereg_obd(dev);
}
" info@clusterfs.com\n");
echo_proc_init();
- rc = class_register_type(&echo_obd_ops,
- (struct lprocfs_vars*)status_class_var,
+ rc = class_register_type(&echo_obd_ops, status_class_var,
OBD_ECHO_DEVICENAME);
- if (rc) RETURN(rc);
+ RETURN(rc);
- return 0;
}
{
echo_proc_fini();
-
class_unregister_type(OBD_ECHO_DEVICENAME);
}
#include <linux/lprocfs_status.h>
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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);
+ int len = 0;
+ struct obd_device* dev = (struct obd_device*)data;
+ len += snprintf(page, count, "%s\n", dev->obd_uuid);
return len;
}
-int rd_fstype(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_fstype(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->u.echo.eo_fstype);
+ int len = 0;
+ struct obd_device* dev = (struct obd_device*)data;
+ len += snprintf(page, count, "%s\n", dev->u.echo.eo_fstype);
return len;
}
-struct lprocfs_vars status_var_nm_1[]={
- {"status/uuid", rd_uuid, 0},
- {"status/fstype", rd_fstype, 0},
+struct lprocfs_vars status_var_nm_1[] = {
+ {"status/uuid", rd_uuid, 0, 0},
+ {"status/fstype", rd_fstype, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+struct lprocfs_vars status_class_var[] = {
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
int filter_attach(struct obd_device *dev,
obd_count len, void *data)
{
-
- int rc;
- rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return rc;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int filter_detach(struct obd_device *dev)
{
- int rc;
- rc = lprocfs_dereg_obd(dev);
- return rc;
-
+ return lprocfs_dereg_obd(dev);
}
static struct obd_ops filter_obd_ops = {
o_attach: filter_attach,
RETURN(-ENOMEM);
}
- return class_register_type(&filter_obd_ops,
- (struct lprocfs_vars*)status_class_var,
+ return class_register_type(&filter_obd_ops, status_class_var,
OBD_FILTER_DEVICENAME);
}
#include <linux/lprocfs_status.h>
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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);
+ 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)
+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 obd_device* temp = (struct obd_device*)data;
struct statfs mystats;
-
- int len=0;
+ int len = 0;
vfs_statfs(temp->u.filter.fo_sb, &mystats);
-
len+=snprintf(page, count, "%ld\n", mystats.f_bsize);
return len;
-
-
}
-int rd_kbtotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbtotal(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* temp=(struct obd_device*)data;
+ struct obd_device* temp = (struct obd_device*)data;
struct statfs mystats;
- int len=0;
+ int len = 0;
+ __u32 blk_size;
__u64 result;
vfs_statfs(temp->u.filter.fo_sb, &mystats);
-
- result=((__u64)(mystats.f_blocks*mystats.f_bsize))>>10;
-
+ blk_size = mystats.f_bsize;
+ blk_size >>= 10;
+ result = mystats.f_blocks;
+ while(blk_size >>= 1){
+ result <<= 1;
+ }
len+=snprintf(page, count, LPU64"\n", result);
-
return len;
}
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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 obd_device* temp = (struct obd_device*)data;
struct statfs mystats;
-
- int len=0;
+ int len = 0;
+ __u32 blk_size;
__u64 result;
vfs_statfs(temp->u.filter.fo_sb, &mystats);
- result=((__u64)(mystats.f_bfree*mystats.f_bsize))>>10;
-
- len+=snprintf(page, count, LPU64"\n", result);
+ blk_size = mystats.f_bsize;
+ blk_size >>= 10;
+ result = mystats.f_bfree;
+ while(blk_size >>= 1){
+ result <<= 1;
+ }
+ len += snprintf(page, count, LPU64"\n", result);
return len;
}
-int rd_fstype(char* page, char **start, off_t off,
- int count, int *eof, void *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;
- int len=0;
-
- len+=snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
+ struct obd_device* temp = (struct obd_device*)data;
+ int len = 0;
+ len += snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
return len;
-
}
-int rd_files(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_files(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
-
- struct obd_device* temp=(struct obd_device*)data;
+ struct obd_device* temp = (struct obd_device*)data;
struct statfs mystats;
-
- int len=0;
-
- vfs_statfs(temp->u.filter.fo_sb, &mystats);
-
- len+=snprintf(page, count, "%ld\n", mystats.f_files);
+ int len = 0;
+ vfs_statfs(temp->u.filter.fo_sb, &mystats);
+ len += snprintf(page, count, "%ld\n", mystats.f_files);
return len;
}
-int rd_filesfree(char* page, char **start, off_t off,
- int count, int *eof, void *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 obd_device* temp = (struct obd_device*)data;
struct statfs mystats;
-
- int len=0;
-
+ int len = 0;
vfs_statfs(temp->u.filter.fo_sb, &mystats);
-
- len+=snprintf(page, count, "%ld\n", mystats.f_ffree);
+ len += snprintf(page, count, "%ld\n", mystats.f_ffree);
return len;
-
-
}
-struct lprocfs_vars status_var_nm_1[]={
- {"status/uuid", rd_uuid, 0},
- {"status/blocksize",rd_blksize, 0},
- {"status/kbytestotal",rd_kbtotal, 0},
- {"status/kbytesfree", rd_kbfree, 0},
- {"status/files", rd_files, 0},
- {"status/filesfree", rd_filesfree, 0},
- {"status/fstype", rd_fstype, 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/files", rd_files, 0, 0},
+ {"status/filesfree", rd_filesfree, 0, 0},
+ {"status/fstype", rd_fstype, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+struct lprocfs_vars status_class_var[] = {
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
#include <linux/lustre_lite.h>
#include <linux/lprocfs_status.h>
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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);
+ 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)
+int rd_blksize(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_blktotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_blktotal(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_blkfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_blkfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_numobjects(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numobjects(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_objfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_objfree(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_objgroups(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_objgroups(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
return 0;
}
-int rd_server_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_server_uuid(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* temp=(struct obd_device*)data;
- struct client_obd* cli=&temp->u.cli;
- int len=0;
- len+=snprintf(page, count, "%s\n",cli->cl_target_uuid);
+ struct obd_device* temp = (struct obd_device*)data;
+ struct client_obd* cli = &temp->u.cli;
+ int len = 0;
+ len += snprintf(page, count, "%s\n",cli->cl_target_uuid);
return len;
}
-int rd_conn_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_conn_uuid(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
struct obd_device* temp=(struct obd_device*)data;
struct client_obd* cli=&temp->u.cli;
struct obd_import* imp=&cli->cl_import;
- int len=0;
- len+=snprintf(page, count, "%s\n",\
- imp->imp_connection->c_remote_uuid);
+ int len = 0;
+ len += snprintf(page, count, "%s\n",
+ imp->imp_connection->c_remote_uuid);
return len;
}
-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_objects", rd_numobjects, 0},
- {"status/f_objectsfree", rd_objfree, 0},
- {"status/f_objectgroups", rd_objgroups, 0},
- {"status/ost_server_uuid", rd_server_uuid, 0},
- {"status/ost_conn_uuid", rd_conn_uuid, 0},
+struct lprocfs_vars status_var_nm_1[] = {
+ {"status/uuid", rd_uuid, 0, 0},
+ {"status/f_blocksize",rd_blksize, 0, 0},
+ {"status/f_blockstotal",rd_blktotal, 0, 0},
+ {"status/f_blocksfree",rd_blkfree, 0, 0},
+ {"status/f_kbytesfree", rd_kbfree, 0, 0},
+ {"status/f_objects", rd_numobjects, 0, 0},
+ {"status/f_objectsfree", rd_objfree, 0, 0},
+ {"status/f_objectgroups", rd_objgroups, 0, 0},
+ {"status/ost_server_uuid", rd_server_uuid, 0, 0},
+ {"status/ost_conn_uuid", rd_conn_uuid, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+struct lprocfs_vars status_class_var[] = {
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
int osc_attach(struct obd_device *dev,
obd_count len, void *data)
{
- int rc;
- rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return rc;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int osc_detach(struct obd_device *dev)
{
- int rc;
- rc = lprocfs_dereg_obd(dev);
- return rc;
-
+ return lprocfs_dereg_obd(dev);
}
struct obd_ops osc_obd_ops = {
o_attach: osc_attach,
static int __init osc_init(void)
{
int rc;
-
- rc = class_register_type(&osc_obd_ops,
- (struct lprocfs_vars*)status_class_var,
+ rc = class_register_type(&osc_obd_ops, status_class_var,
LUSTRE_OSC_NAME);
- if (rc)
- RETURN(rc);
- return 0;
-
+ RETURN(rc);
+
}
static void __exit osc_exit(void)
#include <linux/lprocfs_status.h>
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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);
+ 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)
+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 ost_obd *ost=&temp->u.ost;
- struct lustre_handle *conn=&ost->ost_conn;
+ struct obd_device* temp = (struct obd_device*)data;
+ struct ost_obd *ost = &temp->u.ost;
+ struct lustre_handle *conn = &ost->ost_conn;
struct obd_statfs mystats;
- int len=0;
+ int len = 0;
obd_statfs(conn, &mystats);
- len+=snprintf(page, count, "%d\n", mystats.os_bsize);
+ len += snprintf(page, count, "%d\n", mystats.os_bsize);
return len;
}
-int rd_kbtotal(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_kbtotal(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- struct obd_device* temp=(struct obd_device*)data;
- struct ost_obd *ost=&temp->u.ost;
- struct lustre_handle *conn=&ost->ost_conn;
+ struct obd_device* temp = (struct obd_device*)data;
+ struct ost_obd *ost = &temp->u.ost;
+ struct lustre_handle *conn = &ost->ost_conn;
struct obd_statfs mystats;
- int len=0;
+ int len = 0;
__u32 blk_size;
__u64 result;
-
-
+
obd_statfs(conn, &mystats);
-
- blk_size=mystats.os_bsize;
- blk_size>>=10;
-
- result=mystats.os_blocks;
-
- while(blk_size>>=1){
- result<<=1;
+ blk_size = mystats.os_bsize;
+ blk_size >>= 10;
+ result = mystats.os_blocks;
+ while(blk_size >>= 1){
+ result <<= 1;
}
-
- len+=snprintf(page, count, LPU64"\n", result);
+ len += snprintf(page, count, LPU64"\n", result);
return len;
-
-
+
}
-int rd_kbfree(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+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 ost_obd *ost=&temp->u.ost;
- struct lustre_handle *conn=&ost->ost_conn;
+ struct obd_device* temp = (struct obd_device*)data;
+ struct ost_obd *ost = &temp->u.ost;
+ struct lustre_handle *conn = &ost->ost_conn;
struct obd_statfs mystats;
- int len=0;
+ int len = 0;
__u32 blk_size;
__u64 result;
obd_statfs(conn, &mystats);
-
- blk_size=mystats.os_bsize;
- blk_size>>=10;
-
- result=mystats.os_bfree;
-
- while(blk_size>>=1){
- result<<=1;
+ blk_size = mystats.os_bsize;
+ blk_size >>= 10;
+ result = mystats.os_bfree;
+ while(blk_size >>= 1){
+ result <<= 1;
}
-
- len+=snprintf(page, count, LPU64"\n", result);
+ len += snprintf(page, count, LPU64"\n", result);
return len;
-
}
-int rd_files(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_files(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
-
- struct obd_device* temp=(struct obd_device*)data;
- struct ost_obd *ost=&temp->u.ost;
- struct lustre_handle *conn=&ost->ost_conn;
+ struct obd_device* temp = (struct obd_device*)data;
+ struct ost_obd *ost = &temp->u.ost;
+ struct lustre_handle *conn = &ost->ost_conn;
struct obd_statfs mystats;
- int len=0;
+ int len = 0;
obd_statfs(conn, &mystats);
-
- len+=snprintf(page, count, LPU64"\n",mystats.os_files);
+ len += snprintf(page, count, LPU64"\n",mystats.os_files);
return len;
}
-int rd_filesfree(char* page, char **start, off_t off,
- int count, int *eof, void *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 ost_obd *ost=&temp->u.ost;
- struct lustre_handle *conn=&ost->ost_conn;
+ struct obd_device* temp = (struct obd_device*)data;
+ struct ost_obd *ost = &temp->u.ost;
+ struct lustre_handle *conn = &ost->ost_conn;
struct obd_statfs mystats;
- int len=0;
+ int len = 0;
obd_statfs(conn, &mystats);
- len+=snprintf(page, count, LPU64"\n", mystats.os_ffree);
+ len += snprintf(page, count, LPU64"\n", mystats.os_ffree);
return len;
}
-int rd_objgroups(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_objgroups(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/blocksize",rd_blksize, 0},
- {"status/kbytesfree", rd_kbfree, 0},
- {"status/kbytestotal", rd_kbtotal, 0},
- {"status/files", rd_files, 0},
- {"status/filesfree", rd_filesfree, 0},
- {"status/objectgroups", rd_objgroups, 0},
+struct lprocfs_vars status_var_nm_1[] = {
+ {"status/uuid", rd_uuid, 0, 0},
+ {"status/blocksize",rd_blksize, 0, 0},
+ {"status/kbytesfree", rd_kbfree, 0, 0},
+ {"status/kbytestotal", rd_kbtotal, 0, 0},
+ {"status/files", rd_files, 0, 0},
+ {"status/filesfree", rd_filesfree, 0, 0},
+ {"status/objectgroups", rd_objgroups, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+struct lprocfs_vars status_class_var[] = {
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
+
int ost_attach(struct obd_device *dev,
obd_count len, void *data)
{
- /* lprocfs_reg_dev(dev, (lprocfs_group_t*)lprocfs_ptlrpc_nm,
- sizeof(struct lprofiler_ptlrpc));
- */
- lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return 0;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int ost_detach(struct obd_device *dev)
{
- /* lprocfs_dereg_dev(dev); */
- lprocfs_dereg_obd(dev);
- return 0;
-
+ return lprocfs_dereg_obd(dev);
+
}
{
int rc;
- rc = class_register_type(&ost_obd_ops,
- (struct lprocfs_vars*)status_class_var,
+ rc = class_register_type(&ost_obd_ops, status_class_var,
LUSTRE_OST_NAME);
- if (rc) RETURN(rc);
-
- return 0;
+ RETURN(rc);
}
#include <linux/lustre_lite.h>
#include <linux/lprocfs_status.h>
-int rd_uuid(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_uuid(char* page, char **start, off_t off, int count, int *eof,
+ void *data)
{
- int len=0;
- len+=snprintf(page, count, "%s\n",
- ((struct obd_device*)data)->obd_uuid);
+ int len = 0;
+ len += snprintf(page, count, "%s\n",
+ ((struct obd_device*)data)->obd_uuid);
return len;
-
}
-struct lprocfs_vars status_var_nm_1[]={
- {"status/uuid", rd_uuid, 0},
+struct lprocfs_vars status_var_nm_1[] = {
+ {"status/uuid", rd_uuid, 0, 0},
{0}
};
-int rd_numdevices(char* page, char **start, off_t off,
- int count, int *eof, void *data)
+int rd_numrefs(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);
+ 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},
+struct lprocfs_vars status_class_var[] = {
+ {"status/num_refs", rd_numrefs, 0, 0},
{0}
};
int connmgr_attach(struct obd_device *dev,
obd_count len, void *data)
{
- int rc;
- rc = lprocfs_reg_obd(dev, (struct lprocfs_vars*)status_var_nm_1,
- (void*)dev);
- return rc;
+ return lprocfs_reg_obd(dev, status_var_nm_1, dev);
}
int conmgr_detach(struct obd_device *dev)
{
- int rc;
- rc = lprocfs_dereg_obd(dev);
- return rc;
-
+ return lprocfs_dereg_obd(dev);
}
/* use obd ops to offer management infrastructure */
static struct obd_ops recovd_obd_ops = {
RETURN(rc);
ptlrpc_init_connection();
rc = class_register_type(&recovd_obd_ops,
- (struct lprocfs_vars*)status_class_var,
+ status_class_var,
LUSTRE_HA_NAME);
if (rc)
RETURN(rc);
ptlrpc_put_connection_superhack = ptlrpc_put_connection;
-
- if (rc)
- RETURN(rc);
-
return 0;
}