Whamcloud - gitweb
Only create lprocfs entries after a device is set up (instead of at attach
authoradilger <adilger>
Tue, 13 Apr 2004 18:34:28 +0000 (18:34 +0000)
committeradilger <adilger>
Tue, 13 Apr 2004 18:34:28 +0000 (18:34 +0000)
time) so that they don't try to use initialized data.
b=1519

21 files changed:
lustre/ChangeLog
lustre/cobd/cache_obd.c
lustre/include/linux/lprocfs_status.h
lustre/llite/lproc_llite.c
lustre/lov/lov_obd.c
lustre/lov/lproc_lov.c
lustre/mdc/mdc_request.c
lustre/mds/handler.c
lustre/mds/lproc_mds.c
lustre/obdclass/class_obd.c
lustre/obdclass/llog_test.c
lustre/obdclass/lprocfs_status.c
lustre/obdecho/echo.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_io.c
lustre/obdfilter/lproc_obdfilter.c
lustre/osc/lproc_osc.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c
lustre/ptlbd/client.c
lustre/ptlbd/server.c

index 173fb56..8cb70ba 100644 (file)
@@ -13,6 +13,7 @@ tbd  Cluster File Systems, Inc. <info@clusterfs.com>
        - use highest lock extent for kms, not last one (2925)
        - don't dereference ERR_PTR() dentry in error handling path (3107)
        - fix thread race in portals_debug_dumplog() (3122)
+       - create lprocfs device entries at setup instead of at attach (1519)
        * miscellania
        - allow default OST striping configuration per directory (1414)
 
index e725ecf..9bcd1c2 100644 (file)
 #include <linux/obd_class.h>
 #include <linux/obd_cache.h>
 
-static int cobd_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-
-        lprocfs_init_vars(cobd, &lvars);
-        return lprocfs_obd_attach(dev, lvars.obd_vars);
-}
-
-static int cobd_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
-}
-
-static int
-cobd_setup (struct obd_device *dev, obd_count len, void *buf)
+static int cobd_setup (struct obd_device *obd, obd_count len, void *buf)
 {
         struct lustre_cfg *lcfg = (struct lustre_cfg *)buf;
-        struct cache_obd  *cobd = &dev->u.cobd;
+        struct cache_obd  *cobd = &obd->u.cobd;
         struct obd_device *target;
         struct obd_device *cache;
         struct obd_uuid target_uuid;
         struct obd_uuid cache_uuid;
         struct lustre_handle target_conn = {0,}, cache_conn = {0,};
+        struct lprocfs_static_vars lvars;
         int                rc;
 
-        if (lcfg->lcfg_inlbuf1 == NULL ||
-            lcfg->lcfg_inlbuf2 == NULL)
+        if (lcfg->lcfg_inlbuf1 == NULL || lcfg->lcfg_inlbuf2 == NULL)
                 return (-EINVAL);
 
         obd_str2uuid(&target_uuid, lcfg->lcfg_inlbuf1);
@@ -82,24 +68,29 @@ cobd_setup (struct obd_device *dev, obd_count len, void *buf)
         }
         cobd->cobd_cache_exp = class_conn2export(&cache_conn);
 
-        return rc;
+        lprocfs_init_vars(cobd, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
+
+        return 0;
 }
 
-static int cobd_cleanup(struct obd_device *dev, int flags)
+static int cobd_cleanup(struct obd_device *obd, int flags)
 {
-        struct cache_obd  *cobd = &dev->u.cobd;
+        struct cache_obd  *cobd = &obd->u.cobd;
         int                rc;
 
-        if (!list_empty(&dev->obd_exports))
+        if (!list_empty(&obd->obd_exports))
                 return (-EBUSY);
 
+        lprocfs_obd_cleanup(obd);
+
         rc = obd_disconnect(cobd->cobd_cache_exp, flags);
         if (rc != 0)
-                CERROR ("error %d disconnecting cache\n", rc);
+                CERROR("error %d disconnecting cache\n", rc);
 
         rc = obd_disconnect(cobd->cobd_target_exp, flags);
         if (rc != 0)
-                CERROR ("error %d disconnecting target\n", rc);
+                CERROR("error %d disconnecting target\n", rc);
 
         return (0);
 }
@@ -244,8 +235,6 @@ static int cobd_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
 static struct obd_ops cobd_ops = {
         o_owner:                THIS_MODULE,
-        o_attach:               cobd_attach,
-        o_detach:               cobd_detach,
 
         o_setup:                cobd_setup,
         o_cleanup:              cobd_cleanup,
index 3a7ac42..b79b574 100644 (file)
@@ -182,17 +182,6 @@ extern void lprocfs_free_obd_stats(struct obd_device *obddev);
 extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
                                   struct lprocfs_stats *stats);
 
-#define LPROCFS_INIT_MULTI_VARS(array, size)                              \
-void lprocfs_init_multi_vars(unsigned int idx,                            \
-                             struct lprocfs_static_vars *x)               \
-{                                                                         \
-   struct lprocfs_static_vars *glob = (struct lprocfs_static_vars*)array; \
-   LASSERT(glob != 0);                                                    \
-   LASSERT(idx < (unsigned int)(size));                                   \
-   x->module_vars = glob[idx].module_vars;                                \
-   x->obd_vars = glob[idx].obd_vars;                                      \
-}                                                                         \
-
 #define LPROCFS_INIT_VARS(name, vclass, vinstance)           \
 void lprocfs_##name##_init_vars(struct lprocfs_static_vars *x)  \
 {                                                      \
@@ -205,8 +194,6 @@ do {      \
         extern void lprocfs_##NAME##_init_vars(struct lprocfs_static_vars *);  \
         lprocfs_##NAME##_init_vars(VAR);                                       \
 } while (0)
-extern void lprocfs_init_multi_vars(unsigned int idx,
-                                    struct lprocfs_static_vars *var);
 /* lprocfs_status.c */
 extern int lprocfs_add_vars(struct proc_dir_entry *root,
                             struct lprocfs_vars *var,
@@ -222,8 +209,8 @@ extern void lprocfs_remove(struct proc_dir_entry *root);
 extern struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *root,
                                            const char *name);
 
-extern int lprocfs_obd_attach(struct obd_device *dev, struct lprocfs_vars *list);
-extern int lprocfs_obd_detach(struct obd_device *dev);
+extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
+extern int lprocfs_obd_cleanup(struct obd_device *obd);
 
 /* Generic callbacks */
 
@@ -239,6 +226,8 @@ extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
                                   int count, int *eof, void *data);
 extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
                                 int count, int *eof, void *data);
+extern int lprocfs_rd_num_exports(char *page, char **start, off_t off,
+                                  int count, int *eof, void *data);
 extern int lprocfs_rd_numrefs(char *page, char **start, off_t off,
                               int count, int *eof, void *data);
 
@@ -304,9 +293,6 @@ static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
 static inline struct proc_dir_entry *
 lprocfs_register(const char *name, struct proc_dir_entry *parent,
                  struct lprocfs_vars *list, void *data) { return NULL; }
