Whamcloud - gitweb
Merge lprocfs changes from b_intel to b_md.
authoradilger <adilger>
Fri, 10 Jan 2003 18:41:29 +0000 (18:41 +0000)
committeradilger <adilger>
Fri, 10 Jan 2003 18:41:29 +0000 (18:41 +0000)
This code is tagged as MD_INTEL_BASE in b_intel, so that we can do further
merges from b_intel before we land b_md on HEAD if needed.

lustre/cobd/cache_obd.c
lustre/cobd/lproc_cache.c
lustre/obdclass/statfs_pack.c
lustre/ptlbd/client.c
lustre/ptlbd/server.c

index ac921d8..e63d15f 100644 (file)
 #include <linux/obd_class.h>
 #include <linux/obd_cache.h>
 
-extern struct lprocfs_vars status_var_nm_1[];
-extern struct lprocfs_vars status_class_var[];
-
-static int
-cobd_attach (struct obd_device *dev, obd_count len, void *data)
+static int cobd_attach(struct obd_device *dev, obd_count len, void *data)
 {
-       return (lprocfs_reg_obd (dev, status_var_nm_1, dev));
+        struct lprocfs_static_vars lvars;
+
+        lprocfs_init_vars(&lvars);
+       return lprocfs_obd_attach(dev, lvars.obd_vars);
 }
 
-static int
-cobd_detach (struct obd_device *dev)
+static int cobd_detach(struct obd_device *dev)
 {
-       return (lprocfs_dereg_obd (dev));
+       return lprocfs_obd_detach(dev);
 }
 
 static int
@@ -39,18 +37,18 @@ cobd_setup (struct obd_device *dev, obd_count len, void *buf)
         struct obd_device *target;
         struct obd_device *cache;
         int                rc;
-        
+
         if (data->ioc_inlbuf1 == NULL ||
             data->ioc_inlbuf2 == NULL)
                 return (-EINVAL);
-        
+
         target = class_uuid2obd (data->ioc_inlbuf1);
         cache  = class_uuid2obd (data->ioc_inlbuf2);
         if (target == NULL ||
             cache == NULL)
                 return (-EINVAL);
-        
-        /* don't bother checking attached/setup; 
+
+        /* don't bother checking attached/setup;
          * obd_connect() should, and it can change underneath us */
 
         rc = obd_connect (&cobd->cobd_target, target, NULL, NULL, NULL);
