Whamcloud - gitweb
LU-6750 zfs: add stop trans callback 67/15367/3
authorwang di <di.wang@intel.com>
Fri, 19 Jun 2015 18:07:18 +0000 (11:07 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 8 Jul 2015 17:16:43 +0000 (17:16 +0000)
Add stop transaction callback in OSD-ZFS, so when the
osd transaction is stopped, the top transaction
will be notified.

Signed-off-by: wang di <di.wang@intel.com>
Change-Id: I56b8d964b3c4dd24e3c56429b7f1a8960d3202cb
Reviewed-on: http://review.whamcloud.com/15367
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osd-zfs/osd_handler.c
lustre/osd-zfs/osd_internal.h

index c87cc00..4ad7051 100644 (file)
@@ -173,10 +173,15 @@ static void osd_trans_commit_cb(void *cb_data, int error)
 
 static int osd_trans_cb_add(struct thandle *th, struct dt_txn_commit_cb *dcb)
 {
 
 static int osd_trans_cb_add(struct thandle *th, struct dt_txn_commit_cb *dcb)
 {
-       struct osd_thandle *oh;
+       struct osd_thandle *oh = container_of0(th, struct osd_thandle,
+                                              ot_super);
 
 
-       oh = container_of0(th, struct osd_thandle, ot_super);
-       list_add(&dcb->dcb_linkage, &oh->ot_dcb_list);
+       LASSERT(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC);
+       LASSERT(&dcb->dcb_func != NULL);
+       if (dcb->dcb_flags & DCB_TRANS_STOP)
+               list_add(&dcb->dcb_linkage, &oh->ot_stop_dcb_list);
+       else
+               list_add(&dcb->dcb_linkage, &oh->ot_dcb_list);
 
        return 0;
 }
 
        return 0;
 }
@@ -247,6 +252,22 @@ static void osd_unlinked_list_emptify(struct osd_device *osd,
        }
 }
 
        }
 }
 
+static void osd_trans_stop_cb(struct osd_thandle *oth, int result)
+{
+       struct dt_txn_commit_cb *dcb;
+       struct dt_txn_commit_cb *tmp;
+
+       /* call per-transaction stop callbacks if any */
+       list_for_each_entry_safe(dcb, tmp, &oth->ot_stop_dcb_list,
+                                dcb_linkage) {
+               LASSERTF(dcb->dcb_magic == TRANS_COMMIT_CB_MAGIC,
+                        "commit callback entry: magic=%x name='%s'\n",
+                        dcb->dcb_magic, dcb->dcb_name);
+               list_del_init(&dcb->dcb_linkage);
+               dcb->dcb_func(NULL, &oth->ot_super, dcb, result);
+       }
+}
+
 /*
  * Concurrency: shouldn't matter.
  */
 /*
  * Concurrency: shouldn't matter.
  */
@@ -292,6 +313,8 @@ static int osd_trans_stop(const struct lu_env *env, struct dt_device *dt,
                CDEBUG(D_OTHER, "%s: transaction hook failed: rc = %d\n",
                       osd->od_svname, rc);
 
                CDEBUG(D_OTHER, "%s: transaction hook failed: rc = %d\n",
                       osd->od_svname, rc);
 
+       osd_trans_stop_cb(oh, rc);
+
        LASSERT(oh->ot_tx);
        txg = oh->ot_tx->tx_txg;
 
        LASSERT(oh->ot_tx);
        txg = oh->ot_tx->tx_txg;
 
@@ -330,6 +353,7 @@ static struct thandle *osd_trans_create(const struct lu_env *env,
 
        oh->ot_tx = tx;
        INIT_LIST_HEAD(&oh->ot_dcb_list);
 
        oh->ot_tx = tx;
        INIT_LIST_HEAD(&oh->ot_dcb_list);
+       INIT_LIST_HEAD(&oh->ot_stop_dcb_list);
        INIT_LIST_HEAD(&oh->ot_unlinked_list);
        INIT_LIST_HEAD(&oh->ot_sa_list);
        sema_init(&oh->ot_sa_lock, 1);
        INIT_LIST_HEAD(&oh->ot_unlinked_list);
        INIT_LIST_HEAD(&oh->ot_sa_list);
        sema_init(&oh->ot_sa_lock, 1);
index 12bf5a5..850290f 100644 (file)
@@ -203,6 +203,7 @@ static inline struct osd_thread_info *osd_oti_get(const struct lu_env *env)
 struct osd_thandle {
        struct thandle           ot_super;
        struct list_head         ot_dcb_list;
 struct osd_thandle {
        struct thandle           ot_super;
        struct list_head         ot_dcb_list;
+       struct list_head         ot_stop_dcb_list;
        struct list_head         ot_unlinked_list;
        struct list_head         ot_sa_list;
        struct semaphore         ot_sa_lock;
        struct list_head         ot_unlinked_list;
        struct list_head         ot_sa_list;
        struct semaphore         ot_sa_lock;