-#define LPROCFS_INIT_MULTI_VARS(array, size) do {} while (0)
-static inline void lprocfs_init_multi_vars(unsigned int idx,
-                                           struct lprocfs_static_vars *x) { return; }
 #define LPROCFS_INIT_VARS(name, vclass, vinstance) do {} while (0)
 #define lprocfs_init_vars(...) do {} while (0)
 static inline int lprocfs_add_vars(struct proc_dir_entry *root,
@@ -315,9 +301,9 @@ static inline int lprocfs_add_vars(struct proc_dir_entry *root,
 static inline void lprocfs_remove(struct proc_dir_entry *root) {};
 static inline struct proc_dir_entry *lprocfs_srch(struct proc_dir_entry *head,
                                     const char *name) {return 0;}
-static inline int lprocfs_obd_attach(struct obd_device *dev,
-                                     struct lprocfs_vars *list) { return 0; }
-static inline int lprocfs_obd_detach(struct obd_device *dev)  { return 0; }
+static inline int lprocfs_obd_setup(struct obd_device *dev,
+                                    struct lprocfs_vars *list) { return 0; }
+static inline int lprocfs_obd_cleanup(struct obd_device *dev)  { return 0; }
 static inline int lprocfs_rd_u64(char *page, char **start, off_t off,
                                  int count, int *eof, void *data) { return 0; }
 static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
@@ -325,9 +311,14 @@ static inline int lprocfs_rd_uuid(char *page, char **start, off_t off,
 static inline int lprocfs_rd_name(char *page, char **start, off_t off,
                                   int count, int *eof, void *data) { return 0; }
 static inline int lprocfs_rd_server_uuid(char *page, char **start, off_t off,
-                                         int count, int *eof, void *data) { return 0; }
+                                         int count, int *eof, void *data)
+{ return 0; }
 static inline int lprocfs_rd_conn_uuid(char *page, char **start, off_t off,
-                                       int count, int *eof, void *data) { return 0; }
+                                       int count, int *eof, void *data)
+{ return 0; }
+static inline int lprocfs_rd_num_exports(char *page, char **start, off_t off,
+                                         int count, int *eof, void *data)
+{ return 0; }
 static inline int lprocfs_rd_numrefs(char *page, char **start, off_t off,
                                      int count, int *eof, void *data) { return 0; }
 
index 162f568..9f1987c 100644 (file)
@@ -602,6 +602,7 @@ static int llite_dump_pgcache_seq_release(struct inode *inode,
 }
 
 struct file_operations llite_dump_pgcache_fops = {
+        .owner   = THIS_MODULE,
         .open    = llite_dump_pgcache_seq_open,
         .read    = seq_read,
         .release = llite_dump_pgcache_seq_release,
index 41c0207..cd1ca69 100644 (file)
@@ -114,35 +114,6 @@ static void lov_llh_destroy(struct lov_lock_handles *llh)
 }
 
 /* obd methods */
-int lov_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-        int rc;
-
-        lprocfs_init_vars(lov, &lvars);
-        rc = lprocfs_obd_attach(dev, lvars.obd_vars);
-        if (rc == 0) {
-#ifdef __KERNEL__
-                struct proc_dir_entry *entry;
-
-                entry = create_proc_entry("target_obd", 0444, 
-                                          dev->obd_proc_entry);
-                if (entry == NULL) {
-                        rc = -ENOMEM;
-                } else {
-                        entry->proc_fops = &lov_proc_target_fops;
-                        entry->data = dev;
-                }
-#endif
-        }
-        return rc;
-}
-
-int lov_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
-}
-
 static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
                        struct obd_uuid *cluuid)
 {
@@ -390,6 +361,7 @@ static int lov_notify(struct obd_device *obd, struct obd_device *watched,
 
 static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
 {
+        struct lprocfs_static_vars lvars;
         struct lustre_cfg *lcfg = buf;
         struct lov_desc *desc;
         struct lov_obd *lov = &obd->u.lov;
@@ -397,7 +369,6 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
         struct lov_tgt_desc *tgts;
         int i;
         int count;
-        int rc = 0;
         ENTRY;
 
         if (lcfg->lcfg_inllen1 < 1) {
@@ -456,15 +427,31 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
                 *uuid = uuids[i];
         }
 
+        lprocfs_init_vars(lov, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
+#ifdef __KERNEL__
+        {
+                struct proc_dir_entry *entry;
+
+                entry = create_proc_entry("target_obd", 0444,
+                                          obd->obd_proc_entry);
+                if (entry != NULL) {
+                        entry->proc_fops = &lov_proc_target_fops;
+                        entry->data = obd;
+                }
+        }
+#endif
 
-        RETURN(rc);
+        RETURN(0);
 }
 
-static int lov_cleanup(struct obd_device *obd, int flags) 
+static int lov_cleanup(struct obd_device *obd, int flags)
 {
         struct lov_obd *lov = &obd->u.lov;
 
+        lprocfs_obd_cleanup(obd);
         OBD_FREE(lov->tgts, lov->bufsize);
+
         RETURN(0);
 }
 
@@ -2837,8 +2824,6 @@ EXPORT_SYMBOL(lov_increase_kms);
 
 struct obd_ops lov_obd_ops = {
         o_owner:       THIS_MODULE,
-        o_attach:      lov_attach,
-        o_detach:      lov_detach,
         o_setup:       lov_setup,
         o_cleanup:     lov_cleanup,
         o_connect:     lov_connect,
index c29644c..ee4883d 100644 (file)
@@ -198,9 +198,10 @@ static struct lprocfs_vars lprocfs_module_vars[] = {
 };
 
 struct file_operations lov_proc_target_fops = {
-        .open = lov_target_seq_open,
-        .read = seq_read,
-        .llseek = seq_lseek,
+        .owner   = THIS_MODULE,
+        .open    = lov_target_seq_open,
+        .read    = seq_read,
+        .llseek  = seq_lseek,
         .release = seq_release,
 };
 
index 136ecdf..f7726b8 100644 (file)
@@ -820,19 +820,6 @@ int mdc_sync(struct obd_export *exp, struct ll_fid *fid,
         RETURN(rc);
 }
 
-static int mdc_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-
-        lprocfs_init_vars(mdc, &lvars);
-        return lprocfs_obd_attach(dev, lvars.obd_vars);
-}
-
-static int mdc_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
-}
-
 static int mdc_import_event(struct obd_device *obd,
                             struct obd_import *imp, 
                             enum obd_import_event event)
@@ -847,7 +834,7 @@ static int mdc_import_event(struct obd_device *obd,
         }
         case IMP_EVENT_INVALIDATE: {
                 struct ldlm_namespace *ns = obd->obd_namespace;
-                
+
                 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
 
                 if (obd->obd_observer)
@@ -869,6 +856,7 @@ static int mdc_import_event(struct obd_device *obd,
 static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
 {
         struct client_obd *cli = &obd->u.cli;
+        struct lprocfs_static_vars lvars;
         int rc;
         ENTRY;
 
@@ -881,15 +869,14 @@ static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
 
         OBD_ALLOC(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
         if (!cli->cl_setattr_lock)
-                GOTO(out_free_rpc, rc = -ENOMEM);
+                GOTO(err_rpc_lock, rc = -ENOMEM);
         mdc_init_rpc_lock(cli->cl_setattr_lock);
 
         rc = client_obd_setup(obd, len, buf);
-        if (rc) {
-                OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
- out_free_rpc:
-                OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
-        }
+        if (rc)
+                GOTO(err_setattr_lock, rc);
+        lprocfs_init_vars(mdc, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
 
         rc = obd_llog_init(obd, obd, 0, NULL);
         if (rc) {
@@ -898,6 +885,13 @@ static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
         }
 
         RETURN(rc);
+
+err_setattr_lock:
+        OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
+err_rpc_lock:
+        OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
+        ptlrpcd_decref();
+        RETURN(rc);
 }
 
 int mdc_init_ea_size(struct obd_device *obd, char *lov_name)
@@ -938,7 +932,7 @@ int mdc_init_ea_size(struct obd_device *obd, char *lov_name)
 static int mdc_precleanup(struct obd_device *obd, int flags)
 {
         int rc = 0;
-        
+
         rc = obd_llog_finish(obd, 0);
         if (rc != 0)
                 CERROR("failed to cleanup llogging subsystems\n");
@@ -949,10 +943,11 @@ static int mdc_precleanup(struct obd_device *obd, int flags)
 static int mdc_cleanup(struct obd_device *obd, int flags)
 {
         struct client_obd *cli = &obd->u.cli;
+
         OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
         OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
 
+        lprocfs_obd_cleanup(obd);
         ptlrpcd_decref();
 
         return client_obd_cleanup(obd, flags);
@@ -987,8 +982,6 @@ static int mdc_llog_finish(struct obd_device *obd, int count)
 
 struct obd_ops mdc_obd_ops = {
         o_owner:       THIS_MODULE,
-        o_attach:      mdc_attach,
-        o_detach:      mdc_detach,
         o_setup:       mdc_setup,
         o_precleanup:  mdc_precleanup,
         o_cleanup:     mdc_cleanup,
index 3f2aff3..78b0da2 100644 (file)
@@ -1361,6 +1361,7 @@ int mds_update_server_data(struct obd_device *obd, int force_sync)
 /* mount the file system (secretly) */
 static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
 {
+        struct lprocfs_static_vars lvars;
         struct lustre_cfg* lcfg = buf;
         struct mds_obd *mds = &obd->u.mds;
         struct vfsmount *mnt;
@@ -1418,7 +1419,6 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         rc = llog_start_commit_thread();
         if (rc < 0)
                 GOTO(err_fs, rc);
-        
 
         if (lcfg->lcfg_inllen3 > 0 && lcfg->lcfg_inlbuf3) {
                 class_uuid_t uuid;
@@ -1427,13 +1427,13 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
                 class_uuid_unparse(uuid, &mds->mds_lov_uuid);
 
                 OBD_ALLOC(mds->mds_profile, lcfg->lcfg_inllen3);
-                if (mds->mds_profile == NULL) 
+                if (mds->mds_profile == NULL)
                         GOTO(err_fs, rc = -ENOMEM);
 
                 memcpy(mds->mds_profile, lcfg->lcfg_inlbuf3,
                        lcfg->lcfg_inllen3);
 
-        } 
+        }
 
         ptlrpc_init_client(LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
                            "mds_ldlm_client", &obd->obd_ldlm_client);
@@ -1442,6 +1442,10 @@ static int mds_setup(struct obd_device *obd, obd_count len, void *buf)
         rc = mds_postsetup(obd);
         if (rc)
                 GOTO(err_fs, rc);
+
+        lprocfs_init_vars(mds, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
+
         RETURN(0);
 
 err_fs:
@@ -1575,6 +1579,8 @@ static int mds_cleanup(struct obd_device *obd, int flags)
         if (mds->mds_sb == NULL)
                 RETURN(0);
 
+        lprocfs_obd_cleanup(obd);
+
         mds_update_server_data(obd, 1);
         if (mds->mds_lov_objids != NULL) {
                 OBD_FREE(mds->mds_lov_objids,
@@ -1645,7 +1651,7 @@ static void fixup_handle_for_resent_req(struct ptlrpc_request *req,
          * be handled like any normal request now. */
 
         lustre_msg_clear_flags(req->rq_reqmsg, MSG_RESENT);
-        
+
         DEBUG_REQ(D_HA, req, "no existing lock with rhandle "LPX64,
                   remote_hdl.cookie);
 }
@@ -1806,50 +1812,25 @@ static int mds_intent_policy(struct ldlm_namespace *ns,
         RETURN(ELDLM_LOCK_REPLACED);
 }
 
-int mds_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-
-        lprocfs_init_multi_vars(0, &lvars);
-        return lprocfs_obd_attach(dev, lvars.obd_vars);
-}
-
-int mds_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
-}
-
-int mdt_attach(struct obd_device *dev, obd_count len, void *data)
+static int mdt_setup(struct obd_device *obd, obd_count len, void *buf)
 {
+        struct mds_obd *mds = &obd->u.mds;
         struct lprocfs_static_vars lvars;
-
-        lprocfs_init_multi_vars(1, &lvars);
-        return lprocfs_obd_attach(dev, lvars.obd_vars);
-}
-
-int mdt_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
-}
-
-static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
-{
-        struct mds_obd *mds = &obddev->u.mds;
         int rc = 0;
         ENTRY;
 
-        mds->mds_service = 
+        mds->mds_service =
                 ptlrpc_init_svc(MDS_NBUFS, MDS_BUFSIZE, MDS_MAXREQSIZE,
                                 MDS_REQUEST_PORTAL, MDC_REPLY_PORTAL,
                                 mds_handle, "mds",
-                                obddev->obd_proc_entry);
+                                obd->obd_proc_entry);
 
         if (!mds->mds_service) {
                 CERROR("failed to start service\n");
                 RETURN(rc = -ENOMEM);
         }
 
-        rc = ptlrpc_start_n_threads(obddev, mds->mds_service, MDT_NUM_THREADS,
+        rc = ptlrpc_start_n_threads(obd, mds->mds_service, MDT_NUM_THREADS,
                                     "ll_mdt");
         if (rc)
                 GOTO(err_thread, rc);
@@ -1857,34 +1838,37 @@ static int mdt_setup(struct obd_device *obddev, obd_count len, void *buf)
         mds->mds_setattr_service =
                 ptlrpc_init_svc(MDS_NBUFS, MDS_BUFSIZE, MDS_MAXREQSIZE,
                                 MDS_SETATTR_PORTAL, MDC_REPLY_PORTAL,
-                                mds_handle, "mds_setattr", 
-                                obddev->obd_proc_entry);
+                                mds_handle, "mds_setattr",
+                                obd->obd_proc_entry);
         if (!mds->mds_setattr_service) {
                 CERROR("failed to start getattr service\n");
                 GOTO(err_thread, rc = -ENOMEM);
         }
 
-        rc = ptlrpc_start_n_threads(obddev, mds->mds_setattr_service,
+        rc = ptlrpc_start_n_threads(obd, mds->mds_setattr_service,
                                  MDT_NUM_THREADS, "ll_mdt_attr");
         if (rc)
                 GOTO(err_thread2, rc);
-                        
+
         mds->mds_readpage_service =
                 ptlrpc_init_svc(MDS_NBUFS, MDS_BUFSIZE, MDS_MAXREQSIZE,
                                 MDS_READPAGE_PORTAL, MDC_REPLY_PORTAL,
-                                mds_handle, "mds_readpage", 
-                                obddev->obd_proc_entry);
+                                mds_handle, "mds_readpage",
+                                obd->obd_proc_entry);
         if (!mds->mds_readpage_service) {
                 CERROR("failed to start readpage service\n");
                 GOTO(err_thread2, rc = -ENOMEM);
         }
 
-        rc = ptlrpc_start_n_threads(obddev, mds->mds_readpage_service,
+        rc = ptlrpc_start_n_threads(obd, mds->mds_readpage_service,
                                     MDT_NUM_THREADS, "ll_mdt_rdpg");
 
-        if (rc) 
+        if (rc)
                 GOTO(err_thread3, rc);
 
+        lprocfs_init_vars(mdt, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
+
         RETURN(0);
 
 err_thread3:
@@ -1897,11 +1881,13 @@ err_thread:
 }
 
 
-static int mdt_cleanup(struct obd_device *obddev, int flags)
+static int mdt_cleanup(struct obd_device *obd, int flags)
 {
-        struct mds_obd *mds = &obddev->u.mds;
+        struct mds_obd *mds = &obd->u.mds;
         ENTRY;
 
+        lprocfs_obd_cleanup(obd);
+
         ptlrpc_stop_all_threads(mds->mds_readpage_service);
         ptlrpc_unregister_service(mds->mds_readpage_service);
 
@@ -1914,7 +1900,8 @@ static int mdt_cleanup(struct obd_device *obddev, int flags)
         RETURN(0);
 }
 
-static struct dentry *mds_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr, void *data)
+static struct dentry *mds_lvfs_fid2dentry(__u64 id, __u32 gen, __u64 gr,
+                                          void *data)
 {
         struct obd_device *obd = data;
         struct ll_fid fid;
@@ -1930,8 +1917,6 @@ struct lvfs_callback_ops mds_lvfs_ops = {
 /* use obd ops to offer management infrastructure */
 static struct obd_ops mds_obd_ops = {
         o_owner:       THIS_MODULE,
-        o_attach:      mds_attach,
-        o_detach:      mds_detach,
         o_connect:     mds_connect,
         o_init_export:  mds_init_export,
         o_destroy_export:  mds_destroy_export,
@@ -1951,8 +1936,6 @@ static struct obd_ops mds_obd_ops = {
 
 static struct obd_ops mdt_obd_ops = {
         o_owner:       THIS_MODULE,
-        o_attach:      mdt_attach,
-        o_detach:      mdt_detach,
         o_setup:       mdt_setup,
         o_cleanup:     mdt_cleanup,
 };
@@ -1961,9 +1944,9 @@ static int __init mds_init(void)
 {
         struct lprocfs_static_vars lvars;
 
-        lprocfs_init_multi_vars(0, &lvars);
+        lprocfs_init_vars(mds, &lvars);
         class_register_type(&mds_obd_ops, lvars.module_vars, LUSTRE_MDS_NAME);
-        lprocfs_init_multi_vars(1, &lvars);
+        lprocfs_init_vars(mdt, &lvars);
         class_register_type(&mdt_obd_ops, lvars.module_vars, LUSTRE_MDT_NAME);
 
         return 0;
index 10365a6..52225be 100644 (file)
@@ -163,10 +163,10 @@ struct lprocfs_vars lprocfs_mds_obd_vars[] = {
         { "filestotal",   lprocfs_rd_filestotal,  0, 0 },
         { "filesfree",    lprocfs_rd_filesfree,   0, 0 },
         { "filesopen",    lprocfs_mds_rd_filesopen,   0, 0 },
-        //{ "filegroups",   lprocfs_rd_filegroups,  0, 0 },
         { "mntdev",       lprocfs_mds_rd_mntdev,  0, 0 },
         { "recovery_status", lprocfs_mds_rd_recovery_status, 0, 0 },
         { "evict_client", 0, lprocfs_mds_wr_evict_client, 0 },
+        { "num_exports",  lprocfs_rd_num_exports, 0, 0 },
         { 0 }
 };
 
@@ -186,11 +186,5 @@ struct lprocfs_vars lprocfs_mdt_module_vars[] = {
 };
 
 #endif
-struct lprocfs_static_vars lprocfs_array_vars[] = { {lprocfs_mds_module_vars,
-                                                     lprocfs_mds_obd_vars},
-                                                    {lprocfs_mdt_module_vars,
-                                                     lprocfs_mdt_obd_vars}};
-
-LPROCFS_INIT_MULTI_VARS(lprocfs_array_vars,
-                        (sizeof(lprocfs_array_vars) /
-                         sizeof(struct lprocfs_static_vars)))
+LPROCFS_INIT_VARS(mds, lprocfs_mds_module_vars, lprocfs_mds_obd_vars);
+LPROCFS_INIT_VARS(mdt, lprocfs_mdt_module_vars, lprocfs_mdt_obd_vars);
index 83a6563..119c782 100644 (file)
@@ -359,16 +359,17 @@ static int obd_class_ioctl(struct inode *inode, struct file *filp,
 
 /* declare character device */
 static struct file_operations obd_psdev_fops = {
-        ioctl:   obd_class_ioctl,       /* ioctl */
-        open:    obd_class_open,        /* open */
-        release: obd_class_release,     /* release */
+        .owner   = THIS_MODULE,
+        .ioctl   = obd_class_ioctl,     /* ioctl */
+        .open    = obd_class_open,      /* open */
+        .release = obd_class_release,   /* release */
 };
 
 /* modules setup */
 static struct miscdevice obd_psdev = {
-        OBD_MINOR,
-        "obd_psdev",
-        &obd_psdev_fops
+        .minor = OBD_MINOR,
+        .name  = "obd_psdev",
+        .fops  = &obd_psdev_fops,
 };
 #else
 void *obd_psdev = NULL;
@@ -530,9 +531,10 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
 }
 
 struct file_operations obd_device_list_fops = {
-        .open = obd_device_list_open,
-        .read = seq_read,
-        .llseek = seq_lseek,
+        .owner   = THIS_MODULE,
+        .open    = obd_device_list_open,
+        .read    = seq_read,
+        .llseek  = seq_lseek,
         .release = seq_release,
 };
 #endif
index e3edd02..a45e57d 100644 (file)
@@ -610,11 +610,14 @@ static int llog_test_cleanup(struct obd_device *obd, int flags)
         if (rc)
                 CERROR("failed to llog_test_llog_finish: %d\n", rc);
 
+        lprocfs_obd_cleanup(obd);
+
         return rc;
 }
 
 static int llog_test_setup(struct obd_device *obd, obd_count len, void *buf)
 {
+        struct lprocfs_static_vars lvars;
         struct lustre_cfg *lcfg = buf;
         struct obd_device *tgt;
         int rc;
@@ -641,30 +644,15 @@ static int llog_test_setup(struct obd_device *obd, obd_count len, void *buf)
         rc = llog_run_tests(obd);
         if (rc)
                 llog_test_cleanup(obd, 0);
-        RETURN(rc);
-}
-
-static struct lprocfs_vars lprocfs_ost_obd_vars[] = { {0} };
-static struct lprocfs_vars lprocfs_ost_module_vars[] = { {0} };
-LPROCFS_INIT_VARS(ost, lprocfs_ost_module_vars, lprocfs_ost_obd_vars)
-
-static int llog_test_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
 
-        lprocfs_init_vars(ost, &lvars);
-        return lprocfs_obd_attach(dev, lvars.obd_vars);
-}
+        lprocfs_init_vars(llog_test, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
 
-static int llog_test_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
+        RETURN(rc);
 }
 
 static struct obd_ops llog_obd_ops = {
         o_owner:       THIS_MODULE,
-        o_attach:      llog_test_attach,
-        o_detach:      llog_test_detach,
         o_setup:       llog_test_setup,
         o_cleanup:     llog_test_cleanup,
         o_llog_init:   llog_test_llog_init,
index a90a6e1..fcfb991 100644 (file)
@@ -315,20 +315,13 @@ int lprocfs_rd_filesfree(char *page, char **start, off_t off, int count,
         return rc;
 }
 
-int lprocfs_rd_filegroups(char *page, char **start, off_t off, int count,
-                          int *eof, void *data)
-{
-        *eof = 1;
-        return snprintf(page, count, "unimplemented\n");
-}
-
 int lprocfs_rd_server_uuid(char *page, char **start, off_t off, int count,
                            int *eof, void *data)
 {
         struct obd_device *obd = (struct obd_device *)data;
         struct obd_import *imp;
         char *imp_state_name = NULL;
-        
+
         LASSERT(obd != NULL);
         imp = obd->u.cli.cl_import;
         imp_state_name = ptlrpc_import_state_name(imp->imp_state);
@@ -350,6 +343,16 @@ int lprocfs_rd_conn_uuid(char *page, char **start, off_t off, int count,
         return snprintf(page, count, "%s\n", conn->c_remote_uuid.uuid);
 }
 
+int lprocfs_rd_num_exports(char *page, char **start, off_t off, int count,
+                           int *eof,  void *data)
+{
+        struct obd_device *obd = (struct obd_device*)data;
+
+        LASSERT(obd != NULL);
+        *eof = 1;
+        return snprintf(page, count, "%u\n", obd->obd_num_exports);
+}
+
 int lprocfs_rd_numrefs(char *page, char **start, off_t off, int count,
                        int *eof, void *data)
 {
@@ -360,29 +363,30 @@ int lprocfs_rd_numrefs(char *page, char **start, off_t off, int count,
         return snprintf(page, count, "%d\n", class->typ_refcnt);
 }
 
-int lprocfs_obd_attach(struct obd_device *dev, struct lprocfs_vars *list)
+int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list)
 {
         int rc = 0;
 
-        LASSERT(dev != NULL);
-        LASSERT(dev->obd_type != NULL);
-        LASSERT(dev->obd_type->typ_procroot != NULL);
-
-        dev->obd_proc_entry = lprocfs_register(dev->obd_name,
-                                               dev->obd_type->typ_procroot,
-                                               list, dev);
-        if (IS_ERR(dev->obd_proc_entry)) {
-                rc = PTR_ERR(dev->obd_proc_entry);
-                dev->obd_proc_entry = NULL;
+        LASSERT(obd != NULL);
+        LASSERT(obd->obd_type != NULL);
+        LASSERT(obd->obd_type->typ_procroot != NULL);
+
+        obd->obd_proc_entry = lprocfs_register(obd->obd_name,
+                                               obd->obd_type->typ_procroot,
+                                               list, obd);
+        if (IS_ERR(obd->obd_proc_entry)) {
+                rc = PTR_ERR(obd->obd_proc_entry);
+                CERROR("error %d setting up lprocfs for %s\n",rc,obd->obd_name);
+                obd->obd_proc_entry = NULL;
         }
         return rc;
 }
 
-int lprocfs_obd_detach(struct obd_device *dev)
+int lprocfs_obd_cleanup(struct obd_device *obd)
 {
-        if (dev && dev->obd_proc_entry) {
-                lprocfs_remove(dev->obd_proc_entry);
-                dev->obd_proc_entry = NULL;
+        if (obd && obd->obd_proc_entry) {
+                lprocfs_remove(obd->obd_proc_entry);
+                obd->obd_proc_entry = NULL;
         }
         return 0;
 }
@@ -538,6 +542,7 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
 }
 
 struct file_operations lprocfs_stats_seq_fops = {
+        owner:   THIS_MODULE,
         open:    lprocfs_stats_seq_open,
         read:    seq_read,
         llseek:  seq_lseek,
@@ -788,8 +793,8 @@ EXPORT_SYMBOL(lprocfs_register);
 EXPORT_SYMBOL(lprocfs_srch);
 EXPORT_SYMBOL(lprocfs_remove);
 EXPORT_SYMBOL(lprocfs_add_vars);
-EXPORT_SYMBOL(lprocfs_obd_attach);
-EXPORT_SYMBOL(lprocfs_obd_detach);
+EXPORT_SYMBOL(lprocfs_obd_setup);
+EXPORT_SYMBOL(lprocfs_obd_cleanup);
 EXPORT_SYMBOL(lprocfs_alloc_stats);
 EXPORT_SYMBOL(lprocfs_free_stats);
 EXPORT_SYMBOL(lprocfs_register_stats);
@@ -802,6 +807,7 @@ EXPORT_SYMBOL(lprocfs_rd_name);
 EXPORT_SYMBOL(lprocfs_rd_fstype);
 EXPORT_SYMBOL(lprocfs_rd_server_uuid);
 EXPORT_SYMBOL(lprocfs_rd_conn_uuid);
+EXPORT_SYMBOL(lprocfs_rd_num_exports);
 EXPORT_SYMBOL(lprocfs_rd_numrefs);
 
 EXPORT_SYMBOL(lprocfs_rd_blksize);
@@ -810,7 +816,6 @@ EXPORT_SYMBOL(lprocfs_rd_kbytesfree);
 EXPORT_SYMBOL(lprocfs_rd_kbytesavail);
 EXPORT_SYMBOL(lprocfs_rd_filestotal);
 EXPORT_SYMBOL(lprocfs_rd_filesfree);
-EXPORT_SYMBOL(lprocfs_rd_filegroups);
 
 EXPORT_SYMBOL(lprocfs_write_helper);
 EXPORT_SYMBOL(lprocfs_write_u64_helper);
index 9248472..34d061d 100644 (file)
@@ -442,69 +442,56 @@ commitrw_cleanup:
         return rc;
 }
 
-static int echo_setup(struct obd_device *obddev, obd_count len, void *buf)
+static int echo_setup(struct obd_device *obd, obd_count len, void *buf)
 {
+        struct lprocfs_static_vars lvars;
         ENTRY;
 
-        spin_lock_init(&obddev->u.echo.eo_lock);
-        obddev->u.echo.eo_lastino = ECHO_INIT_OBJID;
+        spin_lock_init(&obd->u.echo.eo_lock);
+        obd->u.echo.eo_lastino = ECHO_INIT_OBJID;
 
-        obddev->obd_namespace =
-                ldlm_namespace_new("echo-tgt", LDLM_NAMESPACE_SERVER);
-        if (obddev->obd_namespace == NULL) {
+        obd->obd_namespace = ldlm_namespace_new("echo-tgt",
+                                                LDLM_NAMESPACE_SERVER);
+        if (obd->obd_namespace == NULL) {
                 LBUG();
                 RETURN(-ENOMEM);
         }
 
+        lprocfs_init_vars(echo, &lvars);
+        if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0 &&
+            lprocfs_alloc_obd_stats(obd, LPROC_ECHO_LAST) == 0) {
+                lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_READ_BYTES,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "read_bytes", "bytes");
+                lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_WRITE_BYTES,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "write_bytes", "bytes");
+        }
+
         ptlrpc_init_client (LDLM_CB_REQUEST_PORTAL, LDLM_CB_REPLY_PORTAL,
-                            "echo_ldlm_cb_client", &obddev->obd_ldlm_client);
+                            "echo_ldlm_cb_client", &obd->obd_ldlm_client);
         RETURN(0);
 }
 
-static int echo_cleanup(struct obd_device *obddev, int flags)
+static int echo_cleanup(struct obd_device *obd, int flags)
 {
-        int     leaked;
+        int leaked;
         ENTRY;
 
-        ldlm_namespace_free(obddev->obd_namespace, flags & OBD_OPT_FORCE);
+        lprocfs_free_obd_stats(obd);
+        lprocfs_obd_cleanup(obd);
+
+        ldlm_namespace_free(obd->obd_namespace, flags & OBD_OPT_FORCE);
 
-        leaked = atomic_read(&obddev->u.echo.eo_prep);
+        leaked = atomic_read(&obd->u.echo.eo_prep);
         if (leaked != 0)
                 CERROR("%d prep/commitrw pages leaked\n", leaked);
 
         RETURN(0);
 }
 
-int echo_attach(struct obd_device *obd, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-        int rc;
-
-        lprocfs_init_vars(echo, &lvars);
-        rc = lprocfs_obd_attach(obd, lvars.obd_vars);
-        if (rc != 0)
-                return rc;
-        rc = lprocfs_alloc_obd_stats(obd, LPROC_ECHO_LAST);
-        if (rc != 0)
-                return rc;
-
-        lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_READ_BYTES,
-                             LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
-        lprocfs_counter_init(obd->obd_stats, LPROC_ECHO_WRITE_BYTES,
-                             LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
-        return rc;
-}
-
-int echo_detach(struct obd_device *dev)
-{
-        lprocfs_free_obd_stats(dev);
-        return lprocfs_obd_detach(dev);
-}
-
 static struct obd_ops echo_obd_ops = {
         o_owner:           THIS_MODULE,
-        o_attach:          echo_attach,
-        o_detach:          echo_detach,
         o_connect:         echo_connect,
         o_disconnect:      echo_disconnect,
         o_destroy_export:  echo_destroy_export,
index 34bc865..4d60890 100644 (file)
@@ -532,7 +532,7 @@ static int filter_cleanup_groups(struct obd_device *obd)
                                 f_dput(dentry);
                 }
                 OBD_FREE(filter->fo_dentry_O_groups,
-                         FILTER_GROUPS * sizeof(struct dentry *));
+                         FILTER_GROUPS * sizeof(*filter->fo_dentry_O_groups));
                 filter->fo_dentry_O_groups = NULL;
         }
         if (filter->fo_last_objid_files != NULL) {
@@ -542,10 +542,10 @@ static int filter_cleanup_groups(struct obd_device *obd)
                                 filp_close(filp, 0);
                 }
                 OBD_FREE(filter->fo_last_objid_files,
-                         FILTER_GROUPS * sizeof(struct file *));
+                         FILTER_GROUPS * sizeof(*filter->fo_last_objid_files));
                 filter->fo_last_objid_files = NULL;
         }
-        if (filter->fo_dentry_O_sub != NULL && filter->fo_subdir_count) {
+        if (filter->fo_dentry_O_sub != NULL) {
                 for (i = 0; i < filter->fo_subdir_count; i++) {
                         dentry = filter->fo_dentry_O_sub[i];
                         if (dentry != NULL)
@@ -558,7 +558,7 @@ static int filter_cleanup_groups(struct obd_device *obd)
         }
         if (filter->fo_last_objids != NULL) {
                 OBD_FREE(filter->fo_last_objids,
-                         FILTER_GROUPS * sizeof(__u64));
+                         FILTER_GROUPS * sizeof(*filter->fo_last_objids));
                 filter->fo_last_objids = NULL;
         }
         if (filter->fo_dentry_O != NULL) {
@@ -1249,6 +1249,7 @@ err_ops:
 
 static int filter_setup(struct obd_device *obd, obd_count len, void *buf)
 {
+        struct lprocfs_static_vars lvars;
         struct lustre_cfg* lcfg = buf;
         const char *str = NULL;
         char *option = NULL;
@@ -1275,6 +1276,21 @@ static int filter_setup(struct obd_device *obd, obd_count len, void *buf)
         rc = filter_common_setup(obd, len, buf, option);
         if (option)
                 OBD_FREE(option, n);
+
+        lprocfs_init_vars(filter, &lvars);
+        if (rc == 0 && lprocfs_obd_setup(obd, lvars.obd_vars) == 0 &&
+            lprocfs_alloc_obd_stats(obd, LPROC_FILTER_LAST) == 0) {
+                /* Init obdfilter private stats here */
+                lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_READ_BYTES,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "read_bytes", "bytes");
+                lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_WRITE_BYTES,
+                                     LPROCFS_CNTR_AVGMINMAX,
+                                     "write_bytes", "bytes");
+
+                lproc_filter_attach_seqstat(obd);
+        }
+
         return rc;
 }
 
@@ -1301,6 +1317,9 @@ static int filter_cleanup(struct obd_device *obd, int flags)
         if (filter->fo_sb == NULL)
                 RETURN(0);
 
+        lprocfs_free_obd_stats(obd);
+        lprocfs_obd_cleanup(obd);
+
         filter_post(obd);
 
         shrink_dcache_parent(filter->fo_sb->s_root);
@@ -1323,35 +1342,6 @@ static int filter_cleanup(struct obd_device *obd, int flags)
         RETURN(0);
 }
 
-static int filter_attach(struct obd_device *obd, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-        int rc;
-
-        lprocfs_init_vars(filter, &lvars);
-        rc = lprocfs_obd_attach(obd, lvars.obd_vars);
-        if (rc != 0)
-                return rc;
-
-        rc = lprocfs_alloc_obd_stats(obd, LPROC_FILTER_LAST);
-        if (rc != 0)
-                return rc;
-
-        /* Init obdfilter private stats here */
-        lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_READ_BYTES,
-                             LPROCFS_CNTR_AVGMINMAX, "read_bytes", "bytes");
-        lprocfs_counter_init(obd->obd_stats, LPROC_FILTER_WRITE_BYTES,
-                             LPROCFS_CNTR_AVGMINMAX, "write_bytes", "bytes");
-
-        return lproc_filter_attach_seqstat(obd);
-}
-
-static int filter_detach(struct obd_device *dev)
-{
-        lprocfs_free_obd_stats(dev);
-        return lprocfs_obd_detach(dev);
-}
-
 /* nearly identical to mds_connect */
 static int filter_connect(struct lustre_handle *conn, struct obd_device *obd,
                           struct obd_uuid *cluuid)
@@ -2388,8 +2378,6 @@ static struct lvfs_callback_ops filter_lvfs_ops = {
 
 static struct obd_ops filter_obd_ops = {
         o_owner:          THIS_MODULE,
-        o_attach:         filter_attach,
-        o_detach:         filter_detach,
         o_get_info:       filter_get_info,
         o_set_info:       filter_set_info,
         o_setup:          filter_setup,
@@ -2416,8 +2404,6 @@ static struct obd_ops filter_obd_ops = {
 
 static struct obd_ops filter_sanobd_ops = {
         o_owner:          THIS_MODULE,
-        o_attach:         filter_attach,
-        o_detach:         filter_detach,
         o_get_info:       filter_get_info,
         o_set_info:       filter_set_info,
         o_setup:          filter_san_setup,
index 3900ad1..b9b7ab3 100644 (file)
@@ -106,6 +106,9 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
 {
         struct filter_export_data *fed;
         struct obd_device *obd = exp->exp_obd;
+        static unsigned long last_msg;
+        static int last_count;
+        int mask = D_CACHE;
         ENTRY;
 
         LASSERT_SPIN_LOCKED(&obd->obd_osfs_lock);
@@ -119,11 +122,20 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa)
 
         fed = &exp->exp_filter_data;
 
+        /* Don't print this to the console the first time it happens, since
+         * it can happen legitimately on occasion, but only rarely. */
+        if (time_after(jiffies, last_msg + 60 * HZ)) {
+                last_count = 0;
+                last_msg = jiffies;
+        }
+        if ((last_count & (-last_count)) == last_count)
+                mask = D_WARNING;
+        last_count++;
+
         /* Add some margin, since there is a small race if other RPCs arrive
          * out-or-order and have already consumed some grant.  We want to
          * leave this here in case there is a large error in accounting. */
-        CDEBUG(oa->o_grant > fed->fed_grant + FILTER_GRANT_CHUNK ?
-               D_WARNING : D_CACHE,
+        CDEBUG(oa->o_grant > fed->fed_grant + FILTER_GRANT_CHUNK ? mask:D_CACHE,
                "%s: cli %s/%p reports grant: "LPU64" dropped: %u, local: %lu\n",
                obd->obd_name, exp->exp_client_uuid.uuid, exp, oa->o_grant,
                oa->o_dropped, fed->fed_grant);
index 6fae59d..8f64926 100644 (file)
@@ -34,10 +34,47 @@ static struct lprocfs_vars lprocfs_obd_vars[]  = { {0} };
 static struct lprocfs_vars lprocfs_module_vars[] = { {0} };
 #else
 
+static int lprocfs_filter_rd_groups(char *page, char **start, off_t off,
+                                    int count, int *eof, void *data)
+{
+        *eof = 1;
+        return snprintf(page, count, "%u\n", FILTER_GROUPS);
+}
+
+static int lprocfs_filter_rd_tot_dirty(char *page, char **start, off_t off,
+                                       int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+
+        LASSERT(obd != NULL);
+        *eof = 1;
+        return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_dirty);
+}
+
+static int lprocfs_filter_rd_tot_granted(char *page, char **start, off_t off,
+                                         int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+
+        LASSERT(obd != NULL);
+        *eof = 1;
+        return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_granted);
+}
+
+static int lprocfs_filter_rd_tot_pending(char *page, char **start, off_t off,
+                                         int count, int *eof, void *data)
+{
+        struct obd_device *obd = (struct obd_device *)data;
+
+        LASSERT(obd != NULL);
+        *eof = 1;
+        return snprintf(page, count, LPU64"\n", obd->u.filter.fo_tot_pending);
+}
+
 static int lprocfs_filter_rd_mntdev(char *page, char **start, off_t off,
                                     int count, int *eof, void *data)
 {
-        struct obd_deviceobd = (struct obd_device *)data;
+        struct obd_device *obd = (struct obd_device *)data;
 
         LASSERT(obd != NULL);
         LASSERT(obd->u.filter.fo_vfsmnt->mnt_devname);
@@ -92,10 +129,14 @@ static struct lprocfs_vars lprocfs_obd_vars[] = {
         { "kbytesavail",  lprocfs_rd_kbytesavail,   0, 0 },
         { "filestotal",   lprocfs_rd_filestotal,    0, 0 },
         { "filesfree",    lprocfs_rd_filesfree,     0, 0 },
-        //{ "filegroups",   lprocfs_rd_filegroups,    0, 0 },
+        { "filegroups",   lprocfs_filter_rd_groups, 0, 0 },
         { "fstype",       lprocfs_rd_fstype,        0, 0 },
         { "mntdev",       lprocfs_filter_rd_mntdev, 0, 0 },
         { "last_id",      lprocfs_filter_rd_last_id,0, 0 },
+        { "tot_dirty",    lprocfs_filter_rd_tot_dirty,   0, 0 },
+        { "tot_pending",  lprocfs_filter_rd_tot_pending, 0, 0 },
+        { "tot_granted",  lprocfs_filter_rd_tot_granted, 0, 0 },
+        { "num_exports",  lprocfs_rd_num_exports,   0, 0 },
         { "readcache_max_filesize",
                           lprocfs_filter_rd_readcache,
                           lprocfs_filter_wr_readcache, 0 },
@@ -137,7 +178,7 @@ void filter_tally_write(struct filter_obd *filter, struct page **pages,
         lprocfs_oh_tally(&filter->fo_w_discont_blocks, discont_blocks);
 }
 
-void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb, 
+void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb,
                        int niocount)
 {
         struct niobuf_local *end;
@@ -156,7 +197,7 @@ void filter_tally_read(struct filter_obd *filter, struct niobuf_local *lnb,
                         /* XXX not so smart for now */
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
                         if ((page->buffers && last_page->buffers) &&
-                            (page->buffers->b_blocknr != 
+                            (page->buffers->b_blocknr !=
                              (last_page->buffers->b_blocknr + 1)))
                                 discont_blocks++;
 #else
@@ -202,9 +243,9 @@ static int filter_brw_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = filter->fo_w_pages.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n", 
-                                 1 << i, r, pct(r, read_tot), 
-                                 pct(read_cum, read_tot), w, 
+                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+                                 1 << i, r, pct(r, read_tot),
+                                 pct(read_cum, read_tot), w,
                                  pct(w, write_tot),
                                  pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
@@ -226,9 +267,9 @@ static int filter_brw_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = filter->fo_w_discont_pages.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n", 
-                                 i, r, pct(r, read_tot), 
-                                 pct(read_cum, read_tot), w, 
+                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+                                 i, r, pct(r, read_tot),
+                                 pct(read_cum, read_tot), w,
                                  pct(w, write_tot),
                                  pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
@@ -249,9 +290,9 @@ static int filter_brw_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = filter->fo_w_discont_blocks.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n", 
-                                 i, r, pct(r, read_tot), 
-                                 pct(read_cum, read_tot), w, 
+                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+                                 i, r, pct(r, read_tot),
+                                 pct(read_cum, read_tot), w,
                                  pct(w, write_tot),
                                  pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
@@ -288,7 +329,7 @@ static int filter_brw_stats_seq_open(struct inode *inode, struct file *file)
         struct proc_dir_entry *dp = PDE(inode);
         struct seq_file *seq;
         int rc;
+
         rc = seq_open(file, &filter_brw_stats_seq_sops);
         if (rc)
                 return rc;
@@ -315,6 +356,7 @@ static ssize_t filter_brw_stats_seq_write(struct file *file, const char *buf,
 }
 
 struct file_operations filter_brw_stats_fops = {
+        .owner   = THIS_MODULE,
         .open    = filter_brw_stats_seq_open,
         .read    = seq_read,
         .write   = filter_brw_stats_seq_write,
@@ -324,11 +366,11 @@ struct file_operations filter_brw_stats_fops = {
 
 int lproc_filter_attach_seqstat(struct obd_device *dev)
 {
-        return lprocfs_obd_seq_create(dev, "brw_stats", 0444, 
+        return lprocfs_obd_seq_create(dev, "brw_stats", 0444,
                                       &filter_brw_stats_fops, dev);
 }
 
 
 
 #endif /* LPROCFS */
-LPROCFS_INIT_VARS(filter,lprocfs_module_vars, lprocfs_obd_vars)
+LPROCFS_INIT_VARS(filter, lprocfs_module_vars, lprocfs_obd_vars)
index 93b4276..88b4d2a 100644 (file)
@@ -306,7 +306,7 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
         rpcs = cli->cl_brw_in_flight;
         r = cli->cl_pending_r_pages;
         w = cli->cl_pending_w_pages;
-                                                                                
+
         seq_printf(seq, "snapshot_time:         %lu:%lu (secs:usecs)\n",
                    now.tv_sec, now.tv_usec);
         seq_printf(seq, "RPCs in flight:        %d\n", rpcs);
@@ -327,9 +327,9 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = cli->cl_write_page_hist.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n", 
-                                 1 << i, r, pct(r, read_tot), 
-                                 pct(read_cum, read_tot), w, 
+                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+                                 1 << i, r, pct(r, read_tot),
+                                 pct(read_cum, read_tot), w,
                                  pct(w, write_tot),
                                  pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
@@ -350,9 +350,9 @@ static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
                 unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
                 read_cum += r;
                 write_cum += w;
-                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n", 
-                                 i, r, pct(r, read_tot), 
-                                 pct(read_cum, read_tot), w, 
+                seq_printf(seq, "%d:\t\t%10lu %3lu %3lu   | %10lu %3lu %3lu\n",
+                                 i, r, pct(r, read_tot),
+                                 pct(read_cum, read_tot), w,
                                  pct(w, write_tot),
                                  pct(write_cum, write_tot));
                 if (read_cum == read_tot && write_cum == write_tot)
@@ -391,7 +391,7 @@ static int osc_rpc_stats_seq_open(struct inode *inode, struct file *file)
         struct proc_dir_entry *dp = PDE(inode);
         struct seq_file *seq;
         int rc;
+
         rc = seq_open(file, &osc_rpc_stats_seq_sops);
         if (rc)
                 return rc;
@@ -416,6 +416,7 @@ static ssize_t osc_rpc_stats_seq_write(struct file *file, const char *buf,
 }
 
 struct file_operations osc_rpc_stats_fops = {
+        .owner   = THIS_MODULE,
         .open    = osc_rpc_stats_seq_open,
         .read    = seq_read,
         .write   = osc_rpc_stats_seq_write,
@@ -425,10 +426,9 @@ struct file_operations osc_rpc_stats_fops = {
 
 int lproc_osc_attach_seqstat(struct obd_device *dev)
 {
-        return lprocfs_obd_seq_create(dev, "rpc_stats", 0444, 
+        return lprocfs_obd_seq_create(dev, "rpc_stats", 0444,
                                       &osc_rpc_stats_fops, dev);
 }
 
-
 #endif /* LPROCFS */
-LPROCFS_INIT_VARS(osc,lprocfs_module_vars, lprocfs_obd_vars)
+LPROCFS_INIT_VARS(osc, lprocfs_module_vars, lprocfs_obd_vars)
index 601d59d..84b3ffc 100644 (file)
 #include <linux/lustre_log.h>
 #include "osc_internal.h"
 
-
-static int osc_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-        int rc;
-        ENTRY;
-
-        lprocfs_init_vars(osc,&lvars);
-        rc = lprocfs_obd_attach(dev, lvars.obd_vars);
-        if (rc < 0)
-                RETURN(rc);
-
-        rc = lproc_osc_attach_seqstat(dev);
-        if (rc < 0) {
-                lprocfs_obd_detach(dev);
-                RETURN(rc);
-        }
-
-        ptlrpc_lprocfs_register_obd(dev);
-        RETURN(0);
-}
-
-static int osc_detach(struct obd_device *dev)
-{
-        ptlrpc_lprocfs_unregister_obd(dev);
-        return lprocfs_obd_detach(dev);
-}
-
-
 /* Pack OSC object metadata for disk storage (LE byte order). */
 static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
                       struct lov_stripe_md *lsm)
@@ -2919,10 +2890,19 @@ int osc_setup(struct obd_device *obd, obd_count len, void *buf)
                 return rc;
 
         rc = client_obd_setup(obd, len, buf);
-        if (rc)
+        if (rc) {
                 ptlrpcd_decref();
-        else
+        } else {
+                struct lprocfs_static_vars lvars;
+
+                lprocfs_init_vars(osc, &lvars);
+                if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
+                        lproc_osc_attach_seqstat(obd);
+                        ptlrpc_lprocfs_register_obd(obd);
+                }
+
                 oscc_init(obd);
+        }
 
         RETURN(rc);
 }
@@ -2931,6 +2911,9 @@ int osc_cleanup(struct obd_device *obd, int flags)
 {
         int rc;
 
+        ptlrpc_lprocfs_unregister_obd(obd);
+        lprocfs_obd_cleanup(obd);
+
         rc = client_obd_cleanup(obd, flags);
         ptlrpcd_decref();
         RETURN(rc);
@@ -2939,8 +2922,6 @@ int osc_cleanup(struct obd_device *obd, int flags)
 
 struct obd_ops osc_obd_ops = {
         o_owner:        THIS_MODULE,
-        o_attach:       osc_attach,
-        o_detach:       osc_detach,
         o_setup:        osc_setup,
         o_cleanup:      osc_cleanup,
         o_connect:      osc_connect,
@@ -2979,8 +2960,6 @@ struct obd_ops osc_obd_ops = {
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
 struct obd_ops sanosc_obd_ops = {
         o_owner:        THIS_MODULE,
-        o_attach:       osc_attach,
-        o_detach:       osc_detach,
         o_cleanup:      client_obd_cleanup,
         o_connect:      osc_connect,
         o_disconnect:   client_disconnect_export,
index 1359623..8a9a67a 100644 (file)
@@ -1118,9 +1118,10 @@ out:
         return 0;
 }
 
-static int ost_setup(struct obd_device *obddev, obd_count len, void *buf)
+static int ost_setup(struct obd_device *obd, obd_count len, void *buf)
 {
-        struct ost_obd *ost = &obddev->u.ost;
+        struct ost_obd *ost = &obd->u.ost;
+        struct lprocfs_static_vars lvars;
         int rc;
         ENTRY;
 
@@ -1132,18 +1133,18 @@ static int ost_setup(struct obd_device *obddev, obd_count len, void *buf)
         if (rc < 0)
                 RETURN(rc);
 
-        ost->ost_service = 
+        ost->ost_service =
                 ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
                                 OST_REQUEST_PORTAL, OSC_REPLY_PORTAL,
                                 ost_handle, "ost",
-                                obddev->obd_proc_entry);
+                                obd->obd_proc_entry);
         if (ost->ost_service == NULL) {
                 CERROR("failed to start service\n");
                 RETURN(-ENOMEM);
         }
-        
-        rc = ptlrpc_start_n_threads(obddev, ost->ost_service, OST_NUM_THREADS, 
-                                 "ll_ost");
+
+        rc = ptlrpc_start_n_threads(obd, ost->ost_service, OST_NUM_THREADS,
+                                    "ll_ost");
         if (rc)
                 GOTO(out, rc = -EINVAL);
 
@@ -1151,17 +1152,20 @@ static int ost_setup(struct obd_device *obddev, obd_count len, void *buf)
                 ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
                                 OST_CREATE_PORTAL, OSC_REPLY_PORTAL,
                                 ost_handle, "ost_create",
-                                obddev->obd_proc_entry);
+                                obd->obd_proc_entry);
         if (ost->ost_create_service == NULL) {
                 CERROR("failed to start OST create service\n");
                 GOTO(out, rc = -ENOMEM);
         }
 
-        rc = ptlrpc_start_n_threads(obddev, ost->ost_create_service, 1,
+        rc = ptlrpc_start_n_threads(obd, ost->ost_create_service, 1,
                                     "ll_ost_create");
-        if (rc) 
+        if (rc)
                 GOTO(out_create, rc = -EINVAL);
 
+        lprocfs_init_vars(ost, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
+
         RETURN(0);
 
 out_create:
@@ -1171,18 +1175,20 @@ out:
         RETURN(rc);
 }
 
-static int ost_cleanup(struct obd_device *obddev, int flags)
+static int ost_cleanup(struct obd_device *obd, int flags)
 {
-        struct ost_obd *ost = &obddev->u.ost;
+        struct ost_obd *ost = &obd->u.ost;
         int err = 0;
         ENTRY;
 
-        spin_lock_bh(&obddev->obd_processing_task_lock);
-        if (obddev->obd_recovering) {
-                target_cancel_recovery_timer(obddev);
-                obddev->obd_recovering = 0;
+        lprocfs_obd_cleanup(obd);
+
+        spin_lock_bh(&obd->obd_processing_task_lock);
+        if (obd->obd_recovering) {
+                target_cancel_recovery_timer(obd);
+                obd->obd_recovering = 0;
         }
-        spin_unlock_bh(&obddev->obd_processing_task_lock);
+        spin_unlock_bh(&obd->obd_processing_task_lock);
 
         ptlrpc_stop_all_threads(ost->ost_service);
         ptlrpc_unregister_service(ost->ost_service);
@@ -1193,24 +1199,9 @@ static int ost_cleanup(struct obd_device *obddev, int flags)
         RETURN(err);
 }
 
-int ost_attach(struct obd_device *dev, obd_count len, void *data)
-{
-        struct lprocfs_static_vars lvars;
-
-        lprocfs_init_vars(ost,&lvars);
-        return lprocfs_obd_attach(dev, lvars.obd_vars);
-}
-
-int ost_detach(struct obd_device *dev)
-{
-        return lprocfs_obd_detach(dev);
-}
-
 /* use obd ops to offer management infrastructure */
 static struct obd_ops ost_obd_ops = {
         o_owner:        THIS_MODULE,
-        o_attach:       ost_attach,
-        o_detach:       ost_detach,
         o_setup:        ost_setup,
         o_cleanup:      ost_cleanup,
 };
index b51d09e..2ccf00e 100644 (file)
@@ -35,6 +35,7 @@
 static int ptlbd_cl_setup(struct obd_device *obd, obd_count len, void *buf)
 {
         struct ptlbd_obd *ptlbd = &obd->u.ptlbd;
+        struct lprocfs_static_vars lvars;
         struct obd_import *imp;
         struct lustre_cfg* lcfg = buf;
         ENTRY;
@@ -66,14 +67,17 @@ static int ptlbd_cl_setup(struct obd_device *obd, obd_count len, void *buf)
         }
         imp->imp_state = LUSTRE_IMP_FULL;
 
-        ptlrpc_init_client(PTLBD_REQUEST_PORTAL, PTLBD_REPLY_PORTAL, 
+        ptlrpc_init_client(PTLBD_REQUEST_PORTAL, PTLBD_REPLY_PORTAL,
                         "ptlbd", &ptlbd->bd_client);
         imp->imp_client = &ptlbd->bd_client;
         imp->imp_obd = obd;
-        memcpy(imp->imp_target_uuid.uuid, lcfg->lcfg_inlbuf1, 
+        memcpy(imp->imp_target_uuid.uuid, lcfg->lcfg_inlbuf1,
                lcfg->lcfg_inllen1);
         ptlbd_blk_register(ptlbd);
 
+        lprocfs_init_vars(ptlbd_cl, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
+
         RETURN(0);
 }
 
@@ -89,6 +93,8 @@ static int ptlbd_cl_cleanup(struct obd_device *obd, int flags)
         if (!imp->imp_connection)
                 RETURN(-ENOENT);
 
+        lprocfs_obd_cleanup(obd);
+
         ptlrpc_cleanup_client(imp);
         ptlrpc_put_connection(imp->imp_connection);
 
@@ -110,7 +116,7 @@ int ptlbd_cl_connect(struct lustre_handle *conn, struct obd_device *obd,
         int     rc, size[] = {sizeof(imp->imp_target_uuid),
                               sizeof(obd->obd_uuid),
                               sizeof(*conn)};
-        char *tmp[] = {imp->imp_target_uuid.uuid, 
+        char *tmp[] = {imp->imp_target_uuid.uuid,
                        obd->obd_uuid.uuid,
                        (char*)conn};
         ENTRY;
@@ -140,7 +146,7 @@ int ptlbd_cl_connect(struct lustre_handle *conn, struct obd_device *obd,
 
         imp->imp_state = LUSTRE_IMP_FULL;
         imp->imp_remote_handle = request->rq_repmsg->handle;
-        
+
 out_req:
         ptlrpc_req_finished(request);
 out_disco:
index c7ac53b..7c94db7 100644 (file)
 
 static int ptlbd_sv_already_setup = 1;
 
-static int ptlbd_sv_setup(struct obd_device *obddev, obd_count len, void *buf)
+static int ptlbd_sv_setup(struct obd_device *obd, obd_count len, void *buf)
 {
-        struct ptlbd_obd *ptlbd = &obddev->u.ptlbd;
+        struct ptlbd_obd *ptlbd = &obd->u.ptlbd;
+        struct lprocfs_static_vars lvars;
         int rc;
         ENTRY;
 
@@ -52,17 +53,20 @@ static int ptlbd_sv_setup(struct obd_device *obddev, obd_count len, void *buf)
                 ptlrpc_init_svc(PTLBD_NBUFS, PTLBD_BUFSIZE, PTLBD_MAXREQSIZE,
                                 PTLBD_REQUEST_PORTAL, PTLBD_REPLY_PORTAL,
                                 ptlbd_handle, "ptlbd_sv",
-                                obddev->obd_proc_entry);
+                                obd->obd_proc_entry);
 
-        if (ptlbd->ptlbd_service == NULL) 
+        if (ptlbd->ptlbd_service == NULL)
                 GOTO(out_filp, rc = -ENOMEM);
 
-        rc = ptlrpc_start_n_threads(obddev, ptlbd->ptlbd_service, 1, "ptldb");
-        if (rc != 0) 
+        rc = ptlrpc_start_n_threads(obd, ptlbd->ptlbd_service, 1, "ptldb");
+        if (rc != 0)
                 GOTO(out_thread, rc);
 
         ptlbd_sv_already_setup = 1;
 
+        lprocfs_init_vars(ptlbd_sv, &lvars);
+        lprocfs_obd_setup(obd, lvars.obd_vars);
+
         RETURN(0);
 
 out_thread:
@@ -73,13 +77,15 @@ out_filp:
         RETURN(rc);
 }
 
-static int ptlbd_sv_cleanup(struct obd_device *obddev, int flags)
+static int ptlbd_sv_cleanup(struct obd_device *obd, int flags)
 {
-        struct ptlbd_obd *ptlbd = &obddev->u.ptlbd;
+        struct ptlbd_obd *ptlbd = &obd->u.ptlbd;
         ENTRY;
 
         /* XXX check for state */
 
+        lprocfs_obd_cleanup(obd);
+
         ptlrpc_stop_all_threads(ptlbd->ptlbd_service);
         ptlrpc_unregister_service(ptlbd->ptlbd_service);
         if ( ! IS_ERR(ptlbd->filp) )