freebsd-dev/sys/contrib
Mark Johnston 705a6ee2b6 zfs: Fix a deadlock between page busy and the teardown lock
When rolling back a dataset, ZFS has to purge file data resident in the
system page cache.  To do this, it loops over all vnodes for the
mountpoint and calls vn_pages_remove() to purge pages associated with
the vnode's VM object.  Each page is thus exclusively busied while the
dataset's teardown write lock is held.

When handling a page fault on a mapped ZFS file, FreeBSD's page fault
handler busies newly allocated pages and then uses VOP_GETPAGES to fill
them.  The ZFS getpages VOP acquires the teardown read lock with vnode
pages already busied.  This represents a lock order reversal which can
lead to deadlock.

To break the deadlock, observe that zfs_rezget() need only purge those
pages marked valid, and that pages busied by the page fault handler are,
by definition, invalid.  Furthermore, ZFS pages always transition from
invalid to valid with the teardown lock held, and ZFS never creates
partially valid pages.  Thus, zfs_rezget() can use the new
vn_pages_remove_valid() to skip over pages busied by the fault handler.

PR:		258208
Tested by:	pho
Reviewed by:	avg, sef, kib
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32931
2021-11-20 11:21:25 -05:00
..
alpine-hal
ck Merge commit 'ce929fe84f9c453263af379f3b255ff8eca01d48' 2021-10-29 19:18:03 +02:00
dev Import ACPICA 20210930 2021-09-30 22:05:52 -04:00
device-tree dts: fsl-ls1028a: Correct ECAM PCIE window ranges 2021-07-01 20:23:40 +02:00
dpdk_rte_lpm routing: Fix crashes with dpdk_lpm[46] algo. 2021-08-17 20:46:22 +00:00
edk2
ena-com ena: Remove redundant declaration of ena_log_level. 2021-07-23 16:07:35 -07:00
ipfilter/netinet kernel: deprecate Internet Class A/B/C 2021-11-09 09:32:38 -06:00
libb2
libfdt
libnv libnv: Fix array unpack endianness logic 2021-09-13 21:21:14 +02:00
libsodium
ncsw
ngatm ngatm: remove one of doubled semicolons 2021-08-30 11:39:30 -04:00
octeon-sdk mips/octeon SDK: Fix __cvmx_cmd_queue_lock asm for clang 11 2021-04-18 12:05:55 -05:00
openzfs zfs: Fix a deadlock between page busy and the teardown lock 2021-11-20 11:21:25 -05:00
pcg-c/include
rdma/krping ibcore: Declare ib_post_send() and ib_post_recv() arguments const 2021-07-12 14:22:33 +02:00
v4l
vchiq/interface vchiq: Rename timer func so they do not conflict with linuxkpi 2020-11-17 14:41:23 +00:00
x86emu
xz-embedded
zlib
zstd sys/*/conf/*, docs: fix links to handbook 2021-05-20 09:27:10 +01:00