mirror_zfs/module/zfs
Andriy Tkachuk f8457fbdc4
Fix deadlock on dmu_tx_assign() from vdev_rebuild()
vdev_rebuild() is always called with spa_config_lock held in
RW_WRITER mode. However, when it tries to call dmu_tx_assign()
the latter may hang on dmu_tx_wait() waiting for available txg.
But that available txg may not happen because txg_sync takes
spa_config_lock in order to process the current txg. So we have
a deadlock case here:

 - dmu_tx_assign() waits for txg holding spa_config_lock;
 - txg_sync waits for spa_config_lock not progressing with txg.

Here are the stacks:

    __schedule+0x24e/0x590
    schedule+0x69/0x110
    cv_wait_common+0xf8/0x130 [spl]
    __cv_wait+0x15/0x20 [spl]
    dmu_tx_wait+0x8e/0x1e0 [zfs]
    dmu_tx_assign+0x49/0x80 [zfs]
    vdev_rebuild_initiate+0x39/0xc0 [zfs]
    vdev_rebuild+0x84/0x90 [zfs]
    spa_vdev_attach+0x305/0x680 [zfs]
    zfs_ioc_vdev_attach+0xc7/0xe0 [zfs]

    cv_wait_common+0xf8/0x130 [spl]
    __cv_wait+0x15/0x20 [spl]
    spa_config_enter+0xf9/0x120 [zfs]
    spa_sync+0x6d/0x5b0 [zfs]
    txg_sync_thread+0x266/0x2f0 [zfs]

