Whamcloud - gitweb
Lproc-snmp code drop
authorthantry <thantry>
Fri, 1 Nov 2002 17:23:18 +0000 (17:23 +0000)
committerthantry <thantry>
Fri, 1 Nov 2002 17:23:18 +0000 (17:23 +0000)
37 files changed:
lustre/include/linux/lustre_lite.h
lustre/include/linux/obd.h
lustre/include/linux/obd_class.h
lustre/ldlm/ldlm_lockd.c
lustre/llite/Makefile.am
lustre/llite/lproc_llite.c
lustre/llite/super.c
lustre/lov/Makefile.am
lustre/lov/lov_obd.c
lustre/lov/lproc_lov.c
lustre/mdc/Makefile.am
lustre/mdc/lproc_mdc.c
lustre/mdc/mdc_request.c
lustre/mds/Makefile.am
lustre/mds/handler.c
lustre/mds/lproc_mds.c
lustre/obdclass/Makefile.am
lustre/obdclass/class_obd.c
lustre/obdclass/genops.c
lustre/obdclass/lprocfs.c
lustre/obdclass/lprocfs_snmp.c [deleted file]
lustre/obdclass/lprocfs_status.c [new file with mode: 0644]
lustre/obdecho/Makefile.am
lustre/obdecho/echo.c
lustre/obdecho/lproc_echo.c
lustre/obdfilter/Makefile.am
lustre/obdfilter/filter.c
lustre/obdfilter/lproc_obdfilter.c
lustre/osc/Makefile.am
lustre/osc/lproc_osc.c
lustre/osc/osc_request.c
lustre/ost/Makefile.am
lustre/ost/lproc_ost.c
lustre/ost/ost_handler.c
lustre/ptlrpc/Makefile.am
lustre/ptlrpc/lproc_ptlrpc.c
lustre/ptlrpc/rpc.c

index a646174..d0be35f 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
 
 #include <linux/fs.h>
 #include <linux/ext2_fs.h>
+#include <linux/proc_fs.h>
 
 #include <linux/obd_class.h>
 #include <linux/lustre_net.h>
 
 #include <linux/obd_class.h>
 #include <linux/lustre_net.h>
@@ -75,6 +76,7 @@ struct ll_sb_info {
         obd_uuid_t                ll_sb_uuid;
         struct lustre_handle      ll_mdc_conn;
         struct lustre_handle      ll_osc_conn;
         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;
         obd_id                    ll_rootino; /* number of root inode */
 
         int                       ll_flags;
         obd_id                    ll_rootino; /* number of root inode */
 
         int                       ll_flags;
index 75759d3..f1a28a7 100644 (file)
@@ -22,6 +22,7 @@
 struct obd_type {
         struct list_head typ_chain;
         struct obd_ops *typ_ops;
 struct obd_type {
         struct list_head typ_chain;
         struct obd_ops *typ_ops;
+        struct proc_dir_entry *typ_procroot;
         char *typ_name;
         int  typ_refcnt;
 };
         char *typ_name;
         int  typ_refcnt;
 };
@@ -324,6 +325,7 @@ struct obd_ops {
                         __u32 mode, struct lustre_handle *);
         int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
                                int local_only);
                         __u32 mode, struct lustre_handle *);
         int (*o_cancel_unused)(struct lustre_handle *, struct lov_stripe_md *,
                                int local_only);
