Whamcloud - gitweb
move transaction commit callback context from dt_device to osd_device.
authorhuanghua <huanghua>
Mon, 28 Aug 2006 10:19:14 +0000 (10:19 +0000)
committerhuanghua <huanghua>
Mon, 28 Aug 2006 10:19:14 +0000 (10:19 +0000)
lustre/include/dt_object.h
lustre/obdclass/dt_object.c
lustre/osd/osd_handler.c

index d30a1f9..f1e913d 100644 (file)
@@ -326,13 +326,6 @@ struct dt_device {
          * single-threaded start-up shut-down procedures.
          */
         struct list_head             dd_txn_callbacks;
-
-        /* Thread context for transaction commit callback.
-         * Transaction commit is serialized, that is there is no more than one
-         * transaction commit at a time (jbd journal_commit_transaction() is 
-         * serialized). This means that it's enough to have _one_ lu_context.
-         */ 
-        struct lu_context            dd_ctx_for_commit;
 };
 
 int  dt_device_init(struct dt_device *dev, struct lu_device_type *t);
index 58906e1..a574ab2 100644 (file)
@@ -107,26 +107,14 @@ EXPORT_SYMBOL(dt_txn_hook_commit);
 
 int dt_device_init(struct dt_device *dev, struct lu_device_type *t)
 {
-        int rc;
 
         CFS_INIT_LIST_HEAD(&dev->dd_txn_callbacks);
-        rc = lu_context_init(&dev->dd_ctx_for_commit, LCT_MD_THREAD);
-        if (rc == 0) {
-                lu_context_enter(&dev->dd_ctx_for_commit);
-                rc = lu_device_init(&dev->dd_lu_dev, t);
-                if (rc != 0) {
-                        lu_context_exit(&dev->dd_ctx_for_commit);
-                        lu_context_fini(&dev->dd_ctx_for_commit);
-                }
-        }
-        return rc;
+        return lu_device_init(&dev->dd_lu_dev, t);
 }
 EXPORT_SYMBOL(dt_device_init);
 
 void dt_device_fini(struct dt_device *dev)
 {
-        lu_context_exit(&dev->dd_ctx_for_commit);
-        lu_context_fini(&dev->dd_ctx_for_commit);
         lu_device_fini(&dev->dd_lu_dev);
 }
 EXPORT_SYMBOL(dt_device_fini);
index 7117c31..0989261 100644 (file)
@@ -101,6 +101,14 @@ struct osd_device {
          * is named by its fid.
          */
         struct dentry            *od_obj_area;
+
+        /* Thread context for transaction commit callback.
+         * Currently, OSD is based on ext3/JBD. Transaction commit in ext3/JBD
+         * is serialized, that is there is no more than one transaction commit 
+         * at a time (JBD journal_commit_transaction() is serialized). 
+         * This means that it's enough to have _one_ lu_context.
+         */
+        struct lu_context         od_ctx_for_commit;
 };
 
 static int   osd_root_get      (const struct lu_context *ctxt,
@@ -458,7 +466,7 @@ static void osd_trans_commit_cb(struct journal_callback *jcb, int error)
                 /* This dd_ctx_for_commit is only for commit usage.
                  * see "struct dt_device" 
                  */ 
-                dt_txn_hook_commit(&dev->dd_ctx_for_commit, th);
+                dt_txn_hook_commit(&osd_dt_dev(dev)->od_ctx_for_commit, th);
         }
 
         lu_device_put(&dev->dd_lu_dev);
@@ -1754,7 +1762,11 @@ static void osd_key_exit(const struct lu_context *ctx,
 static int osd_device_init(const struct lu_context *ctx,
                            struct lu_device *d, struct lu_device *next)
 {
-        return 0;
+        int rc;
+        rc = lu_context_init(&osd_dev(d)->od_ctx_for_commit, LCT_MD_THREAD);
+        if (rc == 0)
+                lu_context_enter(&osd_dev(d)->od_ctx_for_commit);
+        return rc;
 }
 
 static int osd_shutdown(const struct lu_context *ctx, struct osd_device *o)
@@ -1819,6 +1831,8 @@ static struct lu_device *osd_device_fini(const struct lu_context *ctx,
                                          struct lu_device *d)
 {
         ENTRY;
+        lu_context_exit(&osd_dev(d)->od_ctx_for_commit);
+        lu_context_fini(&osd_dev(d)->od_ctx_for_commit);
         RETURN(NULL);
 }