]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add API to wait for pending commit callbacks
authorRicardo M. Correia <ricardo.correia@oracle.com>
Fri, 21 Jan 2011 22:35:41 +0000 (14:35 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 16 Feb 2011 19:20:06 +0000 (11:20 -0800)
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.

include/sys/txg.h
module/zfs/dmu_objset.c
module/zfs/txg.c

index e323d5efabb78e5f36c3ad80c00d6ba02bfed86e..263693846d54bf0da66cb58c4b7f99b2d6d13dc5 100644 (file)
@@ -107,6 +107,12 @@ extern boolean_t txg_stalled(struct dsl_pool *dp);
 /* returns TRUE if someone is waiting for the next txg to sync */
 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.
  */
index 7da5c1aa08f5b5321e8575c333fb38816e8c52e8..0ff95a64e0bd0929f87846efe49f657d4d4a3ce0 100644 (file)
@@ -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);
index 382a2a91c7b08b5a0c1dada5c3a0edf6cbadb15d..5afb139ddfb0b87710bd2805326acf06ad0943a8 100644 (file)
@@ -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