+        
 };
 
 static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
 };
 
 static inline void *mds_fs_start(struct mds_obd *mds, struct inode *inode,
index 2b66b1b..71a16bf 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
 #include <linux/lustre_dlm.h>
 #include <linux/lustre_idl.h>
 #include <linux/lustre_mds.h>
 #include <linux/lustre_dlm.h>
+#include <linux/lprocfs_status.h>
 #endif
 
 
 #endif
 
 
@@ -745,12 +746,13 @@ static inline int obdo_cmp_md(struct obdo *dst, struct obdo *src,
  * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */ 
 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 
  * <shaver> // XXX if this were any uglier, I'd get my own show on MTV */ 
 extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 
-int class_register_type(struct obd_ops *ops, char *nm);
+int class_register_type(struct obd_ops *ops, lprocfs_vars_t* vars, char *nm);
 int class_unregister_type(char *nm);
 int class_name2dev(char *name);
 int class_uuid2dev(char *uuid);
 struct obd_device *class_uuid2obd(char *uuid);
 struct obd_export *class_new_export(struct obd_device *obddev);
 int class_unregister_type(char *nm);
 int class_name2dev(char *name);
 int class_uuid2dev(char *uuid);
 struct obd_device *class_uuid2obd(char *uuid);
 struct obd_export *class_new_export(struct obd_device *obddev);
+struct obd_type *class_nm_to_type(char* name);
 void class_destroy_export(struct obd_export *exp);
 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
                   obd_uuid_t cluuid);
 void class_destroy_export(struct obd_export *exp);
 int class_connect(struct lustre_handle *conn, struct obd_device *obd,
                   obd_uuid_t cluuid);
index 494b82b..17795fc 100644 (file)
@@ -657,7 +657,7 @@ struct obd_ops ldlm_obd_ops = {
 
 static int __init ldlm_init(void)
 {
 
 static int __init ldlm_init(void)
 {
-        int rc = class_register_type(&ldlm_obd_ops, OBD_LDLM_DEVICENAME);
+        int rc = class_register_type(&ldlm_obd_ops, 0, OBD_LDLM_DEVICENAME);
         if (rc != 0)
                 return rc;
 
         if (rc != 0)
                 return rc;
 
index 74e2710..fa2d02e 100644 (file)
@@ -13,7 +13,7 @@ LINX= ll_pack.c
 
 llite_SOURCES = dcache.c commit_callback.c super.c rw.c super25.c
 llite_SOURCES += file.c dir.c sysctl.c symlink.c $(LINX)
 
 llite_SOURCES = dcache.c commit_callback.c super.c rw.c super25.c
 llite_SOURCES += file.c dir.c sysctl.c symlink.c $(LINX)
-llite_SOURCES += lov_pack.c recover.c namei.c
+llite_SOURCES += lov_pack.c recover.c namei.c lproc_llite.c
 
 lov_pack.c: 
        test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c .
 
 lov_pack.c: 
        test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c .
index efa28f3..428bd43 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_LLITE
  *
  */
 #define DEBUG_SUBSYSTEM S_LLITE
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
+
 #include <linux/lustre_lite.h>
 #include <linux/lustre_lite.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/lustre_lib.h>
+#include <linux/lprocfs_status.h>
+
 
 
 int rd_path(char* page, char **start, off_t off,
 
 
 int rd_path(char* page, char **start, off_t off,
@@ -92,13 +89,13 @@ int rd_kbfree(char* page, char **start, off_t off,
         (sb->s_op->statfs)(sb, &mystats);
         blk_size=mystats.f_bsize;
         
         (sb->s_op->statfs)(sb, &mystats);
         blk_size=mystats.f_bsize;
         
-        len+=snprintf(page, count, LPU64"\n", \
+        len+=snprintf(page, count, LPU64"\n", 
                       (__u64)((mystats.f_bfree)/(blk_size*1024))); 
         return len; 
         
 }
 
                       (__u64)((mystats.f_bfree)/(blk_size*1024))); 
         return len; 
         
 }
 
-int rd_numobjects(char* page, char **start, off_t off,
+int rd_filestotal(char* page, char **start, off_t off,
                   int count, int *eof, void *data)
 {
         
                   int count, int *eof, void *data)
 {
         
@@ -114,7 +111,7 @@ int rd_numobjects(char* page, char **start, off_t off,
         return len;
 }
 
         return len;
 }
 
-int rd_objfree(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
                int count, int *eof, void *data)
 {
         
                int count, int *eof, void *data)
 {
         
@@ -130,7 +127,7 @@ int rd_objfree(char* page, char **start, off_t off,
         return len;
 }
 
         return len;
 }
 
-int rd_objgroups(char* page, char **start, off_t off,
+int rd_filegroups(char* page, char **start, off_t off,
                  int count, int *eof, void *data)
 {
         return 0;
                  int count, int *eof, void *data)
 {
         return 0;
@@ -164,16 +161,16 @@ int rd_dev_uuid(char* page, char **start, off_t off,
 }
 
 
 }
 
 
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/mntpt_path", rd_path, 0},
-        {"snmp/fs_type", rd_fstype, 0},
-        {"snmp/f_blocksize",rd_blksize, 0},
-        {"snmp/f_blockstotal",rd_blktotal, 0},
-        {"snmp/f_blocksfree",rd_blkfree, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_objects", rd_numobjects, 0},
-        {"snmp/f_objectsfree", rd_objfree, 0},
-        {"snmp/f_objectgroups", rd_objgroups, 0},
+lprocfs_vars_t 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/blockstotal",rd_blktotal, 0},
+        {"status/blocksfree",rd_blkfree, 0},
+        {"status/kbytesfree", rd_kbfree, 0},
+        {"status/filestotal", rd_filestotal, 0},
+        {"status/filesfree", rd_filesfree, 0},
+        {"status/filegroups", rd_filegroups, 0},
         {0}
 };
         {0}
 };
index 554c28d..40ae623 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/lustre_dlm.h>
 #include <linux/init.h>
 #include <linux/fs.h>
 #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;
 
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 kmem_cache_t *ll_file_data_slab;
@@ -31,6 +33,15 @@ 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 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 lprocfs_vars_t status_var_nm_1[];
+
 static char *ll_read_opt(const char *opt, char *data)
 {
         char *value;
 static char *ll_read_opt(const char *opt, char *data)
 {
         char *value;
@@ -109,6 +120,14 @@ static struct super_block * ll_read_super(struct super_block *sb,
         struct ll_read_inode2_cookie lic;
         class_uuid_t uuid;
 
         struct ll_read_inode2_cookie lic;
         class_uuid_t uuid;
 
+        
+        /* Lprocfs variables */
+        char mnt_name[100];
+        char uuid_name[100];
+        lprocfs_vars_t d_vars[3];
+        
+
+
         ENTRY;
         MOD_INC_USE_COUNT;
 
         ENTRY;
         MOD_INC_USE_COUNT;
 
@@ -218,6 +237,65 @@ static struct super_block * ll_read_super(struct super_block *sb,
         ptlrpc_req_finished(request);
         request = NULL;
 
         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 */
+        lprocfs_add_vars(sbi->ll_mnt_root, (lprocfs_vars_t*)status_var_nm_1,
+                         (void*)sb);
+
+         /* Add the dynamic configuration stuff */
+        /* 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=0;
+        d_vars[0].name=(char*)mnt_name;
+         
+        memset(uuid_name, '\0', strlen(uuid_name));
+        sprintf(uuid_name, "status/%s/uuid", obd->obd_type->typ_name);
+        d_vars[1].read_fptr=rd_dev_uuid;
+        d_vars[1].write_fptr=0;
+        d_vars[1].name=(char*)uuid_name;
+        
+        err=lprocfs_add_vars(sbi->ll_mnt_root, (lprocfs_vars_t*)d_vars, 
+                             (void*)obd);
+        if (err) {
+                CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables");
+        }
+
+        /* OSC or LOV*/
+        obd = class_uuid2obd(osc);
+        /* Reuse mnt_name */
+        memset(mnt_name, '\0', strlen(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=0;
+        d_vars[0].name=(char*)mnt_name;
+         
+        memset(uuid_name, '\0', strlen(uuid_name));
+        sprintf(uuid_name, "status/%s/uuid", obd->obd_type->typ_name);
+        d_vars[1].read_fptr=rd_dev_uuid;
+        d_vars[1].write_fptr=0;
+        d_vars[1].name=(char*)uuid_name;
+        
+        err=lprocfs_add_vars(sbi->ll_mnt_root, (lprocfs_vars_t*)d_vars, 
+                             (void*)obd);        
+        if (err) {
+                CDEBUG(D_OTHER, "Unable to add fs proc dynamic variables");
+        }
 out_dev:
         if (mdc)
                 OBD_FREE(mdc, strlen(mdc) + 1);
 out_dev:
         if (mdc)
                 OBD_FREE(mdc, strlen(mdc) + 1);
@@ -258,6 +336,7 @@ static void ll_put_super(struct super_block *sb)
          */
         mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
 
          */
         mdc_getstatus(&sbi->ll_mdc_conn, &rootfid);
 
+        lprocfs_dereg_mnt(sbi->ll_mnt_root);
         obd_disconnect(&sbi->ll_mdc_conn);
         OBD_FREE(sbi, sizeof(*sbi));
 
         obd_disconnect(&sbi->ll_mdc_conn);
         OBD_FREE(sbi, sizeof(*sbi));
 
index f45ddd9..38d23d4 100644 (file)
@@ -10,7 +10,7 @@ modulefs_DATA = lov.o
 EXTRA_PROGRAMS = lov
 LINX= lov_pack.c
 
 EXTRA_PROGRAMS = lov
 LINX= lov_pack.c
 
-lov_SOURCES = lov_obd.c $(LINX)
+lov_SOURCES = lov_obd.c lproc_lov.c $(LINX)
 
 lov_pack.c: 
        test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c
 
 lov_pack.c: 
        test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c
index 6e70e3b..7e1d1cb 100644 (file)
@@ -1,4 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
  *  lov/lov.c
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
  *  lov/lov.c
 #include <linux/random.h>
 #include <linux/slab.h>
 #include <asm/div64.h>
 #include <linux/random.h>
 #include <linux/slab.h>
 #include <asm/div64.h>
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
 
 static kmem_cache_t *lov_file_cache;
 
 
 static kmem_cache_t *lov_file_cache;
 
@@ -1413,7 +1417,25 @@ static int lov_iocontrol(long cmd, struct lustre_handle *conn, int len,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
+int lov_attach(struct obd_device *dev, 
+               obd_count len, void *data)
+{
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
+
+int lov_detach(struct obd_device *dev)
+{        
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
+ }
+
 struct obd_ops lov_obd_ops = {
 struct obd_ops lov_obd_ops = {
+        o_attach:      lov_attach,
+        o_detach:      lov_detach,
         o_setup:       lov_setup,
         o_connect:     lov_connect,
         o_disconnect:  lov_disconnect,
         o_setup:       lov_setup,
         o_connect:     lov_connect,
         o_disconnect:  lov_disconnect,
@@ -1437,6 +1459,8 @@ struct obd_ops lov_obd_ops = {
 
 static int __init lov_init(void)
 {
 
 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",
         printk(KERN_INFO "Lustre Logical Object Volume driver " LOV_VERSION
                ", info@clusterfs.com\n");
         lov_file_cache = kmem_cache_create("ll_lov_file_data",
@@ -1445,14 +1469,23 @@ static int __init lov_init(void)
         if (!lov_file_cache)
                 RETURN(-ENOMEM);
 
         if (!lov_file_cache)
                 RETURN(-ENOMEM);
 
-        return class_register_type(&lov_obd_ops, OBD_LOV_DEVICENAME);
+        rc = class_register_type(&lov_obd_ops,
+                                 (lprocfs_vars_t*)status_class_var,
+                                 OBD_LOV_DEVICENAME);
+        if (rc) RETURN(rc);
+        
+        return 0;
+
+        
 }
 
 static void __exit lov_exit(void)
 {
 }
 
 static void __exit lov_exit(void)
 {
-        class_unregister_type(OBD_LOV_DEVICENAME);
+                
         if (kmem_cache_destroy(lov_file_cache))
                 CERROR("couldn't free LOV open cache\n");
         if (kmem_cache_destroy(lov_file_cache))
                 CERROR("couldn't free LOV open cache\n");
+        class_unregister_type(OBD_LOV_DEVICENAME);
+     
 }
 
 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
 }
 
 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
index 5e15f60..8198dc6 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
 
 
+#include <linux/lustre_lite.h>
+#include <linux/lprocfs_status.h>
 
 /*
 
 /*
- * Common SNMP namespace
+ * Common STATUS namespace
  */
 
 int rd_uuid(char* page, char **start, off_t off,
  */
 
 int rd_uuid(char* page, char **start, off_t off,
@@ -47,43 +44,66 @@ int rd_stripesize(char* page, char **start, off_t off,
         struct obd_device* dev=(struct obd_device*)data;
         int len=0;
         struct lov_obd* lov=&dev->u.lov;
         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));
+        len+=snprintf(page, count, LPU64"\n", 
+                      (__u64)(lov->desc.ld_default_stripe_size));
         
         return len;
 }
 
         
         return len;
 }
 
-int rd_stripedepth(char* page, char **start, off_t off,
+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;
                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_size);
+        len+=snprintf(page, count, LPU64"\n", 
+                      lov->desc.ld_default_stripe_offset);
         return len;
 
 }
         return len;
 
 }
-int rd_stripefactor(char* page, char **start, off_t off,
+
+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;
                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);
+        len+=snprintf(page, count, LPU64"\n", 
+                      (__u64)(lov->desc.ld_pattern));
         return len;
 
 }
         return len;
 
 }
+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));
+        return len;
 
 
-int rd_stripetype(char* page, char **start, off_t off,
+}
+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 lov_obd* lov=&dev->u.lov;
                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));
+        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)
+{       
+        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;
 
 }
         return len;
 
 }
@@ -139,10 +159,7 @@ int rd_target(char* page, char **start, off_t off,
         struct lov_obd* lov=&dev->u.lov;
         struct lov_tgt_desc* tgts=lov->tgts;
         while(i<lov->desc.ld_tgt_count){
         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, \
-                              "OBD Device [%d] UUID: %s\n", \
-                              i, tgts->uuid);
-
+                len+=snprintf(page, count, "%d: %s\n", i, tgts->uuid);
                 i++;
                 tgts++;
         }
                 i++;
                 tgts++;
         }
@@ -155,26 +172,40 @@ int rd_mdc(char* page, char **start, off_t off,
         struct obd_device* dev=(struct obd_device*)data;
         int len=0;
         struct lov_obd* lov=&dev->u.lov;
         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);
+        len+=snprintf(page, count, "%s\n", lov->mdcobd->obd_uuid);
+        return len;
+}
+
+lprocfs_vars_t 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},
+       
+        {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
         return len;
 }
 
         return len;
 }
 
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/lov_stripesize",rd_stripesize, 0},
-        {"snmp/lov_stripedepth",rd_stripedepth, 0},
-        {"snmp/lov_stripefactor",rd_stripefactor, 0},
-        {"snmp/lov_stripetype", rd_stripetype, 0},
-        {"snmp/f_objects", rd_numobjects, 0},
-        {"snmp/f_objectsfree", rd_objfree, 0},
-        {"snmp/f_objectgroups", rd_objgroups, 0},
-        {"snmp/f_blocksize", rd_blksize, 0},
-        {"snmp/f_blockstotal", rd_blktotal, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_blocksfree", rd_blkfree, 0},
-        {"snmp/target_obd", rd_target, 0},
-        {"snmp/target_mdc", rd_mdc, 0},
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index e149246..26c0053 100644 (file)
@@ -10,7 +10,7 @@ modulefs_DATA = mdc.o
 EXTRA_PROGRAMS = mdc
 
 LINX= mds_updates.c ll_pack.c lov_pack.c client.c
 EXTRA_PROGRAMS = mdc
 
 LINX= mds_updates.c ll_pack.c lov_pack.c client.c
-mdc_SOURCES =  mdc_request.c mdc_reint.c $(LINX)
+mdc_SOURCES =  mdc_request.c mdc_reint.c lproc_mdc.c $(LINX)
 
 lov_pack.c: 
        test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c .
 
 lov_pack.c: 
        test -e lov_pack.c || ln -sf $(top_srcdir)/lib/lov_pack.c .
index 1497b9e..54d1d4c 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#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)
@@ -40,16 +39,11 @@ int rd_uuid(char* page, char **start, off_t off,
 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)
-{
         return 0;
         return 0;
-}
 
 
-int rd_blkfree(char* page, char **start, off_t off,
+}
+int rd_kbtotal(char* page, char **start, off_t off,
                int count, int *eof, void *data)
 {
         return 0;
                int count, int *eof, void *data)
 {
         return 0;
@@ -61,19 +55,20 @@ int rd_kbfree(char* page, char **start, off_t off,
         return 0;
 }
 
         return 0;
 }
 
-int rd_numobjects(char* page, char **start, off_t off,
+
+int rd_files(char* page, char **start, off_t off,
                   int count, int *eof, void *data)
 {
         return 0;
 }
 
                   int count, int *eof, void *data)
 {
         return 0;
 }
 
-int rd_objfree(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
                int count, int *eof, void *data)
 {
         return 0;
 }
 
                int count, int *eof, void *data)
 {
         return 0;
 }
 
-int rd_objgroups(char* page, char **start, off_t off,
+int rd_filegroups(char* page, char **start, off_t off,
                  int count, int *eof, void *data)
 {
         return 0;
                  int count, int *eof, void *data)
 {
         return 0;
@@ -106,16 +101,28 @@ int rd_server_name(char* page, char **start, off_t off,
         
 }
 
         
 }
 
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/f_blocksize",rd_blksize, 0},
-        {"snmp/f_blockstotal",rd_blktotal, 0},
-        {"snmp/f_blocksfree",rd_blkfree, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_objects", rd_numobjects, 0},
-        {"snmp/f_objectsfree", rd_objfree, 0},
-        {"snmp/f_objectgroups", rd_objgroups, 0},
-        {"snmp/server_uuid", rd_server_uuid, 0},
-        {"snmp/conn_uuid", rd_conn_uuid, 0},
+lprocfs_vars_t 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},
+        {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+        return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index ff7334d..4b5f6b2 100644 (file)
 #include <linux/lustre_dlm.h>
 #include <linux/init.h>
 #include <linux/obd_lov.h>
 #include <linux/lustre_dlm.h>
 #include <linux/init.h>
 #include <linux/obd_lov.h>
+#include <linux/lprocfs_status.h>
 
 #define REQUEST_MINOR 244
 
 extern int mds_queue_req(struct ptlrpc_request *);
 
 #define REQUEST_MINOR 244
 
 extern int mds_queue_req(struct ptlrpc_request *);
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
 
 /* should become mdc_getinfo() */
 int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid)
 
 /* should become mdc_getinfo() */
 int mdc_getstatus(struct lustre_handle *conn, struct ll_fid *rootfid)
@@ -775,8 +778,24 @@ out:
 
         return rc;
 }
 
         return rc;
 }
+int mdc_attach(struct obd_device *dev, 
+                   obd_count len, void *data)
+{
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
+
+int mdc_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
 
 
+}
 struct obd_ops mdc_obd_ops = {
 struct obd_ops mdc_obd_ops = {
+        o_attach: mdc_attach,
+        o_detach: mdc_detach,
         o_setup:   client_obd_setup,
         o_cleanup: client_obd_cleanup,
         o_connect: client_obd_connect,
         o_setup:   client_obd_setup,
         o_cleanup: client_obd_cleanup,
         o_connect: client_obd_connect,
@@ -786,12 +805,21 @@ struct obd_ops mdc_obd_ops = {
 
 static int __init ptlrpc_request_init(void)
 {
 
 static int __init ptlrpc_request_init(void)
 {
-        return class_register_type(&mdc_obd_ops, LUSTRE_MDC_NAME);
+        int rc;
+        rc = class_register_type(&mdc_obd_ops, 
+                                 (lprocfs_vars_t*)status_class_var, 
+                                 LUSTRE_MDC_NAME);
+        if(rc)
+                RETURN(rc);
+        return 0;
+        
 }
 
 static void __exit ptlrpc_request_exit(void)
 {
 }
 
 static void __exit ptlrpc_request_exit(void)
 {
+        
         class_unregister_type(LUSTRE_MDC_NAME);
         class_unregister_type(LUSTRE_MDC_NAME);
+        
 }
 
 MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
 }
 
 MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
index e5d5943..a5eefb4 100644 (file)
@@ -28,6 +28,6 @@ lov_pack.c:
 target.c: 
        test -e target.c || ln -sf $(top_srcdir)/lib/target.c
 
 target.c: 
        test -e target.c || ln -sf $(top_srcdir)/lib/target.c
 
-mds_SOURCES = mds_lov.c handler.c mds_reint.c mds_fs.c $(LINX)
+mds_SOURCES = mds_lov.c handler.c mds_reint.c mds_fs.c lproc_mds.c $(LINX)
 
 include $(top_srcdir)/Rules
 
 include $(top_srcdir)/Rules
index be6cd27..6bd5e0c 100644 (file)
@@ -38,6 +38,7 @@
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
 #include <linux/buffer_head.h>
 #endif
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
 #include <linux/buffer_head.h>
 #endif
+#include <linux/lprocfs_status.h>
 
 static kmem_cache_t *mds_file_cache;
 
 
 static kmem_cache_t *mds_file_cache;
 
@@ -48,6 +49,9 @@ extern int mds_update_last_rcvd(struct mds_obd *mds, void *handle,
                                 struct ptlrpc_request *req);
 static int mds_cleanup(struct obd_device * obddev);
 
                                 struct ptlrpc_request *req);
 static int mds_cleanup(struct obd_device * obddev);
 
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
+
 inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
 {
         return &req->rq_export->exp_obd->u.mds;
 inline struct mds_obd *mds_req2mds(struct ptlrpc_request *req)
 {
         return &req->rq_export->exp_obd->u.mds;
@@ -1448,6 +1452,21 @@ static int ldlm_intent_policy(struct ldlm_lock *lock, void *req_cookie,
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
+int mds_attach(struct obd_device *dev, 
+               obd_count len, void *data)
+{
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
+
+int mds_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
+
+}
 
 #define MDT_NUM_THREADS 8
 static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
 
 #define MDT_NUM_THREADS 8
 static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
@@ -1507,6 +1526,8 @@ extern int mds_iocontrol(long cmd, struct lustre_handle *conn,
 
 /* use obd ops to offer management infrastructure */
 static struct obd_ops mds_obd_ops = {
 
 /* use obd ops to offer management infrastructure */
 static struct obd_ops mds_obd_ops = {
+        o_attach:      mds_attach,
+        o_detach:      mds_detach,
         o_connect:     mds_connect,
         o_disconnect:  mds_disconnect,
         o_setup:       mds_setup,
         o_connect:     mds_connect,
         o_disconnect:  mds_disconnect,
         o_setup:       mds_setup,
@@ -1522,25 +1543,33 @@ static struct obd_ops mdt_obd_ops = {
 
 static int __init mds_init(void)
 {
 
 static int __init mds_init(void)
 {
+     
         mds_file_cache = kmem_cache_create("ll_mds_file_data",
                                            sizeof(struct mds_file_data),
                                            0, 0, NULL, NULL);
         if (mds_file_cache == NULL)
                 return -ENOMEM;
 
         mds_file_cache = kmem_cache_create("ll_mds_file_data",
                                            sizeof(struct mds_file_data),
                                            0, 0, NULL, NULL);
         if (mds_file_cache == NULL)
                 return -ENOMEM;
 
-        class_register_type(&mds_obd_ops, LUSTRE_MDS_NAME);
-        class_register_type(&mdt_obd_ops, LUSTRE_MDT_NAME);
+        class_register_type(&mds_obd_ops, (lprocfs_vars_t*)status_class_var, 
+                            LUSTRE_MDS_NAME);
+        class_register_type(&mdt_obd_ops, 0, LUSTRE_MDT_NAME);
+
         ldlm_register_intent(ldlm_intent_policy);
         ldlm_register_intent(ldlm_intent_policy);
+        
         return 0;
         return 0;
+        
 }
 
 static void __exit mds_exit(void)
 {
 }
 
 static void __exit mds_exit(void)
 {
+        
+        
         ldlm_unregister_intent();
         class_unregister_type(LUSTRE_MDS_NAME);
         class_unregister_type(LUSTRE_MDT_NAME);
         if (kmem_cache_destroy(mds_file_cache))
                 CERROR("couldn't free MDS file cache\n");
         ldlm_unregister_intent();
         class_unregister_type(LUSTRE_MDS_NAME);
         class_unregister_type(LUSTRE_MDT_NAME);
         if (kmem_cache_destroy(mds_file_cache))
                 CERROR("couldn't free MDS file cache\n");
+        
 }
 
 MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
 }
 
 MODULE_AUTHOR("Cluster File Systems <info@clusterfs.com>");
index 9302240..a65816f 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#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)
@@ -101,7 +100,7 @@ int rd_kbfree(char* page, char **start, off_t off,
                 return 0;
         }
         blk_size=mystats.f_bsize;
                 return 0;
         }
         blk_size=mystats.f_bsize;
-        len+=snprintf(page, count, LPU64"\n", \
+        len+=snprintf(page, count, LPU64"\n", 
                       (__u64)((mystats.f_bfree)/(blk_size*1024))); 
         return len;  
        
                       (__u64)((mystats.f_bfree)/(blk_size*1024))); 
         return len;  
        
@@ -132,8 +131,7 @@ int rd_ffiles(char* page, char **start, off_t off,
                 return 0;
         }
         
                 return 0;
         }
         
-        len+=snprintf(page, count, LPU64"\n", \
-                      (__u64)(mystats.f_files));
+        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_files));
         return len;  
 
         
         return len;  
 
         
@@ -153,8 +151,7 @@ int rd_inodesfree(char* page, char **start, off_t off,
                 return 0;
         }
         
                 return 0;
         }
         
-        len+=snprintf(page, count, LPU64"\n", \
-                      (__u64)(mystats.f_ffree));
+        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_ffree));
         return len; 
 }
 
         return len; 
 }
 
@@ -163,15 +160,28 @@ int rd_filesets(char* page, char **start, off_t off,
 {
         return 0;
 }
 {
         return 0;
 }
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/f_blocksize",rd_blksize, 0},
-        {"snmp/f_blockstotal",rd_blktotal, 0},
-        {"snmp/f_blocksfree",rd_blkfree, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_fstype", rd_fstype, 0},
-        {"snmp/f_files", rd_ffiles, 0},
-        {"snmp/f_inodesfree", rd_inodesfree, 0},
-        {"snmp/f_filesets", rd_filesets, 0},
+lprocfs_vars_t status_var_nm_1[]={
+        {"status/uuid", rd_uuid, 0},
+        {"status/f_blocksize",rd_blksize, 0},
+        {"status/f_blockstotal",rd_blktotal, 0},
+        {"status/f_blocksfree",rd_blkfree, 0},
+        {"status/f_kbytesfree", rd_kbfree, 0},
+        {"status/f_fstype", rd_fstype, 0},
+        {"status/f_files", rd_ffiles, 0},
+        {"status/f_inodesfree", rd_inodesfree, 0},
+        {"status/f_filesets", rd_filesets, 0},
+        {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+        return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index ed4854c..ab9e40f 100644 (file)
@@ -3,6 +3,6 @@ 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 \
 modulefs_DATA = obdclass.o
 EXTRA_PROGRAMS = obdclass
 obdclass_SOURCES = debug.c genops.c proc_lustre.c class_obd.c sysctl.c uuid.c \
-               lprocfs.c
+               lprocfs_status.c
 
 include $(top_srcdir)/Rules
 
 include $(top_srcdir)/Rules
index 2a22c8f..2569fb2 100644 (file)
@@ -43,7 +43,7 @@
 #include <linux/obd_class.h>
 #include <linux/lustre_debug.h>
 #include <linux/smp_lock.h>
 #include <linux/obd_class.h>
 #include <linux/lustre_debug.h>
 #include <linux/smp_lock.h>
-#include <linux/lprocfs.h>
+#include <linux/lprocfs_status.h>
 
 struct semaphore obd_conf_sem;   /* serialize configuration commands */
 struct obd_device obd_dev[MAX_OBD_DEVICES];
 
 struct semaphore obd_conf_sem;   /* serialize configuration commands */
 struct obd_device obd_dev[MAX_OBD_DEVICES];
@@ -56,388 +56,6 @@ unsigned long obd_timeout = 100;
 char obd_recovery_upcall[128] = "/usr/lib/lustre/ha_assist";
 
 extern struct obd_type *class_nm_to_type(char *nm);
 char obd_recovery_upcall[128] = "/usr/lib/lustre/ha_assist";
 
 extern struct obd_type *class_nm_to_type(char *nm);
-/*
- * LProcFS specific data structures. These define the namespace for
- * the various device classes. We will need to distribute these
- * later, to individual modules (e.g. MDS, MDC etc)
- */
-
-#ifdef LPROCFS_EXISTS
-
-/*
- * Common SNMP namespace
- */
-
-char *snmp_dir_nm[] = {
-        "snmp",
-        0
-
-};
-
-lprocfs_vars_t snmp_var_nm[]={
-        {"uuid", rd_uuid, wr_uuid},
-        {"f_blocksize",rd_blksize, wr_other},
-        {"f_blockstotal",rd_blktotal, wr_other},
-        {"f_blocksfree",rd_blkfree, wr_other},
-        {"f_kbytesfree", rd_kbfree, wr_other},
-        {"f_objects", rd_numobjects, wr_other},
-        {"f_objectsfree", rd_objfree, wr_other},
-        {"f_objectgroups", rd_objgroups, wr_other},
-        {"0", 0, 0}
-};
-
-
-
-
-/*
- * Common OBD namespace for lprocFS (these are used very often)
- */
-
-char* obd_dir_nm_1[]= {
-        "mgmt%",
-        "mgmt/setup",
-        "mgmt/cleanup",
-        "mgmt/connect",
-        "mgmt/disconnect",
-        0
-};
-
-lprocfs_vars_t obd_var_nm_1[]= {
-        {"num_ops", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"min_time", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"max_time", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"sum_time", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"0", 0, 0}
-};
-
-
-/*
- *  MDC Spcific namespace for lprocFS
- */
-
-char *mdc_dir_nm_1[]= {
-        "reint",
-        "getstatus",
-        "getattr",
-        "setattr",
-        "open",
-        "readpage",
-        "create",
-        "unlink",
-        "link",
-        "rename",
-        0
-};
-
-
-
-
-
-/*
- * Create the MDC groupings
- */
-lprocfs_group_t lprocfs_mdc_nm[]= {
-
-        {obd_dir_nm_1, obd_var_nm_1, e_generic},
-        {mdc_dir_nm_1, obd_var_nm_1, e_generic},
-        {snmp_dir_nm, snmp_var_nm, e_specific},
-        {0, 0, 0}
-};
-
-/*
- * MDS Device Groupings
- */
-char *mds_dir_nm_1[]={
-        "getstatus",
-        "connect",
-        "disconnect_callback",
-        "getattr",
-        "readpage",
-        "open",
-        "close",
-        "create",
-        "unlink",
-        "link",
-        "rename",
-        "reint%",
-        "reint/summary",
-        "reint/setattr",
-        "reint/create",
-        "reint/unlink",
-        "reint/link",
-        "reint/rename",
-        "reint/recreate",
-        0
-};
-/*
-char *mds_dir_nm_2[]={
-        "mstatfs",
-        0
-};
-
-
-lprocfs_vars_t mds_var_nm_2[]={
-        {"f_type", rd_fs_type, wr_other},
-        {"f_bsize",rd_other, wr_other},
-        {"f_blocks",rd_other, wr_other},
-        {"f_bfree",rd_other, wr_other},
-        {"f_bavail",rd_other, wr_other},
-        {"uuid",rd_string, wr_string},
-        {"0", 0, 0}
-};
-
-*/
-
-char *mds_snmp_dir_nm_1[] = {
-        "snmp",
-        0
-};
-
-
-lprocfs_vars_t mds_snmp_var_nm_1[] = {
-        {"f_fstype", rd_fs_type, wr_other},
-        {"f_files",rd_other, wr_other},
-        {"f_inodesfree",rd_other, wr_other},
-        {"f_filesets",rd_other, wr_other},
-        {"0", 0, 0}
-};
-
-lprocfs_group_t lprocfs_mds_nm[]={
-         {obd_dir_nm_1, obd_var_nm_1, e_generic},
-         {mds_dir_nm_1, obd_var_nm_1, e_generic},
-         /* {mds_dir_nm_2, mds_var_nm_2, e_specific}, */
-         {snmp_dir_nm, snmp_var_nm, e_specific},
-         {mds_snmp_dir_nm_1, mds_snmp_var_nm_1, e_specific},
-         {0, 0, 0}
-};
-
-lprocfs_group_t lprocfs_mdt_nm[]={
-         {obd_dir_nm_1, obd_var_nm_1, e_generic},
-         /* {mds_dir_nm_1, obd_var_nm_1, e_generic}, */
-         /* {mds_dir_nm_2, mds_var_nm_2, e_specific}, */
-         {snmp_dir_nm, snmp_var_nm, e_specific},
-         {mds_snmp_dir_nm_1, mds_snmp_var_nm_1, e_specific},
-         {0, 0, 0}
-};
-
-/*
- * OSC Namespace
- */
-
-char* osc_dir_nm_1[]={
-        "create",
-        "destroy",
-        "getattr",
-        "setattr",
-        "open",
-        "close",
-        "brw",
-        "punch",
-        "summary",
-        "cancel",
-        0
-};
-
-lprocfs_group_t lprocfs_osc_nm[]={
-         {obd_dir_nm_1, obd_var_nm_1, e_generic},
-         {osc_dir_nm_1, obd_var_nm_1, e_generic},
-         {snmp_dir_nm, snmp_var_nm, e_specific},
-         {0, 0, 0}
-};
-
-
-/*
- * OST, LOV, OBD_FILTER namespace
- * Note: These namespaces are exactly similar to the osc_dir_namespace
- * Hence, I use the osc namespace as the base class and add only
- * those attributes that are missing in osc_dir_namespace.
- */
-
-char *ost_lov_obdfilter_dir_nm_1[]={
-        "getinfo",
-        0
-
-};
-
-
-
-/*
-char *ost_lov_obdfilter_dir_nm_2[]={
-        "ostatfs",
-        0
-};
-
-lprocfs_vars_t ost_lov_obdfilter_var_nm_2[]={
-        {"f_type", rd_fs_type, wr_other},
-        {"f_bsize",rd_other, wr_other},
-        {"f_blocks",rd_other, wr_other},
-        {"f_bfree",rd_other, wr_other},
-        {"f_bavail",rd_other, wr_other},
-        {"f_objects", rd_other, wr_other},
-        {"f_ofree", rd_other, wr_other},
-        {"f_objectgroups", rd_other, wr_other},
-        {"f_uuid", rd_string, wr_string},
-        {"0", 0, 0}
-};
-*/
-
-
-char* obdfilter_snmp_dir_nm_1[] = {
-        "snmp",
-        0
-};
-lprocfs_vars_t obdfilter_snmp_var_nm_1[] = {
-        {"f_fstype", rd_other, wr_other},
-        {"f_inodestotal", rd_other, wr_other},
-        {"f_inodesfree", rd_other, wr_other},
-        {"0", 0, 0}
-};
-
-
-lprocfs_group_t lprocfs_ost_nm[] = {
-         {obd_dir_nm_1, obd_var_nm_1, e_generic},
-         {osc_dir_nm_1, obd_var_nm_1, e_generic},
-         {ost_lov_obdfilter_dir_nm_1, obd_var_nm_1, e_generic},
-         /* {ost_lov_obdfilter_dir_nm_2, ost_lov_obdfilter_var_nm_2, e_specific}, */
-         {snmp_dir_nm, snmp_var_nm, e_specific},
-         {0, 0, 0}
-};
-
-char* lov_snmp_dir_nm_1[] = {
-        "snmp",
-        0
-};
-lprocfs_vars_t lov_snmp_var_nm_1[] = {
-        {"lov_stripesize", rd_other, wr_other},
-        {"lov_stripedepth", rd_other, wr_other},
-        {"lov_stripefactor", rd_other, wr_other},
-        {"lov_stripetype", rd_other, wr_other},
-        {"0", 0, 0}
-};
-
-lprocfs_group_t lprocfs_lov_nm[] = {
-        {obd_dir_nm_1, obd_var_nm_1, e_generic},
-        {osc_dir_nm_1, obd_var_nm_1, e_generic},
-        {ost_lov_obdfilter_dir_nm_1, obd_var_nm_1, e_generic},
-        /* {ost_lov_obdfilter_dir_nm_2, ost_lov_obdfilter_var_nm_2, e_specific}, */
-        {snmp_dir_nm, snmp_var_nm, e_specific},
-        {lov_snmp_dir_nm_1, lov_snmp_var_nm_1, e_specific},
-        {0, 0, 0}
-};
-
-lprocfs_group_t lprocfs_obdf_nm[] = {
-         {obd_dir_nm_1, obd_var_nm_1, e_generic},
-         {osc_dir_nm_1, obd_var_nm_1, e_generic},
-         {ost_lov_obdfilter_dir_nm_1, obd_var_nm_1, e_generic},
-         /* {ost_lov_obdfilter_dir_nm_2, ost_lov_obdfilter_var_nm_2, e_specific}, */
-         {snmp_dir_nm, snmp_var_nm, e_specific},
-         {obdfilter_snmp_dir_nm_1, obdfilter_snmp_var_nm_1, e_specific},
-         {0, 0, 0}
-};
-
-
-/*
- * LDLM Device namespace
- */
-
-
-char* ldlm_dir_nm_1[]={
-        "locks%",
-        "locks/enqueus",
-        "locks/cancels",
-        "locks/converts",
-        "locks/matches",
-        0
-};
-
-lprocfs_vars_t ldlm_var_nm_1[]= {
-        {"num_total", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"num_zerolatency", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"num_zerolatency_inflight", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"num_zerolatency_done", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"nonzero_mintime", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"nonzero_maxtime", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"nonzero_sumtime", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"0", 0, 0}
-
-};
-
-lprocfs_group_t lprocfs_ldlm_nm[]={
-         {obd_dir_nm_1, obd_var_nm_1, e_generic},
-         {ldlm_dir_nm_1, ldlm_var_nm_1, e_generic},
-         {0, 0, 0}
-};
-
-/*
- * Note: Need to add namespace for breaking out locks by device class
- */
-
-/*
- * PTLRPC Namespace
- */
-char* ptlrpc_dir_nm_1[]={
-        "counters",
-        0
-};
-
-lprocfs_vars_t ptlrpc_var_nm_1[]={
-        {"msgs_alloc", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"msgs_max", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"recv_count", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"recv_length", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"send_count", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"send_length", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"portal_kmemory", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"0", 0, 0}
-};
-
-char* ptlrpc_dir_nm_2[] = {
-        "network",
-        0
-};
-
-lprocfs_vars_t ptlrpc_var_nm_2[] = {
-        {"type", rd_string, wr_string},
-        {"mtu", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"rxpackets", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"txpackets", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"txbytes", lprocfs_ll_rd, lprocfs_ll_wr},
-        {"0", 0, 0}
-};
-
-lprocfs_group_t lprocfs_ptlrpc_nm[]={
-         {obd_dir_nm_1, obd_var_nm_1, e_generic},
-         {ptlrpc_dir_nm_1, ptlrpc_var_nm_1, e_generic},
-         {ptlrpc_dir_nm_2, ptlrpc_var_nm_2, e_specific},
-         {snmp_dir_nm, snmp_var_nm, e_specific},
-         {0, 0, 0}
-};
-
-
-/*
- * Building the entire device namespace. This will be used during attach and
- * detach to associate the namespace with the class of the device
- */
-
-lprocfs_obd_nm_t obd_nm[]={
-        {"mdc", lprocfs_mdc_nm, sizeof(struct lprofiler_gen)},
-        {"mds", lprocfs_mds_nm, sizeof(struct lprofiler_gen)},
-        {"mdt", lprocfs_mdt_nm, sizeof(struct lprofiler_gen)},
-        {"osc", lprocfs_osc_nm, sizeof(struct lprofiler_gen)},
-        {"ost", lprocfs_ost_nm, sizeof(struct lprofiler_gen)},
-        {"lov", lprocfs_lov_nm, sizeof(struct lprofiler_gen)},
-        {"obdfilter", lprocfs_obdf_nm, sizeof(struct lprofiler_gen)},
-        {"obdecho", lprocfs_ost_nm, sizeof(struct lprofiler_gen)},
-        {"ldlm", lprocfs_ldlm_nm, sizeof(struct lprofiler_ldlm)},
-        {"ptlrpc", lprocfs_ptlrpc_nm, sizeof(struct lprofiler_ptlrpc)},
-        {"0", 0, 0}
-};
-
-#else
-
-lprocfs_obd_nm_t* obd_nm=0;
-
-#endif
 
 /*  opening /dev/obd */
 static int obd_class_open(struct inode * inode, struct file * file)
 
 /*  opening /dev/obd */
 static int obd_class_open(struct inode * inode, struct file * file)
@@ -516,7 +134,7 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
         int rw = OBD_BRW_READ;
         int err = 0;
         int serialised = 0;
         int rw = OBD_BRW_READ;
         int err = 0;
         int serialised = 0;
-        int l_idx = 0;
+
         ENTRY;
 
         switch (cmd)
         ENTRY;
 
         switch (cmd)
@@ -719,17 +337,6 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                 INIT_LIST_HEAD(&obd->obd_imports);
                 spin_lock_init(&obd->obd_dev_lock);
 
                 INIT_LIST_HEAD(&obd->obd_imports);
                 spin_lock_init(&obd->obd_dev_lock);
 
-                /* do the attach */
-                if (OBP(obd, attach))
-                        err = OBP(obd,attach)(obd, sizeof(*data), data);
-                if (err) {
-                        obd->obd_type = NULL;
-                } else {
-                        obd->obd_flags |= OBD_ATTACHED;
-
-                        type->typ_refcnt++;
-                        CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
-                               obd->obd_minor, data->ioc_inlbuf1);
                         if (data->ioc_inlbuf2) {
                                 int len = strlen(data->ioc_inlbuf2) + 1;
                                 OBD_ALLOC(obd->obd_name, len);
                         if (data->ioc_inlbuf2) {
                                 int len = strlen(data->ioc_inlbuf2) + 1;
                                 OBD_ALLOC(obd->obd_name, len);
@@ -738,14 +345,9 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                                         LBUG();
                                 }
                                 memcpy(obd->obd_name, data->ioc_inlbuf2, len);
                                         LBUG();
                                 }
                                 memcpy(obd->obd_name, data->ioc_inlbuf2, len);
-                                /* obd->obd_proc_entry =
-                                        proc_lustre_register_obd_device(obd);
-                                */
                         } else {
                                 CERROR("WARNING: unnamed obd device\n");
                         } else {
                                 CERROR("WARNING: unnamed obd device\n");
-                                obd->obd_proc_entry = NULL;
                         }
                         }
-
                         if (data->ioc_inlbuf3) {
                                 int len = strlen(data->ioc_inlbuf3);
                                 if (len >= sizeof(obd->obd_uuid)) {
                         if (data->ioc_inlbuf3) {
                                 int len = strlen(data->ioc_inlbuf3);
                                 if (len >= sizeof(obd->obd_uuid)) {
@@ -758,16 +360,20 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                                 }
                                 memcpy(obd->obd_uuid, data->ioc_inlbuf3, len);
                         }
                                 }
                                 memcpy(obd->obd_uuid, data->ioc_inlbuf3, len);
                         }
+                /* do the attach */
+                if (OBP(obd, attach))
+                        err = OBP(obd,attach)(obd, sizeof(*data), data);
+                if (err) {
+                        if(data->ioc_inlbuf2)                                                
+                                OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
+                        obd->obd_type = NULL;
 
 
-                        /* Get the LprocFS namespace for this device class */
-                        l_idx = lprocfs_get_nm(data->ioc_inlbuf1, obd_nm);
-                        if (l_idx < 0) {
-                                CERROR("Non-existent device class"
-                                       "or proc/lustre not compiled \n");
                         } else {
                         } else {
-                                lprocfs_reg_dev(obd, obd_nm[l_idx].obd_names,
-                                                obd_nm[l_idx].cntr_blk_sz);
-                        }
+                        obd->obd_flags |= OBD_ATTACHED;
+
+                        type->typ_refcnt++;
+                        CDEBUG(D_IOCTL, "OBD: dev %d attached type %s\n",
+                               obd->obd_minor, data->ioc_inlbuf1);
 
                         CDEBUG(D_IOCTL, "MOD_INC_USE for attach: count = %d\n",
                                atomic_read(&(THIS_MODULE)->uc.usecount));
 
                         CDEBUG(D_IOCTL, "MOD_INC_USE for attach: count = %d\n",
                                atomic_read(&(THIS_MODULE)->uc.usecount));
@@ -795,19 +401,13 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp,
                         }
                         forcibly_detach_exports(obd);
                 }
                         }
                         forcibly_detach_exports(obd);
                 }
