mirror_zfs/module
Rob Norris 670147be53 zvol: ensure device minors are properly cleaned up
Currently, if a minor is in use when we try to remove it, we'll skip it
and never come back to it again. Since the zvol state is hung off the
minor in the kernel, this can get us into weird situations if something
tries to use it after the removal fails. It's even worse at pool export,
as there's now a vestigial zvol state with no pool under it. It's
weirder again if the pool is subsequently reimported, as the zvol code
(reasonably) assumes the zvol state has been properly setup, when it's
actually left over from the previous import of the pool.

This commit attempts to tackle that by setting a flag on the zvol if its
minor can't be removed, and then checking that flag when a request is
made and rejecting it, thus stopping new work coming in.

The flag also causes a condvar to be signaled when the last client
finishes. For the case where a single minor is being removed (eg
changing volmode), it will wait for this signal before proceeding.
Meanwhile, when removing all minors, a background task is created for
each minor that couldn't be removed on the spot, and those tasks then
wake and clean up.

Since any new tasks are queued on to the pool's spa_zvol_taskq,
spa_export_common() will continue to wait at export until all minors are
removed.

Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #14872
Closes #16364
2024-08-06 12:08:14 -07:00
..
avl Suppress Clang Static Analyzer false positive in the AVL tree code. 2023-03-08 13:51:21 -08:00
icp icp: remove redundant FreeBSD check 2024-05-31 15:13:59 -07:00
lua LUA: Backport CVE-2020-24370's patch 2024-02-07 11:53:05 -08:00
nvpair xdr: header cleanup 2024-04-03 15:13:27 -07:00
os zvol: ensure device minors are properly cleaned up 2024-08-06 12:08:14 -07:00
unicode Illumos #15286: do_composition() needs sign awareness 2023-01-05 11:16:21 -08:00
zcommon ddt: add support for prefetching tables into the ARC 2024-07-26 09:16:18 -07:00
zfs zvol: ensure device minors are properly cleaned up 2024-08-06 12:08:14 -07:00
zstd zstd: don't call zstd_mempool_reap if there are no buffers (#16302) 2024-07-15 14:51:37 -07:00
.gitignore FreeBSD: Ignore symlink to i386 includes 2022-08-02 16:34:23 -07:00
Kbuild.in Linux 6.9: Fix UBSAN errors in sa.c (#16380) 2024-07-23 17:13:04 -07:00
Makefile.bsd Makefile.bsd: sort and cleanup source file list 2024-04-03 15:49:22 -07:00
Makefile.in check-zstd-symbols: also ignore __pfx_ symbols 2023-09-18 09:08:41 -07:00