The solution is to pass txg returned by spa_vdev_enter(spa)
at the top of spa_vdev_attach() to vdev_rebuild() and call
dmu_tx_create_assigned(txg) which doesn't wait for txg.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Akash B <akash-b@hpe.com>
Reviewed-by: Alek Pinchuk <apinchuk@axcient.com>
Signed-off-by: Andriy Tkachuk <andriy.tkachuk@seagate.com>
Closes #18210
Closes #18258
2026-02-26 11:18:02 -08:00
..
abd.c Preserve LIFO ordering of kmap ops in abd_raidz_gen_iterate() 2025-12-09 09:12:16 -08:00
aggsum.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
arc.c arc: remove unused l2df_size and l2df_type from l2arc_data_free_t 2026-02-04 10:07:26 -08:00
blake3_zfs.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
blkptr.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
bplist.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
bpobj.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
bptree.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
bqueue.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
brt.c Add BRT support to zpool prefetch command 2025-11-10 16:16:22 -08:00
btree.c Move range_tree, btree, highbit64 to common code 2026-02-22 11:43:51 -08:00
dataset_kstats.c CI: Test & fix Linux ZFS built-in build 2026-02-19 10:15:41 -08:00
dbuf_stats.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
dbuf.c Remove parent ZIO from dbuf_prefetch() 2026-02-18 18:12:13 -08:00
ddt_log.c CI: Test & fix Linux ZFS built-in build 2026-02-19 10:15:41 -08:00
ddt_stats.c Introduce dedupused/dedupsaved pool properties 2026-02-25 09:41:38 -05:00
ddt_zap.c DDT: Fix compressed entry buffer size 2025-12-15 14:52:44 -08:00
ddt.c CI: Test & fix Linux ZFS built-in build 2026-02-19 10:15:41 -08:00
dmu_diff.c Allow physical rewrite without logical 2025-08-06 10:36:07 -07:00
dmu_direct.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
dmu_object.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
dmu_objset.c Allow rewrite skip cloned and snapshotted blocks 2026-02-09 10:17:56 -08:00
dmu_recv.c Fix activating large_microzap on receive 2026-02-05 15:48:03 -08:00
dmu_redact.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
dmu_send.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
dmu_traverse.c Allow physical rewrite without logical 2025-08-06 10:36:07 -07:00
dmu_tx.c Improve caching for dbuf prefetches 2026-02-04 10:12:32 -08:00
dmu_zfetch.c tunables: remove legacy FreeBSD aliases 2025-09-08 10:03:01 -07:00
dmu.c Cleanup allocation class selection 2026-02-16 10:33:21 -05:00
dnode_sync.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
dnode.c Update dnode_next_offset_level to accept blkid instead of offset 2025-11-04 13:12:17 -08:00
dsl_bookmark.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
dsl_crypt.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
dsl_dataset.c Add snapshots_changed_nsecs dataset property 2026-01-06 09:36:20 -08:00
dsl_deadlist.c Fix missed assertion update in physical rewrite patch 2025-08-13 15:56:25 -04:00
dsl_deleg.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
dsl_destroy.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
dsl_dir.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
dsl_pool.c Prefer VERIFY0P(n) over VERIFY(n == NULL) 2025-08-07 11:41:37 -07:00
dsl_prop.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
dsl_scan.c Use reduced precision for scan times 2025-12-18 10:22:11 -08:00
dsl_synctask.c dmu_tx_assign: make all VERIFY0 calls use DMU_TX_SUSPEND 2025-05-28 10:28:59 -07:00
dsl_userhold.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
edonr_zfs.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
fm.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
gzip.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
hkdf.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
lz4_zfs.c SPDX: license tags: BSD-2-Clause 2025-03-13 17:56:46 -07:00
lz4.c SPDX: license tags: BSD-2-Clause 2025-03-13 17:56:46 -07:00
lzjb.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
metaslab.c Fix available space accounting for special/dedup (#18222) 2026-02-19 10:36:35 -08:00
mmp.c mmp: claim sequence id before final import 2026-02-09 09:36:01 -08:00
multilist.c Allow vmem_alloc backed multilists 2025-08-12 13:36:03 -07:00
objlist.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
pathname.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
range_tree.c range_tree: use zfs_panic_recover() for partial-overlap remove 2026-02-25 11:26:10 -08:00
refcount.c Implement allocation size ranges and use for gang leaves (#17111) 2025-05-02 15:32:18 -07:00
rrwlock.c Prefer VERIFY0P(n) over VERIFY(n == NULL) 2025-08-07 11:41:37 -07:00
sa.c Lock db_mtx around arc_release() in couple places 2026-01-26 21:32:16 -05:00
sha2_zfs.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
skein_zfs.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
spa_checkpoint.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
spa_config.c spa_misc: add an API for spa_namespace_lock 2025-11-10 14:23:39 -08:00
spa_errlog.c Allow physical rewrite without logical 2025-08-06 10:36:07 -07:00
spa_history.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
spa_log_spacemap.c Fix available space accounting for special/dedup (#18222) 2026-02-19 10:36:35 -08:00
spa_misc.c Fix available space accounting for special/dedup (#18222) 2026-02-19 10:36:35 -08:00
spa_stats.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
spa.c Fix deadlock on dmu_tx_assign() from vdev_rebuild() 2026-02-26 11:18:02 -08:00
space_map.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
space_reftree.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
THIRDPARTYLICENSE.cityhash
THIRDPARTYLICENSE.cityhash.descrip
txg.c txg_wait_synced_flags: add TXG_WAIT_SUSPEND flag to not wait if pool suspended 2025-05-28 10:27:46 -07:00
u8_textprep.c u8_textprep: move into module/zfs 2025-12-22 14:58:36 -08:00
uberblock.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
unique.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_draid_rand.c SPDX: license tags: LicenseRef-OpenZFS-ThirdParty-PublicDomain 2025-03-13 17:57:31 -07:00
vdev_draid.c Detect a slow raidz child during reads 2025-09-10 15:25:03 -07:00
vdev_file.c Add vdev property to disable vdev scheduler 2026-02-23 09:34:33 -08:00
vdev_indirect_births.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
vdev_indirect_mapping.c Pass flags to more DMU write/hold functions 2025-10-29 11:17:51 -07:00
vdev_indirect.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
vdev_initialize.c spa_misc: add an API for spa_namespace_lock 2025-11-10 14:23:39 -08:00
vdev_label.c mmp: claim sequence id before final import 2026-02-09 09:36:01 -08:00
vdev_mirror.c Allow physical rewrite without logical 2025-08-06 10:36:07 -07:00
vdev_missing.c Implement allocation size ranges and use for gang leaves (#17111) 2025-05-02 15:32:18 -07:00
vdev_queue.c Add vdev property to disable vdev scheduler 2026-02-23 09:34:33 -08:00
vdev_raidz_math_aarch64_neon_common.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_aarch64_neon.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_aarch64_neonx2.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_avx2.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_avx512bw.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_avx512f.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_impl.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_powerpc_altivec_common.h SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_powerpc_altivec.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_scalar.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_sse2.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math_ssse3.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
vdev_raidz_math.c tunables: don't assert initialisation in impl getters 2025-05-28 16:50:22 -07:00
vdev_raidz.c RAIDZ: Remove some excessive logging 2025-12-17 14:00:01 -08:00
vdev_rebuild.c Fix deadlock on dmu_tx_assign() from vdev_rebuild() 2026-02-26 11:18:02 -08:00
vdev_removal.c spa_misc: add an API for spa_namespace_lock 2025-11-10 14:23:39 -08:00
vdev_root.c Implement allocation size ranges and use for gang leaves (#17111) 2025-05-02 15:32:18 -07:00
vdev_trim.c spa_misc: add an API for spa_namespace_lock 2025-11-10 14:23:39 -08:00
vdev.c Add vdev property to disable vdev scheduler 2026-02-23 09:34:33 -08:00
zap_leaf.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zap_micro.c DDT: Add/use zap_lookup_length_uint64_by_dnode() 2025-12-15 14:38:34 -08:00
zap.c DDT: Add/use zap_lookup_length_uint64_by_dnode() 2025-12-15 14:38:34 -08:00
zcp_get.c Add snapshots_changed_nsecs dataset property 2026-01-06 09:36:20 -08:00
zcp_global.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zcp_iter.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zcp_set.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zcp_synctask.c zcp_synctask: add zfs.sync.clone() 2025-06-10 14:53:10 -07:00
zcp.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
zfeature.c Synchronize the update of feature refcount 2025-08-22 16:35:58 -07:00
zfs_byteswap.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zfs_chksum.c chksum: run 256K benchmark on demand, preserve chksum_stat_data 2025-12-01 10:14:52 -08:00
zfs_crrd.c Fix time database update calculations 2025-09-12 16:33:36 -07:00
zfs_debug_common.c nvlist: Add nvlist_snprintf() and zfs_dbgmsg_nvlist() 2025-04-18 09:22:16 -04:00
zfs_fm.c Fix snapshot automount expiry cancellation deadlock 2025-12-01 14:43:42 -08:00
zfs_fuid.c libspl: move SID definitions from zfs_context.h; remove kernel gate 2025-11-12 10:01:48 -08:00
zfs_impl.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zfs_ioctl.c Fix send:raw permission for send -w -I 2026-02-11 10:30:26 -08:00
zfs_log.c ZIL: pass commit errors back to ITX callbacks 2025-08-08 16:43:20 -07:00
zfs_onexit.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zfs_quota.c Bypass snprintf() in quota checks if no quotas set 2025-12-17 21:59:47 -05:00
zfs_ratelimit.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zfs_replay.c dmu_tx: rename dmu_tx_assign() flags from TXG_* to DMU_TX_* (#17143) 2025-03-18 16:04:22 -07:00
zfs_rlock.c Prefer VERIFY0(n) over VERIFY3U(n, ==, 0) 2025-08-07 11:41:25 -07:00
zfs_sa.c ZIL: allow zil_commit() to fail with error 2025-08-08 16:43:09 -07:00
zfs_vnops.c Restrict cloning with different properties 2026-02-10 09:53:24 -08:00
zfs_znode.c Add default user/group/project quota properties 2025-04-03 10:35:22 -07:00
zil.c ZIL: Make allocations more flexible 2025-08-14 08:50:17 -07:00
zio_checksum.c Prefer VERIFY0(n) over VERIFY(n == 0) 2025-08-07 11:40:59 -07:00
zio_compress.c CI: Test & fix Linux ZFS built-in build 2026-02-19 10:15:41 -08:00
zio_inject.c spa_misc: add an API for spa_namespace_lock 2025-11-10 14:23:39 -08:00
zio.c DDT: Move logs searches out of the lock 2025-12-15 09:17:04 -08:00
zle.c SPDX: license tags: CDDL-1.0 2025-03-13 17:56:27 -07:00
zrlock.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
zthr.c Prefer VERIFY0P(n) over VERIFY3P(n, ==, NULL) 2025-08-07 11:41:42 -07:00
zvol.c spa_misc: add an API for spa_namespace_lock 2025-11-10 14:23:39 -08:00