-
-                if (lprocfs_dereg_dev(obd) != LPROCFS_SUCCESS) {
-                        CERROR("Could not remove /proc entry\n");
-                }
+                   if (OBP(obd, detach))
+                        err=OBP(obd,detach)(obd);
 
                 if (obd->obd_name) {
                         OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
                         obd->obd_name = NULL;
                 }
 
                 if (obd->obd_name) {
                         OBD_FREE(obd->obd_name, strlen(obd->obd_name)+1);
                         obd->obd_name = NULL;
                 }
-                /*
-                if (obd->obd_proc_entry)
-                        proc_lustre_release_obd_device(obd);
-                */
 
                 obd->obd_flags &= ~OBD_ATTACHED;
                 obd->obd_type->typ_refcnt--;
 
                 obd->obd_flags &= ~OBD_ATTACHED;
                 obd->obd_type->typ_refcnt--;
@@ -1092,6 +692,7 @@ EXPORT_SYMBOL(class_uuid_unparse);
 EXPORT_SYMBOL(class_signal_connection_failure);
 EXPORT_SYMBOL(ll_sync_io_cb);
 EXPORT_SYMBOL(ll_init_cb);
 EXPORT_SYMBOL(class_signal_connection_failure);
 EXPORT_SYMBOL(ll_sync_io_cb);
 EXPORT_SYMBOL(ll_init_cb);