@@ -73,14 +71,14 @@ cobd_cleanup (struct obd_device *dev)
 {
         struct cache_obd  *cobd = &dev->u.cobd;
         int                rc;
-        
+
         if (!list_empty (&dev->obd_exports))
                 return (-EBUSY);
-        
+
         rc = obd_disconnect (&cobd->cobd_cache);
         if (rc != 0)
                 CERROR ("error %d disconnecting cache\n", rc);
-        
+
         rc = obd_disconnect (&cobd->cobd_target);
         if (rc != 0)
                 CERROR ("error %d disconnecting target\n", rc);
@@ -103,12 +101,12 @@ static int
 cobd_disconnect (struct lustre_handle *conn)
 {
        int rc = class_disconnect (conn);
-       
+
         CERROR ("rc %d\n", rc);
        return (rc);
 }
 
-static int 
+static int
 cobd_get_info(struct lustre_handle *conn, obd_count keylen,
               void *key, obd_count *vallen, void **val)
 {
@@ -124,11 +122,11 @@ cobd_get_info(struct lustre_handle *conn, obd_count keylen,
 
         /* intercept cache utilisation info? */
 
-        return (obd_get_info (&cobd->cobd_target, 
+        return (obd_get_info (&cobd->cobd_target,
                               keylen, key, vallen, val));
 }
 
-static int 
+static int
 cobd_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
 {
         struct obd_device *obd = class_conn2obd(conn);
@@ -143,7 +141,7 @@ cobd_statfs(struct lustre_handle *conn, struct obd_statfs *osfs)
         return (obd_statfs (&cobd->cobd_target, osfs));
 }
 
-static int 
+static int
 cobd_getattr(struct lustre_handle *conn, struct obdo *oa,
              struct lov_stripe_md *lsm)
 {
@@ -159,7 +157,7 @@ cobd_getattr(struct lustre_handle *conn, struct obdo *oa,
         return (obd_getattr (&cobd->cobd_target, oa, lsm));
 }
 
-static int 
+static int
 cobd_open(struct lustre_handle *conn, struct obdo *oa,
           struct lov_stripe_md *lsm)
 {
@@ -175,7 +173,7 @@ cobd_open(struct lustre_handle *conn, struct obdo *oa,
         return (obd_open (&cobd->cobd_target, oa, lsm));
 }
 
-static int 
+static int
 cobd_close(struct lustre_handle *conn, struct obdo *oa,
            struct lov_stripe_md *lsm)
 {
@@ -191,7 +189,7 @@ cobd_close(struct lustre_handle *conn, struct obdo *oa,
         return (obd_close (&cobd->cobd_target, oa, lsm));
 }
 
-static int 
+static int
 cobd_preprw(int cmd, struct lustre_handle *conn,
             int objcount, struct obd_ioobj *obj,
             int niocount, struct niobuf_remote *nb,
@@ -207,15 +205,15 @@ cobd_preprw(int cmd, struct lustre_handle *conn,
 
         if ((cmd & OBD_BRW_WRITE) != 0)
                 return -EOPNOTSUPP;
-        
+
         cobd = &obd->u.cobd;
-        return (obd_preprw (cmd, &cobd->cobd_target, 
-                            objcount, obj, 
-                            niocount, nb, 
+        return (obd_preprw (cmd, &cobd->cobd_target,
+                            objcount, obj,
+                            niocount, nb,
                             res, desc_private));
 }
 
-static int 
+static int
 cobd_commitrw(int cmd, struct lustre_handle *conn,
               int objcount, struct obd_ioobj *obj,
               int niocount, struct niobuf_local *local,
@@ -231,7 +229,7 @@ cobd_commitrw(int cmd, struct lustre_handle *conn,
 
         if ((cmd & OBD_BRW_WRITE) != 0)
                 return -EOPNOTSUPP;
-        
+
         cobd = &obd->u.cobd;
         return (obd_commitrw (cmd, &cobd->cobd_target,
                               objcount, obj,
@@ -239,7 +237,7 @@ cobd_commitrw(int cmd, struct lustre_handle *conn,
                               desc_private));
 }
 
-static inline int 
+static inline int
 cobd_brw(int cmd, struct lustre_handle *conn,
          struct lov_stripe_md *lsm, obd_count oa_bufs,
          struct brw_page *pga, struct obd_brw_set *set)
@@ -254,13 +252,13 @@ cobd_brw(int cmd, struct lustre_handle *conn,
 
         if ((cmd & OBD_BRW_WRITE) != 0)
                 return -EOPNOTSUPP;
-        
+
         cobd = &obd->u.cobd;
-        return (obd_brw (cmd, &cobd->cobd_target, 
+        return (obd_brw (cmd, &cobd->cobd_target,
                          lsm, oa_bufs, pga, set));
 }
 
-static int 
+static int
 cobd_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len,
                void *karg, void *uarg)
 {
@@ -301,22 +299,21 @@ static struct obd_ops cobd_ops = {
         o_iocontrol:            cobd_iocontrol,
 };
 
-static int __init
-cobd_init (void)
+static int __init cobd_init(void)
 {
-       int   rc;
-       
-       printk (KERN_INFO "Lustre Caching OBD driver\n");
-       
-       rc = class_register_type (&cobd_ops, status_class_var,
-                                 OBD_CACHE_DEVICENAME);
-       return (rc);
+        struct lprocfs_static_vars lvars;
+        ENTRY;
+
+       printk(KERN_INFO "Lustre Caching OBD driver\n");
+
+        lprocfs_init_vars(&lvars);
+        RETURN(class_register_type(&cobd_ops, lvars.module_vars,
+                                   OBD_CACHE_DEVICENAME));
 }
 
-static void __exit
-cobd_exit (void)
+static void __exit cobd_exit(void)
 {
-       class_unregister_type (OBD_CACHE_DEVICENAME);
+       class_unregister_type(OBD_CACHE_DEVICENAME);
 }
 
 MODULE_AUTHOR("Cluster Filesystems Inc. <info@clusterfs.com>");
@@ -325,5 +322,3 @@ MODULE_LICENSE("GPL");
 
 module_init(cobd_init);
 module_exit(cobd_exit);
-
-       
index 5adcaf8..63e0d8b 100644 (file)
  * Common STATUS namespace
  */
 
-static int rd_uuid (char *page, char **start, off_t off, int count,
-                    int *eof, void *data)
-{
-        struct obd_device* dev = (struct obd_device*)data;
-
-        return (snprintf(page, count, "%s\n", dev->obd_uuid));
-}
-
 static int rd_target (char *page, char **start, off_t off, int count,
                       int *eof, void *data)
 {
         struct obd_device    *dev = (struct obd_device*)data;
-        struct cache_obd     *cobd = &dev->u.cobd;
-       struct lustre_handle *conn = &cobd->cobd_target;
+       struct lustre_handle *conn = &dev->u.cobd.cobd_target;
        struct obd_export    *exp;
        int    rc;
 
@@ -49,7 +40,7 @@ static int rd_target (char *page, char **start, off_t off, int count,
                rc = snprintf (page, count, "not set up\n");
        else {
                exp = class_conn2export (conn);
-               LASSERT (exp != NULL);
+               LASSERT(exp != NULL);
                rc = snprintf(page, count, "%s\n", exp->exp_obd->obd_uuid);
        }
        return (rc);
@@ -59,8 +50,7 @@ static int rd_cache(char *page, char **start, off_t off, int count,
                     int *eof, void *data)
 {
         struct obd_device    *dev = (struct obd_device*)data;
-       struct cache_obd     *cobd = &dev->u.cobd;
-       struct lustre_handle *conn = &cobd->cobd_cache;
+       struct lustre_handle *conn = &dev->u.cobd.cobd_cache;
        struct obd_export    *exp;
        int    rc;
 
@@ -74,22 +64,21 @@ static int rd_cache(char *page, char **start, off_t off, int count,
        return (rc);
 }
 
-struct lprocfs_vars status_var_nm_1[] = {
-        {"status/uuid", rd_uuid, 0, 0},
-        {"status/target_uuid", rd_target, 0, 0},
-        {"status/cache_uuid", rd_cache, 0, 0},
-        {0}
+#ifndef LPROCFS
+struct lprocfs_vars lprocfs_obd_vars[] = { {0} };
+struct lprocfs_vars lprocfs_module_vars[] = { {0} };
+#else
+struct lprocfs_vars lprocfs_obd_vars[] = {
+        { "uuid",        lprocfs_rd_uuid,    0, 0 },
+        { "target_uuid", rd_target,          0, 0 },
+        { "cache_uuid",  rd_cache,           0, 0 },
+        { 0 }
 };
 
-int rd_numrefs(char *page, char **start, off_t off, int count,
-               int *eof, void *data)
-{
-        struct obd_type* class = (struct obd_type*)data;
-
-        return (snprintf(page, count, "%d\n", class->typ_refcnt));
-}
-
-struct lprocfs_vars status_class_var[] = {
-        {"status/num_refs", rd_numrefs, 0, 0},
-        {0}
+struct lprocfs_vars lprocfs_module_vars[] = {
+        { "num_refs",    lprocfs_rd_numrefs, 0, 0 },
+        { 0 }
 };
+#endif /* LPROCFS */
+
+LPROCFS_INIT_VARS(lprocfs_module_vars, lprocfs_obd_vars)
index 876d41c..7667ba7 100644 (file)
@@ -27,6 +27,7 @@
 #define EXPORT_SYMTAB
 #include <linux/lustre_net.h>
 #include <linux/obd_support.h>
+#include <linux/obd_class.h>
 
 void obd_statfs_pack(struct obd_statfs *tgt, struct obd_statfs *src)
 {
@@ -69,7 +70,35 @@ void statfs_unpack(struct statfs *sfs, struct obd_statfs *osfs)
         sfs->f_namelen = osfs->os_namelen;
 }
 
+int obd_self_statfs(struct obd_device *obd, struct statfs *sfs)
+{
+        struct lustre_handle conn;
+        struct obd_export *export, *my_export = NULL;
+        struct obd_statfs osfs = { 0 };
+        int rc;
+        ENTRY;
+
+        if (list_empty(&obd->obd_exports)) {
+                export = my_export = class_new_export(obd);
+                if (export == NULL)
+                        RETURN(-ENOMEM);
+        } else
+                export = list_entry(obd->obd_exports.next, typeof(*export),
+                                    exp_obd_chain);
+        conn.addr = (unsigned long)export;
+        conn.cookie = export->exp_cookie;
+
+        rc = obd_statfs(&conn, &osfs);
+        if (!rc)
+                statfs_unpack(sfs, &osfs);
+
+        if (my_export)
+                class_destroy_export(my_export);
+        RETURN(rc);
+}
+
 EXPORT_SYMBOL(obd_statfs_pack);
 EXPORT_SYMBOL(obd_statfs_unpack);
 EXPORT_SYMBOL(statfs_pack);
 EXPORT_SYMBOL(statfs_unpack);
+EXPORT_SYMBOL(obd_self_statfs);
index d57e001..18af8b1 100644 (file)
@@ -104,7 +104,7 @@ static int ptlbd_cl_connect(struct lustre_handle *conn, struct obd_device *obd,
         ENTRY;
 
         rc = class_connect(conn, obd, cluuid);
-        if (rc) 
+        if (rc)
                 RETURN(rc);
 
         INIT_LIST_HEAD(&imp->imp_chain);
@@ -130,9 +130,10 @@ static struct obd_ops ptlbd_cl_obd_ops = {
 
 int ptlbd_cl_init(void)
 {
-        extern struct lprocfs_vars status_class_var[];
+        struct lprocfs_static_vars lvars;
 
-        return class_register_type(&ptlbd_cl_obd_ops, status_class_var,
+        lprocfs_init_vars(&lvars);
+        return class_register_type(&ptlbd_cl_obd_ops, lvars.module_vars,
                                    OBD_PTLBD_CL_DEVICENAME);
 }
 
index 422f0e1..4705bda 100644 (file)
@@ -142,9 +142,10 @@ static struct obd_ops ptlbd_sv_obd_ops = {
 
 int ptlbd_sv_init(void)
 {
-        extern struct lprocfs_vars status_class_var[];
+        struct lprocfs_static_vars lvars;
 
-        return class_register_type(&ptlbd_sv_obd_ops, status_class_var,
+        lprocfs_init_vars(&lvars);
+        return class_register_type(&ptlbd_sv_obd_ops, lvars.module_vars,
                                    OBD_PTLBD_SV_DEVICENAME);
 }