From 27929cca29d949423773c30d39e7227b45df85fb Mon Sep 17 00:00:00 2001 From: wang di Date: Fri, 19 Jun 2015 11:07:18 -0700 Subject: [PATCH] LU-6750 zfs: add stop trans callback 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 Change-Id: I56b8d964b3c4dd24e3c56429b7f1a8960d3202cb Reviewed-on: http://review.whamcloud.com/15367 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Alex Zhuravlev Reviewed-by: Oleg Drokin --- lustre/osd-zfs/osd_handler.c | 30 +++++++++++++++++++++++++++--- lustre/osd-zfs/osd_internal.h | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lustre/osd-zfs/osd_handler.c b/lustre/osd-zfs/osd_handler.c index c87cc00..4ad7051 100644 --- a/lustre/osd-zfs/osd_handler.c +++ b/lustre/osd-zfs/osd_handler.c @@ -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) { - 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; } @@ -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. */ @@ -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); + osd_trans_stop_cb(oh, rc); + 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); + 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); diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index 12bf5a5..850290f 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -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 list_head ot_stop_dcb_list; struct list_head ot_unlinked_list; struct list_head ot_sa_list; struct semaphore ot_sa_lock; -- 1.8.3.1