+EXPORT_SYMBOL(class_nm_to_type);
 
 static int __init init_obdclass(void)
 {
 
 static int __init init_obdclass(void)
 {
@@ -1114,15 +715,19 @@ static int __init init_obdclass(void)
                 obd->obd_minor = i;
 
         err = obd_init_caches();
                 obd->obd_minor = i;
 
         err = obd_init_caches();
+        
         if (err)
                 return err;
         obd_sysctl_init();
         if (err)
                 return err;
         obd_sysctl_init();
+        
+        err=lprocfs_reg_main();
+        
         return 0;
 }
 
 static void __exit cleanup_obdclass(void)
 {
         return 0;
 }
 
 static void __exit cleanup_obdclass(void)
 {
-        int i;
+        int i, err;
         ENTRY;
 
         misc_deregister(&obd_psdev);
         ENTRY;
 
         misc_deregister(&obd_psdev);
@@ -1137,6 +742,9 @@ static void __exit cleanup_obdclass(void)
 
         obd_cleanup_caches();
         obd_sysctl_clean();
 
         obd_cleanup_caches();
         obd_sysctl_clean();
+        
+        err = lprocfs_dereg_main();
+
         CERROR("obd memory leaked: %ld bytes\n", obd_memory);
         EXIT;
 }
         CERROR("obd memory leaked: %ld bytes\n", obd_memory);
         EXIT;
 }
index f188f74..fcc57a5 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/obd_class.h>
 #include <linux/random.h>
 #include <linux/slab.h>
 #include <linux/obd_class.h>
 #include <linux/random.h>
 #include <linux/slab.h>
+#include <linux/lprocfs_status.h>
 
 extern struct list_head obd_types;
 kmem_cache_t *obdo_cachep = NULL;
 
 extern struct list_head obd_types;
 kmem_cache_t *obdo_cachep = NULL;
@@ -148,9 +149,10 @@ struct obd_type *class_nm_to_type(char *nm)
         return type;
 }
 
         return type;
 }
 
-int class_register_type(struct obd_ops *ops, char *nm)
+int class_register_type(struct obd_ops *ops, struct lprocfs_vars* vars, char *nm)
 {
         struct obd_type *type;
 {
         struct obd_type *type;
+        int rc;
 
         ENTRY;
 
 
         ENTRY;
 
@@ -171,6 +173,10 @@ int class_register_type(struct obd_ops *ops, char *nm)
         list_add(&type->typ_chain, &obd_types);
         memcpy(type->typ_ops, ops, sizeof(*type->typ_ops));
         strcpy(type->typ_name, 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, (lprocfs_vars_t *)vars, (void*)type);
+        if(rc)
+                RETURN(rc);
+        
         RETURN(0);
 }
 
         RETURN(0);
 }
 
@@ -192,6 +198,8 @@ int class_unregister_type(char *nm)
                 OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
                 RETURN(-EBUSY);
         }
                 OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
                 RETURN(-EBUSY);
         }
+        if(type->typ_procroot)
+                lprocfs_dereg_class(type);
 
         list_del(&type->typ_chain);
         OBD_FREE(type->typ_name, strlen(nm) + 1);
 
         list_del(&type->typ_chain);
         OBD_FREE(type->typ_name, strlen(nm) + 1);
index 55a18e8..aef4b9b 100644 (file)
@@ -1,7 +1,7 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- * Copyright (C) 2002 Intel Corporation
+ *  Copyright (C) 2002 Cluster File Systems, Inc.
  *
  *   This file is part of Lustre, http://www.lustre.org.
  *
  *
  *   This file is part of Lustre, http://www.lustre.org.
  *
  *   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.
  *   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
- * File Name: lprocfs.c
- *
- * During initialization (of lustre), the following directory materializes
- *          /proc/lustre
- * When the first OBD device of a class is created (due to insmod)
- * the directory
- *         /proc/lustre/devices/<device-class> is created.
- * When an instance of a device is created (during attach) the
- * directory entry for that instance along with the variables for
- * that entry gets created. These variables could be counters, string
- * variables etc.
- * Each API further describes the functionality offered.
  *
  */
 
  *
  */
 
@@ -76,18 +60,16 @@ char escape_char = '%';
  * Externs
  */
 extern struct proc_dir_entry proc_root; /* Defined in proc/root.c */
  * Externs
  */
 extern struct proc_dir_entry proc_root; /* Defined in proc/root.c */
-
+extern struct obd_type *class_nm_to_type(char *nm);
 
 /*
  * Globals
  */
 
 /*
  * Globals
  */
