From: thantry Date: Wed, 13 Nov 2002 02:46:41 +0000 (+0000) Subject: 1. Bug fix for Bug #320, also needs repair of lconf, since it tries X-Git-Tag: 0.5.17~19 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=404d2dc2fc01f49ae469a3e7c81bac431bd84936;p=fs%2Flustre-release.git 1. Bug fix for Bug #320, also needs repair of lconf, since it tries 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. --- diff --git a/lustre/include/linux/lprocfs_status.h b/lustre/include/linux/lprocfs_status.h index 0a8a2a9..e769f43 100644 --- a/lustre/include/linux/lprocfs_status.h +++ b/lustre/include/linux/lprocfs_status.h @@ -19,22 +19,28 @@ * 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 +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 @@ -87,7 +93,7 @@ static inline int lprocfs_dereg_obd(struct obd_device* device) 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) diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h index d63d095..f8a6715 100644 --- a/lustre/include/linux/lustre_dlm.h +++ b/lustre/include/linux/lustre_dlm.h @@ -101,7 +101,9 @@ struct ldlm_namespace { 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; diff --git a/lustre/include/linux/lustre_lite.h b/lustre/include/linux/lustre_lite.h index a2657d8..93b92cc 100644 --- a/lustre/include/linux/lustre_lite.h +++ b/lustre/include/linux/lustre_lite.h @@ -77,7 +77,7 @@ struct ll_sb_info { 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; diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 494b74e..53b835a 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -19,45 +19,55 @@ kmem_cache_t *ldlm_resource_slab, *ldlm_lock_slab; 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) { @@ -98,17 +108,7 @@ struct ldlm_namespace *ldlm_namespace_new(char *name, __u32 client) 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: @@ -207,9 +207,7 @@ int ldlm_namespace_free(struct ldlm_namespace *ns) 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); diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 0c34215..b3c4a0f 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -25,151 +25,223 @@ #include - -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 diff --git a/lustre/llite/super.c b/lustre/llite/super.c index 7635fc8..580a88a 100644 --- a/lustre/llite/super.c +++ b/lustre/llite/super.c @@ -22,7 +22,6 @@ #include #include - #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) kmem_cache_t *ll_file_data_slab; extern struct address_space_operations ll_aops; @@ -33,14 +32,7 @@ extern int ll_recover(struct recovd_data *, int); 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) { @@ -120,10 +112,7 @@ static struct super_block * ll_read_super(struct super_block *sb, 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; @@ -234,63 +223,7 @@ static struct super_block * ll_read_super(struct super_block *sb, 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) @@ -333,7 +266,9 @@ static void ll_put_super(struct super_block *sb) */ 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); diff --git a/lustre/llite/super25.c b/lustre/llite/super25.c index 7af645b..4521ea4 100644 --- a/lustre/llite/super25.c +++ b/lustre/llite/super25.c @@ -20,6 +20,7 @@ #include #include #include +#include #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) kmem_cache_t *ll_file_data_slab; @@ -34,6 +35,8 @@ extern int ll_commitcbd_setup(struct ll_sb_info *); 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; @@ -219,7 +222,7 @@ static int ll_fill_super(struct super_block *sb, void *data, int silent) ptlrpc_req_finished(request); request = NULL; - + ll_proc_namespace(sb, osc, mdc) out_dev: if (mdc) OBD_FREE(mdc, strlen(mdc) + 1); @@ -266,6 +269,9 @@ static void ll_put_super(struct super_block *sb) */ 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)); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index af37ded..0ebde79 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1359,19 +1359,13 @@ static int lov_iocontrol(long cmd, struct lustre_handle *conn, int len, 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, @@ -1400,7 +1394,6 @@ struct obd_ops lov_obd_ops = { 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", @@ -1408,14 +1401,9 @@ static int __init lov_init(void) 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) diff --git a/lustre/lov/lproc_lov.c b/lustre/lov/lproc_lov.c index 8ad5a5b..97bc841 100644 --- a/lustre/lov/lproc_lov.c +++ b/lustre/lov/lproc_lov.c @@ -28,184 +28,177 @@ * 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(idesc.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} }; diff --git a/lustre/mdc/lproc_mdc.c b/lustre/mdc/lproc_mdc.c index 8fc9fa6..357c1de 100644 --- a/lustre/mdc/lproc_mdc.c +++ b/lustre/mdc/lproc_mdc.c @@ -25,104 +25,104 @@ #include -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} }; diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 40a1e38..6fc0ff1 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -640,18 +640,12 @@ out: 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, @@ -665,21 +659,13 @@ struct obd_ops mdc_obd_ops = { 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 "); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 90060cf..4c334fd 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1454,18 +1454,12 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie, 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) @@ -1549,13 +1543,9 @@ static int __init mds_init(void) 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; } diff --git a/lustre/mds/lproc_mds.c b/lustre/mds/lproc_mds.c index 80db1c7..904c18f 100644 --- a/lustre/mds/lproc_mds.c +++ b/lustre/mds/lproc_mds.c @@ -24,106 +24,103 @@ #include #include - -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) { @@ -131,19 +128,19 @@ int rd_ffiles(char* page, char **start, off_t off, 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) { @@ -151,37 +148,36 @@ int rd_inodesfree(char* page, char **start, off_t off, 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} }; diff --git a/lustre/obdclass/Makefile.am b/lustre/obdclass/Makefile.am index ab9e40f..3ad8a59 100644 --- a/lustre/obdclass/Makefile.am +++ b/lustre/obdclass/Makefile.am @@ -2,7 +2,5 @@ DEFS= 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 diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 51ad1b1..333159e 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -173,7 +173,7 @@ int class_register_type(struct obd_ops *ops, struct lprocfs_vars* vars, char *nm 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); } diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index d4c65e7..d3022c2 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -17,9 +17,9 @@ * 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 #include @@ -29,8 +29,6 @@ #include #define DEBUG_SUBSYSTEM S_CLASS -#define MAX_STRING_SIZE 100 - #include #include @@ -59,12 +57,9 @@ struct proc_dir_entry* lprocfs_mkdir(const char* dname, 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; } @@ -72,17 +67,14 @@ struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head, 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; } @@ -103,17 +95,18 @@ void lprocfs_remove_all(struct proc_dir_entry* root) } } +#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; @@ -123,23 +116,23 @@ struct proc_dir_entry* lprocfs_new_dir(struct proc_dir_entry* root, 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; @@ -152,28 +145,30 @@ int lprocfs_new_vars(struct proc_dir_entry* root, struct lprocfs_vars* list, 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 */ @@ -186,8 +181,14 @@ int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *var, 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, @@ -207,9 +208,12 @@ int lprocfs_dereg_obd(struct obd_device* device) 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); @@ -218,11 +222,19 @@ int lprocfs_dereg_obd(struct obd_device* device) 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; } @@ -230,15 +242,13 @@ int lprocfs_dereg_mnt(struct proc_dir_entry* root) 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; } @@ -249,30 +259,28 @@ int lprocfs_dereg_class(struct obd_type* class) 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; } @@ -299,9 +307,7 @@ int lprocfs_ll_rd(char *page, char **start, off_t off, { __u64 *temp = (__u64 *)data; int len; - len = snprintf(page, count, LPU64"\n", *temp); - return len; } diff --git a/lustre/obdclass/proc_lustre.c b/lustre/obdclass/proc_lustre.c deleted file mode 100644 index d4dc835..0000000 --- a/lustre/obdclass/proc_lustre.c +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- 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 - * - * 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/ - * when /dev/obd 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 . "cat /proc/lustre/obd//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//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// entry by name. This is the only - * function that is exported to other modules. - */ - -#define EXPORT_SYMTAB -#include -#include -#include -#include - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include - -#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); diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index 8c16744..1dcfa67 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -12,8 +12,8 @@ * and Andreas Dilger */ -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 @@ -437,18 +437,12 @@ static int echo_cleanup(struct obd_device *obddev) 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); } @@ -478,12 +472,10 @@ static int __init obdecho_init(void) " 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; } @@ -491,7 +483,6 @@ static void __exit obdecho_exit(void) { echo_proc_fini(); - class_unregister_type(OBD_ECHO_DEVICENAME); } diff --git a/lustre/obdecho/lproc_echo.c b/lustre/obdecho/lproc_echo.c index f949610..449f9c5 100644 --- a/lustre/obdecho/lproc_echo.c +++ b/lustre/obdecho/lproc_echo.c @@ -25,43 +25,43 @@ #include -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} }; diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 8f4cec4..0ae84c8 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -1767,19 +1767,12 @@ int filter_copy_data(struct lustre_handle *dst_conn, struct obdo *dst, 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, @@ -1826,8 +1819,7 @@ static int __init obdfilter_init(void) 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); } diff --git a/lustre/obdfilter/lproc_obdfilter.c b/lustre/obdfilter/lproc_obdfilter.c index a559466..48c5382 100644 --- a/lustre/obdfilter/lproc_obdfilter.c +++ b/lustre/obdfilter/lproc_obdfilter.c @@ -25,127 +25,115 @@ #include -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} }; diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index d67bbb0..229be02 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -24,103 +24,103 @@ #include #include -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} }; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 508e328..a77e2d8 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -871,18 +871,12 @@ out: 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, @@ -909,14 +903,10 @@ struct obd_ops osc_obd_ops = { 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) diff --git a/lustre/ost/lproc_ost.c b/lustre/ost/lproc_ost.c index a22c95c..e919104 100644 --- a/lustre/ost/lproc_ost.c +++ b/lustre/ost/lproc_ost.c @@ -25,150 +25,138 @@ #include -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} }; + diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index de4414a..94ad47f 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -664,20 +664,13 @@ static int ost_cleanup(struct obd_device * obddev) 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); + } @@ -694,12 +687,9 @@ static int __init ost_init(void) { 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); } diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 36e9254..a778b57 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -24,30 +24,29 @@ #include #include -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} }; diff --git a/lustre/ptlrpc/rpc.c b/lustre/ptlrpc/rpc.c index cacb98e..af6ce21 100644 --- a/lustre/ptlrpc/rpc.c +++ b/lustre/ptlrpc/rpc.c @@ -169,18 +169,12 @@ static int connmgr_connect(struct lustre_handle *conn, struct obd_device *src, 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 = { @@ -201,15 +195,11 @@ static int __init ptlrpc_init(void) 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; }