aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo M. Correia <ricardo.correia@oracle.com>2011-01-21 22:35:41 +0000
committerBrian Behlendorf <behlendorf1@llnl.gov>2011-02-16 19:20:06 +0000
commit54a179e7b80413bd48cd2cd259110fb493d0215e (patch)
tree8bce4e2af34f745165ee0b225e0616ee823dfc7d
parent8d4e8140ef67fa9c8fa0b1d0f5b1d5d36c747969 (diff)
downloadsrc-54a179e7b80413bd48cd2cd259110fb493d0215e.tar.gz
src-54a179e7b80413bd48cd2cd259110fb493d0215e.zip
Add API to wait for pending commit callbacks
This adds an API to wait for pending commit callbacks of already-synced transactions to finish processing. This is needed by the DMU-OSD in Lustre during device finalization when some callbacks may still not be called, this leads to non-zero reference count errors. See lustre.org bug 23931.
-rw-r--r--include/sys/txg.h6
-rw-r--r--module/zfs/dmu_objset.c1
-rw-r--r--module/zfs/txg.c15
3 files changed, 22 insertions, 0 deletions
diff --git a/include/sys/txg.h b/include/sys/txg.h
index e323d5efabb7..263693846d54 100644
--- a/include/sys/txg.h
+++ b/include/sys/txg.h
@@ -108,6 +108,12 @@ extern boolean_t txg_stalled(struct dsl_pool *dp);
extern boolean_t txg_sync_waiting(struct dsl_pool *dp);
/*
+ * Wait for pending commit callbacks of already-synced transactions to finish
+ * processing.
+ */
+extern void txg_wait_callbacks(struct dsl_pool *dp);
+
+/*
* Per-txg object lists.
*/
diff --git a/module/zfs/dmu_objset.c b/module/zfs/dmu_objset.c
index 7da5c1aa08f5..0ff95a64e0bd 100644
--- a/module/zfs/dmu_objset.c
+++ b/module/zfs/dmu_objset.c
@@ -1813,6 +1813,7 @@ EXPORT_SYMBOL(dmu_objset_destroy);
EXPORT_SYMBOL(dmu_objset_snapshot);
EXPORT_SYMBOL(dmu_objset_stats);
EXPORT_SYMBOL(dmu_objset_fast_stat);
+EXPORT_SYMBOL(dmu_objset_spa);
EXPORT_SYMBOL(dmu_objset_space);
EXPORT_SYMBOL(dmu_objset_fsid_guid);
EXPORT_SYMBOL(dmu_objset_find);
diff --git a/module/zfs/txg.c b/module/zfs/txg.c
index 382a2a91c7b0..5afb139ddfb0 100644
--- a/module/zfs/txg.c
+++ b/module/zfs/txg.c
@@ -350,6 +350,20 @@ txg_dispatch_callbacks(dsl_pool_t *dp, uint64_t txg)
}
}
+/*
+ * Wait for pending commit callbacks of already-synced transactions to finish
+ * processing.
+ * Calling this function from within a commit callback will deadlock.
+ */
+void
+txg_wait_callbacks(dsl_pool_t *dp)
+{
+ tx_state_t *tx = &dp->dp_tx;
+
+ if (tx->tx_commit_cb_taskq != NULL)
+ taskq_wait(tx->tx_commit_cb_taskq);
+}
+
static void
txg_sync_thread(dsl_pool_t *dp)
{
@@ -735,6 +749,7 @@ EXPORT_SYMBOL(txg_register_callbacks);
EXPORT_SYMBOL(txg_delay);
EXPORT_SYMBOL(txg_wait_synced);
EXPORT_SYMBOL(txg_wait_open);
+EXPORT_SYMBOL(txg_wait_callbacks);
EXPORT_SYMBOL(txg_stalled);
EXPORT_SYMBOL(txg_sync_waiting);
#endif