+struct proc_dir_entry *proc_lustre_root = 0;
+struct proc_dir_entry *proc_lustre_dev_root = 0;
+
 
 
-static struct proc_dir_entry *proc_lustre_root = 0;
-static struct proc_dir_entry *proc_lustre_dev_root = 0;
 
 
-/* struct lustre_lock proc_lustre_lock; */
-/* static struct proc_dir_entry *proc_lustre_conn_root = 0; */
-char *testStr = "General..";
 
 /*
  * Link the namespace with the internal array indices for
 
 /*
  * Link the namespace with the internal array indices for
@@ -328,14 +310,6 @@ struct groupspace_index class_index[] = {
 };
 
 
 };
 
 
-/*
- *  API implementations
- */
-
-/*
- * lprocfs_reg_dev: Registers an instance of the OBD device in the
- *                       proc hierarchy
- */
 
 int lprocfs_reg_dev(struct obd_device* device, lprocfs_group_t* namespace,
                     unsigned int cnt_struct_size)
 
 int lprocfs_reg_dev(struct obd_device* device, lprocfs_group_t* namespace,
                     unsigned int cnt_struct_size)
@@ -362,6 +336,7 @@ int lprocfs_reg_dev(struct obd_device* device, lprocfs_group_t* namespace,
                        device->obd_type->typ_name);
                 return LPROCFS_FAILURE;
         }
                        device->obd_type->typ_name);
                 return LPROCFS_FAILURE;
         }
+        CDEBUG(D_OTHER, "Obtained the class array index\n");
 
         /* Create the directory namespace */
         retval = lprocfs_create_dir_namespace(this_dev_root, namespace,
 
         /* Create the directory namespace */
         retval = lprocfs_create_dir_namespace(this_dev_root, namespace,
@@ -517,7 +492,7 @@ int lprocfs_create_dir_namespace(struct proc_dir_entry* root,
 
         while (1) {
                 temp = &namespace[i];
 
         while (1) {
                 temp = &namespace[i];
-                if (temp->count_func_namespace == 0)
+                if (temp->count_func_namespace)
                         break;
                 while ((temp->dir_namespace)[j] != 0){
                         dir_root = lprocfs_add_dir(root,
                         break;
                 while ((temp->dir_namespace)[j] != 0){
                         dir_root = lprocfs_add_dir(root,
@@ -553,57 +528,6 @@ int lprocfs_getclass_idx(struct groupspace_index* group, const char* classname)
         return LPROCFS_FAILURE;
 }
 
         return LPROCFS_FAILURE;
 }
 
-struct proc_dir_entry* lprocfs_mkinitdir(struct obd_device* device)
-{
-        struct proc_dir_entry* this_dev_root = 0;
-        struct proc_dir_entry* temp_proc = 0;
-
-        /*
-         * First check if /proc/lustre exits. If it does not,
-         * instantiate the same and the devices directory
-         */
-        if (!proc_lustre_root) {
-                proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
-                if (!proc_lustre_root) {
-                        CERROR(" !! Cannot create /proc/lustre !! \n");
-                        return 0;
-                }
-                proc_lustre_dev_root =
-                        lprocfs_mkdir("devices", proc_lustre_root);
-
-                if (!proc_lustre_dev_root) {
-                        CERROR(" !! Cannot create /proc/lustre/devices !! \n");
-                        return 0;
-                }
-        }
-
-        /*
-         * Check if this is the first instance for a device of
-         * this class in the lprocfs hierarchy.
-         */
-        temp_proc = lprocfs_srch(proc_lustre_dev_root,
-                                 device->obd_type->typ_name);
-
-        if (!temp_proc) {
-                temp_proc = lprocfs_mkdir(device->obd_type->typ_name,
-                                          proc_lustre_dev_root);
-                if (!temp_proc) {
-                        CERROR("! Proc dir for device class %s !!\n",
-                               device->obd_type->typ_name);
-                        return 0;
-                }
-        }
-
-        /* Next create the proc_dir_entry for this instance */
-        this_dev_root = lprocfs_mkdir(device->obd_name, temp_proc);
-        if (!this_dev_root) {
-                CERROR("!Can't create proc entry for instance %s !! \n",
-                       device->obd_name);
-                return 0;
-        }
-
-        return this_dev_root;
-}
 
 
 int lprocfs_get_idx(struct namespace_index* class, const char* dir_name)
 
 
 int lprocfs_get_idx(struct namespace_index* class, const char* dir_name)
@@ -750,43 +674,6 @@ struct proc_dir_entry* lprocfs_add_dir(struct proc_dir_entry *root,
         return new_root;
 }
 
         return new_root;
 }
 
-struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head,
-                                    const char* name)
-{
-        struct proc_dir_entry* temp;
-
-        if (!head)
-                return 0;
-        temp = head->subdir;
-        while (temp != NULL) {
-                if (!strcmp(temp->name, name))
-                        return temp;
-                temp = temp->next;
-        }
-
-        return 0;
-}
-
-#warning FIXME: recursive code is VERY bad in the kernel because of stack limit
-struct proc_dir_entry* lprocfs_bfs_srch(struct proc_dir_entry* root,
-                                        const char* name)
-{
-        struct proc_dir_entry* temp = root;
-
-        if (!temp)
-                return 0;
-
-        if (!strcmp(temp->name, name))
-                return temp;
-
-        if ((temp = lprocfs_bfs_srch(root->next, name)) != 0)
-                return temp;
-
-        if ((temp = lprocfs_bfs_srch(root->subdir, name)) != 0)
-                return temp;
-
-        return temp;
-}
 
 int lprocfs_get_nm(char* name, lprocfs_obd_nm_t* collection)
 {
 
 int lprocfs_get_nm(char* name, lprocfs_obd_nm_t* collection)
 {
diff --git a/lustre/obdclass/lprocfs_snmp.c b/lustre/obdclass/lprocfs_snmp.c
deleted file mode 100644 (file)
index 408534d..0000000
+++ /dev/null
@@ -1,476 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
- *  Copyright (C) 2002 Cluster File Systems, Inc.
- *
- *   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.
- *
- */
-
-#define EXPORT_SYMTAB
-#include <linux/config.h>
-#include <linux/module.h>
-#include <linux/version.h>
-#include <linux/proc_fs.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-
-#define DEBUG_SUBSYSTEM S_CLASS
-#define MAX_STRING_SIZE 100
-
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
-
-#ifdef LPROCFS_EXISTS
-
-#define DEFAULT_MODE 0644
-/*
- * Tokenizer array. Change this array to include special
- * characters for string tokenizing
- */
-char tok[] = {'/', (char)0};
-
-
-
-/*
- * Externs
- */
-extern struct proc_dir_entry proc_root; /* Defined in proc/root.c */
-extern struct obd_type *class_nm_to_type(char *nm);
-
-/*
- * Globals
- */
-struct proc_dir_entry *proc_lustre_root = 0;
-struct proc_dir_entry *proc_lustre_dev_root = 0;
-
-/*
- *  API implementations
- */
-/*
- * lprocfs_reg_obd: Registers an instance of the OBD device in the
- *                  proc hierarchy
- */
-
-int lprocfs_reg_obd(struct obd_device* device, 
-                    lprocfs_vars_t* list, 
-                    void* data)
-{
-        
-        int retval = 0;
-        struct proc_dir_entry* this_dev_root=0;
-        
-
-        /* Obtain this device root */
-        this_dev_root = lprocfs_mkinitdir(device);
-        if (this_dev_root == 0) {
-                CERROR("Could not create initial directory");
-                return LPROCFS_FAILURE;
-        }
-        
-        device->obd_proc_entry=this_dev_root;
-        retval=lprocfs_new_vars(device,             \
-                                this_dev_root, list, \
-                                (const char*)tok, 
-                                data);
-                
-        return retval;
-}
-
-int lprocfs_add_new_vars(struct obd_device* device,
-                         lprocfs_vars_t* var, 
-                         void* data)
-{
-        int retval=0;
-        if(!device) {
-                CERROR("Null pointer passed!");
-                return LPROCFS_FAILURE;
-        }
-        if(!(device->obd_proc_entry)){
-                CDEBUG(D_OTHER, \
-                       "Device instance not registered yet!!");
-                return LPROCFS_FAILURE;
-      
-        }
-        retval=lprocfs_new_vars(device,
-                                device->obd_proc_entry, \
-                                var, (const char*) tok, data);
-        return retval;
-}
-
-int lprocfs_dereg_obd(struct obd_device* device)
-{
-        struct proc_dir_entry* parent;
-
-        CDEBUG(D_OTHER, "LPROCFS removing device = %s\n", \
-               device->obd_name);
-
-        if (!device) {
-                CDEBUG(D_OTHER, "! LProcfs:  Null pointer !\n");
-                return LPROCFS_SUCCESS;
-        }
-
-        if (!(device->obd_name)) {
-                CERROR(" !! Device does not have a name !! \n");
-                return LPROCFS_FAILURE;
-        }
-        if(!(device->obd_proc_entry)){
-                CERROR("This device has not been registered\n");
-                return LPROCFS_FAILURE;
-        }
-        parent=device->obd_proc_entry->parent;
-        lprocfs_remove_all(device->obd_proc_entry);
-
-        /*
-         * Free the memory held by counters
-         */
-        if (device->counters)
-                OBD_FREE(device->counters, device->cntr_mem_size);
-
-        
-        while((!(parent->subdir) && \
-               memcmp(parent, &proc_root, sizeof(*parent)))) {
-                remove_proc_entry(parent->name, parent->parent);
-                parent=parent->parent;
-        }
-
-        CDEBUG(D_OTHER, "LPROCFS removed device = %s\n", \
-               device->obd_name);
-
-        return LPROCFS_SUCCESS;
-}
-struct proc_dir_entry* lprocfs_mkinitdir(struct obd_device* device)
-{
-        struct proc_dir_entry* this_dev_root = 0;
-        struct proc_dir_entry* temp_proc = 0;
-
-        /*
-         * First check if /proc/lustre exits. If it does not,
-         * instantiate the same and the devices directory
-         */
-        if (proc_lustre_root==0) {
-                proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
-                if (!proc_lustre_root) {
-                        CERROR(" !! Cannot create /proc/lustre !! \n");
-                        return 0;
-                }
-        }
-        if (proc_lustre_dev_root==0) {
-                proc_lustre_dev_root =
-                        lprocfs_mkdir("devices", proc_lustre_root);
-                
-                if (!proc_lustre_dev_root) {
-                        CERROR(" !! Cannot create /proc/lustre/devices !! \n");
-                        return 0;
-                }
-                
-        }
-
-        /*
-         * Check if this is the first instance for a device of
-         * this class in the lprocfs hierarchy.
-         */
-        temp_proc = lprocfs_srch(proc_lustre_dev_root,
-                                 device->obd_type->typ_name);
-
-        if (!temp_proc) {
-                temp_proc = lprocfs_mkdir(device->obd_type->typ_name,
-                                          proc_lustre_dev_root);
-                if (!temp_proc) {
-                        CERROR("! Proc dir for device class %s !!\n",
-                               device->obd_type->typ_name);
-                        return 0;
-                }
-        }
-
-        /* Next create the proc_dir_entry for this instance */
-        this_dev_root = lprocfs_mkdir(device->obd_name, temp_proc);
-        if (!this_dev_root) {
-                CERROR("!Can't create proc entry for instance %s !! \n",
-                       device->obd_name);
-                return 0;
-        }
-
-        return this_dev_root;
-}
-
-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;
-}
-struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head,
-                                    const char* name)
-{
-        struct proc_dir_entry* temp;
-        
-        if (!head)
-                return 0;
-        temp = head->subdir;
-        while (temp != NULL) {
-                if (!strcmp(temp->name, name))
-                        return temp;
-                temp = temp->next;
-        }
-        
-        return 0;
-}
-
-#warning FIXME: recursive code is VERY bad in the kernel because of stack limit
-struct proc_dir_entry* lprocfs_bfs_srch(struct proc_dir_entry* root,
-                                        const char* name)
-{
-        struct proc_dir_entry* temp = root;
-
-        if (!temp)
-                return 0;
-
-        if (!strcmp(temp->name, name))
-                return temp;
-
-        if ((temp = lprocfs_bfs_srch(root->next, name)) != 0)
-                return temp;
-
-        if ((temp = lprocfs_bfs_srch(root->subdir, name)) != 0)
-                return temp;
-
-        return temp;
-}
-void lprocfs_remove_all(struct proc_dir_entry* root)
-{
-        if (root->subdir != 0)
-                lprocfs_remove_all(root->subdir);
-
-        if (root->next != 0)
-                lprocfs_remove_all(root->next);
-
-        if (root->parent != 0)
-                remove_proc_entry(root->name, root->parent);
-        else
-                remove_proc_entry(root->name, NULL);
-}
-/*
- * This function will be invoked during a module loading. The path parameter
- * is relative to /proc/lustre, and hence needs to begin as 
- * dir_1/dir_2 etc
- * The list is a simple variable list of names, which will be created under
- * the "path". If none is specified, no variable entries will be created.
- * Returns: The root for this module.
- */
-
-struct proc_dir_entry* lprocfs_reg_module(char* name, char* path, 
-                                          lprocfs_vars_t* list, 
-                                          void* data)
-{
-        struct proc_dir_entry* root=0;
-        int retVal=0;
-        if(!name){
-                CERROR("LProcFS: Null pointer for name\n");
-                return 0;
-        }
-        if(!path){
-                CERROR("LProcFS: Insertion path not provided\n");
-                return 0;
-        }
-        if (proc_lustre_root==0) {
-                proc_lustre_root = lprocfs_mkdir("lustre", &proc_root);
-                if (!proc_lustre_root) {
-                        CERROR(" !! Cannot create /proc/lustre !! \n");
-                        return 0;
-                }
-        }
-        if((root=lprocfs_new_dir(proc_lustre_root, \
-                                 path, (const char*)tok))==0){
-
-                CERROR("!! LProcFS: Failed to create dirs");
-                return 0;
-        }
-
-        root=lprocfs_mkdir(name, root);        
-        retVal=lprocfs_new_vars(NULL, root, list, \
-                                (const char*)tok, data);
-        if(retVal==LPROCFS_FAILURE) 
-                return 0;
-        return root;
-        
-}
-
-int lprocfs_dereg_module(char* name)
-{
-        struct proc_dir_entry* temp=0;
-        struct proc_dir_entry* parent=0;
-        if (proc_lustre_root==0) {
-                CERROR(" !! LProc Does not exist !! \n");
-                return 0;
-        }
-        temp = lprocfs_bfs_srch(proc_lustre_root->subdir, \
-                                name);
-        if (temp == 0) {
-                CDEBUG(D_OTHER, "!! Module not inserted!!");
-                return LPROCFS_FAILURE;
-        }
-        parent=temp->parent;
-        lprocfs_remove_all(temp);
-        while((!(parent->subdir) && \
-               memcmp(parent, &proc_root, sizeof(*parent)))) {
-                remove_proc_entry(parent->name, parent->parent);
-                parent=parent->parent;
-        }
-
-        CDEBUG(D_OTHER, "LPROCFS removed = %s\n", \
-               name);
-        
-
-        return LPROCFS_SUCCESS;
-
-}
-
-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;
-        
-        char temp_string[MAX_STRING_SIZE];
-        char* my_str;
-        char* mover_str;
-
-        /*
-         * Remove trailing escaping character
-         */
-        memset(temp_string, 0, MAX_STRING_SIZE);
-        if (strlen(string) >= MAX_STRING_SIZE) {
-                CDEBUG(D_OTHER, "Directory namespace too long");
-                return 0;
-        }
-       
-        strcpy(temp_string, string);
-        temp_string[strlen(string) + 1] = '\0';
-        
-        new_root=root;
-        mover_str=temp_string;
-        while ((my_str = strsep(&mover_str, tok))) {
-                if(!*my_str)
-                        continue;
-                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) {
-                        CDEBUG(D_OTHER, "Adding: %s\n", my_str);
-                        temp_entry = lprocfs_mkdir(my_str, new_root);
-                        if (temp_entry == 0) {
-                                CDEBUG(D_OTHER, 
-                                       "! Did not create new dir %s !!\n",
-                                       my_str);
-                                return 0;
-                        }
-                }
-                new_root = temp_entry;
-        }
-
-        return new_root;
-}
-
-
-int lprocfs_add_mod_vars(struct proc_dir_entry* root, 
-                         lprocfs_vars_t* list,
-                         void* data)
-{
-        int retval=0;
-        retval=lprocfs_new_vars(NULL, root, list, \
-                                (const char*) tok, data);
-        return retval;
-}
-
-int lprocfs_new_vars(struct obd_device* dev, 
-                     struct proc_dir_entry* root,
-                     lprocfs_vars_t* list,
-                     const char* tok, 
-                     void* data)
-{
-        struct proc_dir_entry* temp_root=0;
-        struct proc_dir_entry* new_leaf=0;
-        struct proc_dir_entry* new_parent=0;
-        char temp_string[MAX_STRING_SIZE];
-        
-        if(!list)
-                return LPROCFS_SUCCESS;
-
-        while(list->name){
-                temp_root=lprocfs_new_dir(root, \
-                                          list->name, \
-                                          tok);
-                
-                if(!temp_root){
-                        CDEBUG(D_OTHER, "!LProcFS: Mods: No root!");
-                        return LPROCFS_FAILURE;
-                }
-                /* Convert the last element into a leaf-node */
-                memset(temp_string, 0, MAX_STRING_SIZE);
-                strcpy(temp_string, temp_root->name);
-                temp_string[strlen(temp_root->name) + 1] = '\0';
-                new_parent=temp_root->parent;
-                if (new_parent != 0){
-                        remove_proc_entry(temp_root->name, new_parent);
-                } else {
-                        remove_proc_entry(temp_root->name, NULL);
-                }
-                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(dev)
-                        new_leaf->data=dev;
-                list++;
-        }
-        return LPROCFS_SUCCESS;
-
-}
-int lprocfs_ll_rd(char *page, char **start, off_t off,
-                  int count, int *eof, void *data)
-{
-        __u64 *temp = (__u64 *)data;
-        int len;
-
-        len = snprintf(page, count, LPU64"\n", *temp);
-
-        return len;
-}
-
-#endif /* LPROCFS_EXISTS */
-
-
-EXPORT_SYMBOL(lprocfs_reg_obd);
-EXPORT_SYMBOL(lprocfs_dereg_obd);
-EXPORT_SYMBOL(lprocfs_add_new_vars);
-EXPORT_SYMBOL(lprocfs_reg_module);
-EXPORT_SYMBOL(lprocfs_dereg_module);
-EXPORT_SYMBOL(lprocfs_ll_rd);
-EXPORT_SYMBOL(lprocfs_add_mod_vars);
-
diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c
new file mode 100644 (file)
index 0000000..ea2b9c4
--- /dev/null
@@ -0,0 +1,360 @@
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ *   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.
+ *
+ */
+
+#define EXPORT_SYMTAB
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/proc_fs.h>
+#include <linux/slab.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>
+
+#ifdef LPROC_SNMP
+
+#define DEFAULT_MODE 0444
+/*
+ * Tokenizer array. Change this array to include special
+ * characters for string tokenizing
+ */
+char tok[] = {'/', (char)0};
+
+
+
+/*
+ * Externs
+ */
+extern struct proc_dir_entry proc_root; /* Defined in proc/root.c */
+
+/*
+ * Globals
+ */
+struct proc_dir_entry *proc_lustre_root = 0;
+struct proc_dir_entry *proc_lustre_dev_root = 0;
+struct proc_dir_entry *proc_lustre_fs_root=0;
+
+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;
+}
+struct proc_dir_entry* lprocfs_srch(struct proc_dir_entry* head,
+                                    const char* name)
+{
+        struct proc_dir_entry* temp;
+        
+        if (!head)
+                return 0;
+        temp = head->subdir;
+        while (temp != NULL) {
+                if (!strcmp(temp->name, name))
+                        return temp;
+                temp = temp->next;
+        }
+        
+        return 0;
+}
+
+
+void lprocfs_remove_all(struct proc_dir_entry* root)
+{
+
+        struct proc_dir_entry *temp=root;
+        struct proc_dir_entry* rm_entry;
+
+        while(1){
+
+                while(temp->subdir){
+                        temp=temp->subdir;
+        }
+                rm_entry=temp;
+                temp=temp->parent;
+                remove_proc_entry(rm_entry->name, rm_entry->parent);
+                if(temp==root->parent) break;
+
+        }
+
+
+}
+
+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;
+        
+        char temp_string[MAX_STRING_SIZE];
+        char* my_str;
+        char* mover_str;
+
+        /*
+         * Remove trailing escaping character
+         */
+        memset(temp_string, 0, MAX_STRING_SIZE);
+        if (strlen(string) >= MAX_STRING_SIZE) {
+                CDEBUG(D_OTHER, "Directory namespace too long");
+                return 0;
+        }
+       
+        strcpy(temp_string, string);
+        temp_string[strlen(string) + 1] = '\0';
+        
+        new_root=root;
+        mover_str=temp_string;
+        while ((my_str = strsep(&mover_str, tok))) {
+                if(!*my_str)
+                        continue;
+                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) {
+                        CDEBUG(D_OTHER, "Adding: %s\n", my_str);
+                        temp_entry = lprocfs_mkdir(my_str, new_root);
+                        if (temp_entry == 0) {
+                                CDEBUG(D_OTHER, 
+                                       "! Did not create new dir %s !!\n",
+                                       my_str);
+                                return 0;
+                        }
+                }
+                new_root = temp_entry;
+        }
+
+        return new_root;
+}
+
+int lprocfs_new_vars(struct proc_dir_entry* root,
+                     lprocfs_vars_t* list,
+                     const char* tok, 
+                     void* data)
+{
+        struct proc_dir_entry* temp_root=0;
+        struct proc_dir_entry* new_leaf=0;
+        struct proc_dir_entry* new_parent=0;
+        char temp_string[MAX_STRING_SIZE];
+        
+        if(!list)
+                return 0;
+
+        while(list->name){
+                temp_root=lprocfs_new_dir(root, list->name, tok);
+                
+                if(!temp_root){
+                        CDEBUG(D_OTHER, "!LProcFS: Mods: No root!");
+                        return -EINVAL;
+                }
+                /* Convert the last element into a leaf-node */
+                memset(temp_string, 0, MAX_STRING_SIZE);
+                strcpy(temp_string, temp_root->name);
+                temp_string[strlen(temp_root->name) + 1] = '\0';
+                new_parent=temp_root->parent;
+                if (new_parent != 0){
+                        remove_proc_entry(temp_root->name, new_parent);
+                } else {
+                        remove_proc_entry(temp_root->name, NULL);
+                }
+                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;
+                list++;
+        }
+        return 0;
+
+}
+
+/*
+ *  API implementations
+ */
+
+int lprocfs_add_vars(struct proc_dir_entry* root,
+                     lprocfs_vars_t* var, 
+                     void* data)
+{
+            
+        return lprocfs_new_vars(root, var, 
+                                (const char*) tok, data);
+
+        
+}
+
+int lprocfs_reg_obd(struct obd_device* device, 
+                    lprocfs_vars_t* list, 
+                    void* data)
+{
+        
+        int retval = 0;
+        struct proc_dir_entry* this_dev_root=0;
+        
+        /* Obtain this device root */
+        this_dev_root = lprocfs_mkdir(device->obd_name, 
+                                      device->obd_type->typ_procroot);
+            
+        device->obd_proc_entry=this_dev_root;
+        retval=lprocfs_add_vars(this_dev_root, list, 
+                                data);
+                
+        return retval;
+}
+
+int lprocfs_dereg_obd(struct obd_device* device)
+{
+
+        CDEBUG(D_OTHER, "LPROCFS removing device = %s\n", device->obd_name);
+
+        if (!device) {
+                CDEBUG(D_OTHER, "! LProcfs:  Null pointer !\n");
+                return 0;
+        }
+
+        lprocfs_remove_all(device->obd_proc_entry);
+
+        if (device->counters)
+                OBD_FREE(device->counters, device->cntr_mem_size);
+
+        return 0;
+}
+
+struct proc_dir_entry* lprocfs_reg_mnt(char* mnt_name)
+{
+        return lprocfs_mkdir(mnt_name, proc_lustre_fs_root);
+                       
+}
+
+int lprocfs_dereg_mnt(struct proc_dir_entry* root)
+{
+        lprocfs_remove_all(root);
+         return 0;
+        
+}
+
+int lprocfs_reg_class(struct obd_type* type,
+                      lprocfs_vars_t* list, 
+                      void* data)
+{
+        struct proc_dir_entry* root;
+        int retval;
+
+        root=lprocfs_mkdir(type->typ_name, proc_lustre_dev_root);        
+        
+        type->typ_procroot=root;
+
+        retval=lprocfs_add_vars(root, list, data);
+
+        return retval;
+}
+
+int lprocfs_dereg_class(struct obd_type* class)
+{
+        if(!class){
+                CDEBUG(D_OTHER, "Non-existent class",
+                       class->typ_name);
+                return 0;
+        }
+                
+        lprocfs_remove_all(class->typ_procroot);
+      
+        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) {
+                CERROR(" !! Cannot create /proc/lustre !! \n");
+                return -EINVAL;
+        }
+                
+        proc_lustre_dev_root =lprocfs_mkdir("devices", proc_lustre_root);
+        
+        if (!proc_lustre_dev_root) {
+                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) {
+                CERROR(" !! Cannot create /proc/lustre/mnt_pnt !! \n");
+                return -EINVAL;
+        }
+        
+        return 0;
+
+}
+
+int lprocfs_dereg_main()
+{
+        lprocfs_remove_all(proc_lustre_root);
+        proc_lustre_root=0;
+        proc_lustre_dev_root=0;
+        proc_lustre_fs_root=0;
+        return 0;
+
+}
+
+
+/* 
+ * Needs to go...
+ */
+
+int lprocfs_ll_rd(char *page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        __u64 *temp = (__u64 *)data;
+        int len;
+
+        len = snprintf(page, count, LPU64"\n", *temp);
+
+        return len;
+}
+
+#endif /* LPROC_SNMP */
+
+
+EXPORT_SYMBOL(lprocfs_reg_obd);
+EXPORT_SYMBOL(lprocfs_dereg_obd);
+EXPORT_SYMBOL(lprocfs_reg_main);
+EXPORT_SYMBOL(lprocfs_dereg_main);
+EXPORT_SYMBOL(lprocfs_reg_mnt);
+EXPORT_SYMBOL(lprocfs_dereg_mnt);
+EXPORT_SYMBOL(lprocfs_add_vars);
+EXPORT_SYMBOL(lprocfs_reg_class);
+EXPORT_SYMBOL(lprocfs_dereg_class);
+EXPORT_SYMBOL(lprocfs_ll_rd);
+
+
index 8539f01..b0ddafe 100644 (file)
@@ -9,7 +9,7 @@ modulefs_DATA = obdecho.o
 EXTRA_PROGRAMS = obdecho
 
 LINX=
 EXTRA_PROGRAMS = obdecho
 
 LINX=
-obdecho_SOURCES = echo.c $(LINX)
+obdecho_SOURCES = echo.c lproc_echo.c $(LINX)
 
 include $(top_srcdir)/Rules
 
 
 include $(top_srcdir)/Rules
 
index 2b09d95..f310687 100644 (file)
@@ -12,8 +12,8 @@
  * and Andreas Dilger <adilger@clusterfs.com>
  */
 
  * and Andreas Dilger <adilger@clusterfs.com>
  */
 
-static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.41 2002/10/18 22:32:45 pschwan Exp $";
-#define OBDECHO_VERSION "$Revision: 1.41 $"
+static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.42 2002/11/01 17:23:13 thantry Exp $";
+#define OBDECHO_VERSION "$Revision: 1.42 $"
 
 #define EXPORT_SYMTAB
 
 
 #define EXPORT_SYMTAB
 
@@ -38,6 +38,7 @@ static char rcsid[] __attribute ((unused)) = "$Id: echo.c,v 1.41 2002/10/18 22:3
 #include <linux/obd_echo.h>
 #include <linux/lustre_debug.h>
 #include <linux/lustre_dlm.h>
 #include <linux/obd_echo.h>
 #include <linux/lustre_debug.h>
 #include <linux/lustre_dlm.h>
+#include <linux/lprocfs_status.h>
 
 static atomic_t echo_page_rws;
 static atomic_t echo_getattrs;
 
 static atomic_t echo_page_rws;
 static atomic_t echo_getattrs;
@@ -45,6 +46,9 @@ static atomic_t echo_getattrs;
 #define ECHO_PROC_STAT "sys/obdecho"
 #define ECHO_INIT_OBJID 0x1000000000000000ULL
 
 #define ECHO_PROC_STAT "sys/obdecho"
 #define ECHO_INIT_OBJID 0x1000000000000000ULL
 
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
+
 int echo_proc_read(char *page, char **start, off_t off, int count, int *eof,
                    void *data)
 {
 int echo_proc_read(char *page, char **start, off_t off, int count, int *eof,
                    void *data)
 {
@@ -425,7 +429,26 @@ static int echo_cleanup(struct obd_device *obddev)
         RETURN(0);
 }
 
         RETURN(0);
 }
 
+int echo_attach(struct obd_device *dev, 
+                   obd_count len, void *data)
+{
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
+
+int echo_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
+
+}
+
+
 struct obd_ops echo_obd_ops = {
 struct obd_ops echo_obd_ops = {
+        o_attach:       echo_attach,
+        o_detach:       echo_detach,
         o_connect:      echo_connect,
         o_disconnect:   echo_disconnect,
         o_create:       echo_create,
         o_connect:      echo_connect,
         o_disconnect:   echo_disconnect,
         o_create:       echo_create,
@@ -442,16 +465,25 @@ struct obd_ops echo_obd_ops = {
 
 static int __init obdecho_init(void)
 {
 
 static int __init obdecho_init(void)
 {
+        int rc;
+        
+
         printk(KERN_INFO "Echo OBD driver " OBDECHO_VERSION
                " info@clusterfs.com\n");
 
         echo_proc_init();
         printk(KERN_INFO "Echo OBD driver " OBDECHO_VERSION
                " info@clusterfs.com\n");
 
         echo_proc_init();
+        rc = class_register_type(&echo_obd_ops, 
+                                 (lprocfs_vars_t*)status_class_var, 
+                                 OBD_ECHO_DEVICENAME);
+        if (rc) RETURN(rc);
+        
+        return 0;
 
 
-        return class_register_type(&echo_obd_ops, OBD_ECHO_DEVICENAME);
 }
 
 static void __exit obdecho_exit(void)
 {
 }
 
 static void __exit obdecho_exit(void)
 {
+                
         echo_proc_fini();
 
         class_unregister_type(OBD_ECHO_DEVICENAME);
         echo_proc_fini();
 
         class_unregister_type(OBD_ECHO_DEVICENAME);
index 96ecf7f..4592f6b 100644 (file)
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  */
-#define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+#define DEBUG_SUBSYSTEM S_ECHO
+
+#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)
@@ -47,8 +46,22 @@ int rd_fstype(char* page, char **start, off_t off,
 }
 
 
 }
 
 
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/fstype", rd_fstype, 0},
+lprocfs_vars_t status_var_nm_1[]={
+        {"status/uuid", rd_uuid, 0},
+        {"status/fstype", rd_fstype, 0},
+        {0}
+};
+
+int rd_numdevices(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+        return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index 68eeee2..a237004 100644 (file)
@@ -15,7 +15,7 @@ ll_pack.c:
 simple.c:
        test -e simple.c || ln -sf $(top_srcdir)/lib/simple.c
 
 simple.c:
        test -e simple.c || ln -sf $(top_srcdir)/lib/simple.c
 
-FILTERC = filter.c
+FILTERC = filter.c lproc_obdfilter.c
 obdfilter_SOURCES = $(FILTERC) $(LINX)
 
 dist-hook:
 obdfilter_SOURCES = $(FILTERC) $(LINX)
 
 dist-hook:
index 2c890a5..46e5784 100644 (file)
 #include <linux/init.h>
 #include <linux/random.h>
 #include <linux/stringify.h>
 #include <linux/init.h>
 #include <linux/random.h>
 #include <linux/stringify.h>
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_class_var[];
+extern lprocfs_vars_t status_var_nm_1[];
 
 static kmem_cache_t *filter_open_cache;
 static kmem_cache_t *filter_dentry_cache;
 
 static kmem_cache_t *filter_open_cache;
 static kmem_cache_t *filter_dentry_cache;
@@ -1751,9 +1755,25 @@ int filter_copy_data(struct lustre_handle *dst_conn, struct obdo *dst,
 
         RETURN(err);
 }
 
         RETURN(err);
 }
+int filter_attach(struct obd_device *dev, 
+                   obd_count len, void *data)
+{
 
 
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
 
 
+int filter_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
+
+}
 static struct obd_ops filter_obd_ops = {
 static struct obd_ops filter_obd_ops = {
+        o_attach:      filter_attach,
+        o_detach:      filter_detach,
         o_get_info:    filter_get_info,
         o_setup:       filter_setup,
         o_cleanup:     filter_cleanup,
         o_get_info:    filter_get_info,
         o_setup:       filter_setup,
         o_cleanup:     filter_cleanup,
@@ -1796,7 +1816,9 @@ static int __init obdfilter_init(void)
                 RETURN(-ENOMEM);
         }
 
                 RETURN(-ENOMEM);
         }
 
-        return class_register_type(&filter_obd_ops, OBD_FILTER_DEVICENAME);
+        return class_register_type(&filter_obd_ops, 
+                                   (lprocfs_vars_t*)status_class_var,
+                                   OBD_FILTER_DEVICENAME);
 }
 
 static void __exit obdfilter_exit(void)
 }
 
 static void __exit obdfilter_exit(void)
index a97605d..ab37589 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#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)
@@ -43,91 +42,110 @@ int rd_blksize(char* page, char **start, off_t off,
         struct obd_device* temp=(struct obd_device*)data;
         struct statfs mystats;
 
         struct obd_device* temp=(struct obd_device*)data;
         struct statfs mystats;
 
-        int rc, len=0;
+        int len=0;
 
 
-        rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
-        if (rc) {
-                CERROR("obdfilter: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bsize)); 
+        vfs_statfs(temp->u.filter.fo_sb, &mystats);
+
+        len+=snprintf(page, count, "%ld\n", mystats.f_bsize); 
         return len;
         
 
 }
         return len;
         
 
 }
-int rd_blktotal(char* page, char **start, off_t off,
+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 statfs mystats;
                 int count, int *eof, void *data)
 {
         struct obd_device* temp=(struct obd_device*)data;
         struct statfs mystats;
+        int len=0;
+        __u64 result;
 
 
-        int rc, len=0;
+        vfs_statfs(temp->u.filter.fo_sb, &mystats);
+        
+        result=((__u64)(mystats.f_blocks*mystats.f_bsize))>>10;
+
+        len+=snprintf(page, count, LPU64"\n", result); 
 
 
-        rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
-        if (rc) {
-                CERROR("obdfilter: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_blocks)); 
         return len;   
 }
 
         return len;   
 }
 
-int rd_blkfree(char* page, char **start, off_t off,
+int rd_kbfree(char* page, char **start, off_t off,
                int count, int *eof, void *data)
 {
         struct obd_device* temp=(struct obd_device*)data;
         struct statfs mystats;
 
                int count, int *eof, void *data)
 {
         struct obd_device* temp=(struct obd_device*)data;
         struct statfs mystats;
 
-        int rc, len=0;
+        int len=0;
+        __u64 result;
+
+        vfs_statfs(temp->u.filter.fo_sb, &mystats);
+        result=((__u64)(mystats.f_bfree*mystats.f_bsize))>>10;
 
 
-        rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
-        if (rc) {
-                CERROR("obdfilter: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.f_bfree)); 
+        len+=snprintf(page, count, LPU64"\n", result); 
         return len;     
 }
 
         return len;     
 }
 
-int rd_kbfree(char* page, char **start, off_t off,
+int rd_fstype(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        
+        struct obd_device* temp=(struct obd_device*)data;
+        int len=0;
+        
+        len+=snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
+        return len;
+        
+}
+int rd_files(char* page, char **start, off_t off,
               int count, int *eof, void *data)
 { 
               int count, int *eof, void *data)
 { 
+        
         struct obd_device* temp=(struct obd_device*)data;
         struct statfs mystats;
 
         struct obd_device* temp=(struct obd_device*)data;
         struct statfs mystats;
 
-        int rc, len=0, blk_size=0;
+         int len=0;
 
 
-        rc = vfs_statfs(temp->u.filter.fo_sb, &mystats);
-        if (rc) {
-                CERROR("obdfilter: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        blk_size=mystats.f_bsize;
+         vfs_statfs(temp->u.filter.fo_sb, &mystats);
 
 
-        len+=snprintf(page, count, LPU64"\n", \
-                      (__u64)((mystats.f_bfree)/(blk_size*1024))); 
+         len+=snprintf(page, count, "%ld\n", mystats.f_files); 
         return len;
         return len;
-                
 }
 
 }
 
-int rd_fstype(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
                   int count, int *eof, void *data)
 {
                   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;
         
-        len+=snprintf(page, count, "%s\n", temp->u.filter.fo_fstype);
+        vfs_statfs(temp->u.filter.fo_sb, &mystats);
+        
+        len+=snprintf(page, count, "%ld\n", mystats.f_ffree); 
         return len;
         
         return len;
         
+        
+}
+
+lprocfs_vars_t 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},
+        {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+        return len;
 }
 
 }
 
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/f_blocksize",rd_blksize, 0},
-        {"snmp/f_blockstotal",rd_blktotal, 0},
-        {"snmp/f_blocksfree",rd_blkfree, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_fstype", rd_fstype, 0},
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index 5c0557e..284c2d6 100644 (file)
@@ -10,7 +10,7 @@ modulefs_DATA = osc.o
 EXTRA_PROGRAMS = osc
 
 LINX= obd_pack.c ll_pack.c client.c
 EXTRA_PROGRAMS = osc
 
 LINX= obd_pack.c ll_pack.c client.c
-osc_SOURCES = osc_request.c $(LINX)
+osc_SOURCES = osc_request.c lproc_osc.c $(LINX)
 
 obd_pack.c: 
        test -e obd_pack.c || ln -sf $(top_srcdir)/lib/obd_pack.c
 
 obd_pack.c: 
        test -e obd_pack.c || ln -sf $(top_srcdir)/lib/obd_pack.c
index 698184c..0ee8873 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
+
+#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)
@@ -100,16 +98,29 @@ int rd_conn_uuid(char* page, char **start, off_t off,
         
 }
 
         
 }
 
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/f_blocksize",rd_blksize, 0},
-        {"snmp/f_blockstotal",rd_blktotal, 0},
-        {"snmp/f_blocksfree",rd_blkfree, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_objects", rd_numobjects, 0},
-        {"snmp/f_objectsfree", rd_objfree, 0},
-        {"snmp/f_objectgroups", rd_objgroups, 0},
-        {"snmp/ost_server_uuid", rd_server_uuid, 0},
-        {"snmp/ost_conn_uuid", rd_conn_uuid, 0},
+lprocfs_vars_t 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},
+        {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+        return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index 610287a..5700797 100644 (file)
 #include <linux/obd_support.h> /* for OBD_FAIL_CHECK */
 #include <linux/lustre_lite.h> /* for ll_i2info */
 #include <portals/lib-types.h> /* for PTL_MD_MAX_IOV */
 #include <linux/obd_support.h> /* for OBD_FAIL_CHECK */
 #include <linux/lustre_lite.h> /* for ll_i2info */
 #include <portals/lib-types.h> /* for PTL_MD_MAX_IOV */
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
 
 static int osc_getattr(struct lustre_handle *conn, struct obdo *oa,
                        struct lov_stripe_md *md)
 
 static int osc_getattr(struct lustre_handle *conn, struct obdo *oa,
                        struct lov_stripe_md *md)
@@ -815,7 +819,24 @@ out:
         return err;
 }
 
         return err;
 }
 
+int osc_attach(struct obd_device *dev, 
+                   obd_count len, void *data)
+{
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
+
+int osc_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
+
+}
 struct obd_ops osc_obd_ops = {
 struct obd_ops osc_obd_ops = {
+        o_attach:       osc_attach,
+        o_detach:       osc_detach,
         o_setup:        client_obd_setup,
         o_cleanup:      client_obd_cleanup,
         o_statfs:       osc_statfs,
         o_setup:        client_obd_setup,
         o_cleanup:      client_obd_cleanup,
         o_statfs:       osc_statfs,
@@ -837,7 +858,15 @@ struct obd_ops osc_obd_ops = {
 
 static int __init osc_init(void)
 {
 
 static int __init osc_init(void)
 {
-        return class_register_type(&osc_obd_ops, LUSTRE_OSC_NAME);
+        int rc;
+        
+        rc = class_register_type(&osc_obd_ops,
+                                 (lprocfs_vars_t*)status_class_var, 
+                                 LUSTRE_OSC_NAME);
+        if (rc)
+                RETURN(rc);
+        return 0;
+       
 }
 
 static void __exit osc_exit(void)
 }
 
 static void __exit osc_exit(void)
index d4e8288..3ad390a 100644 (file)
@@ -17,7 +17,7 @@ obd_pack.c:
 target.c: 
        test -e target.c || ln -sf $(top_srcdir)/lib/target.c
 
 target.c: 
        test -e target.c || ln -sf $(top_srcdir)/lib/target.c
 
-ost_SOURCES = ost_handler.c $(LINX)
+ost_SOURCES = ost_handler.c lproc_ost.c $(LINX)
 dist-hook:
        list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done
 
 dist-hook:
        list='$(LINX)'; for f in $$list; do rm -f $(distdir)/$$f; done
 
index 8a8f1e1..8878ad0 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_OST
  *
  */
 #define DEBUG_SUBSYSTEM S_OST
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
 
 
-/* Required for 64 bit division */
-#include <asm/div64.h>
+#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)
@@ -48,57 +44,43 @@ int rd_blksize(char* page, char **start, off_t off,
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
-        int rc, len=0;
+        int len=0;
         
         
-        rc = obd_statfs(conn, &mystats);
-        if (rc) {
-                CERROR("ost: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_bsize)); 
+        obd_statfs(conn, &mystats);
+        len+=snprintf(page, count, "%d\n", mystats.os_bsize); 
         return len;
         
 }
         return len;
         
 }
-int rd_blktotal(char* page, char **start, off_t off,
+int rd_kbtotal(char* page, char **start, off_t off,
                 int count, int *eof, void *data)
 {
                 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_statfs mystats;
         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 rc, len=0;
+        int len=0;
+        __u32 blk_size;
+        __u64 result;
         
         
-        rc = obd_statfs(conn, &mystats);
-        if (rc) {
-                CERROR("ost: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_blocks)); 
-        return len;
         
         
-}
+        obd_statfs(conn, &mystats);
 
 
-int rd_blkfree(char* page, char **start, off_t off,
-               int count, int *eof, void *data)
-{
+        blk_size=mystats.os_bsize;
+        blk_size>>=10;
         
         
-        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 rc, len=0;
+        result=mystats.os_blocks;
         
         
-        rc = obd_statfs(conn, &mystats);
-        if (rc) {
-                CERROR("ost: statfs failed: rc %d\n", rc);
-                return 0;
+        while(blk_size>>=1){
+                result<<=1;
         }
         }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_bfree)); 
+       
+        len+=snprintf(page, count, LPU64"\n", result);
         return len;
         
         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)
 {
@@ -107,30 +89,27 @@ int rd_kbfree(char* page, char **start, off_t off,
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
-        int rc, len=0;
+        int len=0;
         __u32 blk_size;
         __u64 result;
         __u32 blk_size;
         __u64 result;
-        __u32 remainder;
 
 
-        rc = obd_statfs(conn, &mystats);
-        if (rc) {
-                CERROR("ost: statfs failed: rc %d\n", rc);
-                return 0;
-        }
+        obd_statfs(conn, &mystats);
+        
         blk_size=mystats.os_bsize;
         blk_size=mystats.os_bsize;
-        blk_size*=1024;
+        blk_size>>=10;
+
         result=mystats.os_bfree;
         result=mystats.os_bfree;
-        remainder=do_div(result, blk_size);
 
 
-        len+=snprintf(page, count, LPU64"\n", \
-                      result);
+        while(blk_size>>=1){
+                result<<=1;
+        }
         
         
+        len+=snprintf(page, count, LPU64"\n", result);
         return len;  
         
         return len;  
         
-       
 }
 
 }
 
-int rd_numobjects(char* page, char **start, off_t off,
+int rd_files(char* page, char **start, off_t off,
                   int count, int *eof, void *data)
 {
         
                   int count, int *eof, void *data)
 {
         
@@ -138,19 +117,16 @@ int rd_numobjects(char* page, char **start, off_t off,
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
-        int rc, len=0;
+        int len=0;
         
         
-        rc = obd_statfs(conn, &mystats);
-        if (rc) {
-                CERROR("ost: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_files)); 
+        obd_statfs(conn, &mystats);
+        
+        len+=snprintf(page, count, LPU64"\n",mystats.os_files); 
         return len;
         
 }
 
         return len;
         
 }
 
-int rd_objfree(char* page, char **start, off_t off,
+int rd_filesfree(char* page, char **start, off_t off,
                int count, int *eof, void *data)
 {
         
                int count, int *eof, void *data)
 {
         
@@ -158,14 +134,10 @@ int rd_objfree(char* page, char **start, off_t off,
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
         struct ost_obd *ost=&temp->u.ost;
         struct lustre_handle *conn=&ost->ost_conn;
         struct obd_statfs mystats;
-        int rc, len=0;
+        int len=0;
         
         
-        rc = obd_statfs(conn, &mystats);
-        if (rc) {
-                CERROR("ost: statfs failed: rc %d\n", rc);
-                return 0;
-        }
-        len+=snprintf(page, count, LPU64"\n", (__u64)(mystats.os_ffree)); 
+        obd_statfs(conn, &mystats);
+        len+=snprintf(page, count, LPU64"\n", mystats.os_ffree); 
         return len;
         
 }
         return len;
         
 }
@@ -176,14 +148,27 @@ int rd_objgroups(char* page, char **start, off_t off,
         return 0;
 }
 
         return 0;
 }
 
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/f_blocksize",rd_blksize, 0},
-        {"snmp/f_blockstotal",rd_blktotal, 0},
-        {"snmp/f_blocksfree",rd_blkfree, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_objects", rd_numobjects, 0},
-        {"snmp/f_objectsfree", rd_objfree, 0},
-        {"snmp/f_objectgroups", rd_objgroups, 0},
+lprocfs_vars_t 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},
+        {0}
+};
+
+int rd_numdevices(char* page, char **start, off_t off,
+                  int count, int *eof, void *data)
+{
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+        return len;
+}
+
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index 0378840..9282752 100644 (file)
 #include <linux/lustre_net.h>
 #include <linux/lustre_dlm.h>
 #include <linux/init.h>
 #include <linux/lustre_net.h>
 #include <linux/lustre_dlm.h>
 #include <linux/init.h>
+#include <linux/lprocfs_status.h>
+
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
 
 static int ost_destroy(struct ptlrpc_request *req)
 {
 
 static int ost_destroy(struct ptlrpc_request *req)
 {
@@ -665,21 +669,50 @@ static int ost_cleanup(struct obd_device * obddev)
         MOD_DEC_USE_COUNT;
         RETURN(0);
 }
         MOD_DEC_USE_COUNT;
         RETURN(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, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return 0; 
+}
+
+int ost_detach(struct obd_device *dev)
+{
+        /* lprocfs_dereg_dev(dev); */
+        lprocfs_dereg_obd(dev);
+        return 0;
+
+}
+
+
 
 /* use obd ops to offer management infrastructure */
 static struct obd_ops ost_obd_ops = {
 
 /* use obd ops to offer management infrastructure */
 static struct obd_ops ost_obd_ops = {
+        o_attach:      ost_attach,
+        o_detach:      ost_detach,
         o_setup:       ost_setup,
         o_cleanup:     ost_cleanup,
 };
 
 static int __init ost_init(void)
 {
         o_setup:       ost_setup,
         o_cleanup:     ost_cleanup,
 };
 
 static int __init ost_init(void)
 {
-        class_register_type(&ost_obd_ops, LUSTRE_OST_NAME);
+        int rc;
+
+        rc = class_register_type(&ost_obd_ops,
+                                 (lprocfs_vars_t*)status_class_var, 
+                                 LUSTRE_OST_NAME);
+        if (rc) RETURN(rc);
+
         return 0;
         return 0;
+
 }
 
 static void __exit ost_exit(void)
 {
 }
 
 static void __exit ost_exit(void)
 {
+        
         class_unregister_type(LUSTRE_OST_NAME);
 }
 
         class_unregister_type(LUSTRE_OST_NAME);
 }
 
index 89000de..dd3f9d8 100644 (file)
@@ -9,6 +9,6 @@ MODULE = ptlrpc
 modulefs_DATA = ptlrpc.o
 EXTRA_PROGRAMS = ptlrpc
 
 modulefs_DATA = ptlrpc.o
 EXTRA_PROGRAMS = ptlrpc
 
-ptlrpc_SOURCES = recovd.c recover.c connection.c rpc.c events.c service.c client.c niobuf.c pack_generic.c
+ptlrpc_SOURCES = recovd.c recover.c connection.c rpc.c events.c service.c client.c niobuf.c pack_generic.c lproc_ptlrpc.c
 
 include $(top_srcdir)/Rules
 
 include $(top_srcdir)/Rules
index 3e91850..48a8401 100644 (file)
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
  *
  */
 #define DEBUG_SUBSYSTEM S_CLASS
-#include <linux/obd_support.h>
-#include <linux/obd_class.h>
-#include <linux/lprocfs.h>
-#include <linux/string.h>
-#include <linux/lustre_lib.h>
-
-
 
 
+#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 len=0;
 
 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", \
+        len+=snprintf(page, count, "%s\n", 
                       ((struct obd_device*)data)->obd_uuid);
         return len;
 
 }
 
                       ((struct obd_device*)data)->obd_uuid);
         return len;
 
 }
 
-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)
-{
-        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)
-{
-        return 0;
-}
-
-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)
-{
-        return 0;
-}
-
-int rd_objgroups(char* page, char **start, off_t off,
-                 int count, int *eof, void *data)
-{
-        return 0;
-}
-
-
-int rd_fs_type(char* page, char **start, off_t off,
+lprocfs_vars_t status_var_nm_1[]={
+        {"status/uuid", rd_uuid, 0},
+        {0}
+};
+int rd_numdevices(char* page, char **start, off_t off,
                int count, int *eof, void *data)
 {
                int count, int *eof, void *data)
 {
-        return 0;
-}
-
-int rd_other(char* page, char **start, off_t off, int count, int *eof,
-             void *data)
-{
-        return 0;
-}
-
-int rd_string(char* page, char **start, off_t off, int count, int *eof,
-              void *data)
-{
-        printk("Hello string");
-        return 0;
-}
-
-int lprocfs_ll_wr(struct file* file, const char *buffer, unsigned long count,
-                  void *data)
-{
-        return 0;
-}
-
-int wr_other(struct file* file, const char *buffer, unsigned long count,
-             void *data)
-{
-        return 0;
+        struct obd_type* class=(struct obd_type*)data;
+        int len=0;
+        len+=snprintf(page, count, "%d\n", class->typ_refcnt);
+        return len;
 }
 
 }
 
-int wr_string(struct file* file, const char *buffer, unsigned long count,
-              void *data)
-{
-        return 0;
-}
-lprocfs_vars_t snmp_var_nm_1[]={
-        {"snmp/uuid", rd_uuid, 0},
-        {"snmp/f_blocksize",rd_blksize, 0},
-        {"snmp/f_blockstotal",rd_blktotal, 0},
-        {"snmp/f_blocksfree",rd_blkfree, 0},
-        {"snmp/f_kbytesfree", rd_kbfree, 0},
-        {"snmp/f_objects", rd_numobjects, 0},
-        {"snmp/f_objectsfree", rd_objfree, 0},
-        {"snmp/f_objectgroups", rd_objgroups, 0},
+lprocfs_vars_t status_class_var[]={
+        {"status/num_devices", rd_numdevices, 0},
         {0}
 };
         {0}
 };
index cb89c76..7cdd2a6 100644 (file)
 #include <linux/lustre_ha.h>
 #include <linux/lustre_net.h>
 #include <linux/init.h>
 #include <linux/lustre_ha.h>
 #include <linux/lustre_net.h>
 #include <linux/init.h>
+#include <linux/lprocfs_status.h>
+
+
 
 extern int ptlrpc_init_portals(void);
 extern void ptlrpc_exit_portals(void);
 
 
 extern int ptlrpc_init_portals(void);
 extern void ptlrpc_exit_portals(void);
 
+extern lprocfs_vars_t status_var_nm_1[];
+extern lprocfs_vars_t status_class_var[];
+
 int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
 {
         struct recovd_obd *recovd = &obddev->u.recovd;
 int connmgr_setup(struct obd_device *obddev, obd_count len, void *buf)
 {
         struct recovd_obd *recovd = &obddev->u.recovd;
@@ -160,9 +166,25 @@ static int connmgr_connect(struct lustre_handle *conn, struct obd_device *src,
 {
         return class_connect(conn, src, cluuid);
 }
 {
         return class_connect(conn, src, cluuid);
 }
+int connmgr_attach(struct obd_device *dev, 
+                   obd_count len, void *data)
+{
+        int rc;
+        rc = lprocfs_reg_obd(dev, (lprocfs_vars_t*)status_var_nm_1, (void*)dev);
+        return rc; 
+}
+
+int conmgr_detach(struct obd_device *dev)
+{
+        int rc;
+        rc = lprocfs_dereg_obd(dev);
+        return rc;
 
 
+}
 /* use obd ops to offer management infrastructure */
 static struct obd_ops recovd_obd_ops = {
 /* use obd ops to offer management infrastructure */
 static struct obd_ops recovd_obd_ops = {
+        o_attach:      connmgr_attach,
+        o_detach:      conmgr_detach,
         o_setup:       connmgr_setup,
         o_cleanup:     connmgr_cleanup,
         o_iocontrol:   connmgr_iocontrol,
         o_setup:       connmgr_setup,
         o_cleanup:     connmgr_cleanup,
         o_iocontrol:   connmgr_iocontrol,
@@ -177,8 +199,16 @@ static int __init ptlrpc_init(void)
         if (rc) 
                 RETURN(rc);
         ptlrpc_init_connection();
         if (rc) 
                 RETURN(rc);
         ptlrpc_init_connection();
-        class_register_type(&recovd_obd_ops, LUSTRE_HA_NAME);
+        rc = class_register_type(&recovd_obd_ops, 
+                                 (lprocfs_vars_t*)status_class_var,
+                                 LUSTRE_HA_NAME);
+        if (rc) 
+                RETURN(rc);
         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
         ptlrpc_put_connection_superhack = ptlrpc_put_connection;
+
+        if (rc)
+                RETURN(rc);
+                
         return 0;
 }
 
         return 0;
 }