freebsd-src/sys
Andriy Gapon aca41af247 g_access: deal with races created by geoms that drop the topology lock
The problem is that g_access() must be called with the GEOM topology
lock held.  And that gives a false impression that the lock is indeed
held across the call.  But this isn't always true because many classes,
ZVOL being one of the many, need to drop the lock.  It's either to
perform an I/O on the first open or to acquire a different lock (like in
g_mirror_access).

That, of course, can break many assumptions.  For example,
g_slice_access() adds an extra exclusive count on the first open. As
described above, an underlying geom may drop the topology lock and that
would open a race with another thread that would also request another
extra exclusive count.  In general, two consumers may be granted
incompatible accesses.

To avoid this problem the code is changed to mark a geom with special
flag before calling its access method and clear the flag afterwards.  If
another thread sees that flag, then it means that the topology lock has
been dropped (either by the geom in question or downstream from it), so
it is not safe to make another access call.  So, the second thread would
use g_topology_sleep() to wait until the flag is cleared and only then
would it proceed with the access.

Also see http://docs.freebsd.org/cgi/mid.cgi?809d9254-ee56-59d8-69a4-08838e985cea

PR:		225960
Reported by:	asomers
Reviewed by:	markj, mav
MFC after:	3 weeks
Differential Revision: https://reviews.freebsd.org/D14533
2018-03-15 09:16:10 +00:00
..
amd64 Remove stray ; at end of linux_vdso_deinstall() 2018-03-14 13:20:36 +00:00
arm arm: Remove SoC Specific -MMCCAM kernelconfig 2018-03-11 23:14:50 +00:00
arm64 EFIRT: SetVirtualAddressMap with 1:1 mapping after exiting boot services 2018-03-13 17:10:52 +00:00
bsm
cam Create a sysctl kern.cam.{,a,n}da.X.invalidate 2018-03-14 17:53:37 +00:00
cddl MFV r330973: 9164 assert: newds == os->os_dsl_dataset 2018-03-15 08:49:21 +00:00
compat Fix compliancy of the kstrtoXXX() functions in the LinuxKPI, by skipping 2018-03-14 19:51:28 +00:00
conf Reverting r330925 for now 2018-03-15 06:19:45 +00:00
contrib Merge ACPICA 20180313. 2018-03-14 23:45:48 +00:00
crypto Remove unused error return from API that cannot fail 2018-02-23 20:15:19 +00:00
ddb db_script_exec: use a saved script name when reporting commands executed 2018-03-04 13:27:21 +00:00
dev Increase ABOUT FIRMWARE command timeout to 5s. 2018-03-15 01:07:21 +00:00
dts [rpi] remove IRQ support for BCM233x RNG 2018-03-10 02:49:58 +00:00
fs Fix Bad file descriptor error. 2018-03-09 04:45:24 +00:00
gdb amd64: Protect the kernel text, data, and BSS by setting the RW/NX bits 2018-03-06 14:28:37 +00:00
geom g_access: deal with races created by geoms that drop the topology lock 2018-03-15 09:16:10 +00:00
gnu bwn(4): txpid2g/txpid5g[lh] are not defined after sromrev 7; the default 2018-02-13 17:43:54 +00:00
i386 Remove stray ; at end of linux_vdso_deinstall() 2018-03-14 13:20:36 +00:00
isa Revert r330780, it was improperly tested and results in taking a spin 2018-03-11 20:13:15 +00:00
kern vfs_bio.c: Apply cleanups motivated by Coverity analysis 2018-03-14 22:11:45 +00:00
kgssapi kgssapi: Remove trivial deadcode 2018-02-14 00:12:03 +00:00
libkern iconv uses strlen directly on user supplied memory 2018-02-26 18:23:36 +00:00
mips MIPS: Implement fue*word* and casueword* in assembly. 2018-03-12 22:10:06 +00:00
modules Fix FSACTL_GET_NEXT_ADAPTER_FIB under 32-bit compat. 2018-03-14 21:11:41 +00:00
net Define ethernet type 0x88A8 as ETHERTYPE_QINQ. 2018-03-06 12:01:31 +00:00
net80211 net80211: wrap protection frame allocation into ieee80211_alloc_prot() 2018-03-09 11:33:56 +00:00
netgraph Correct pseudo misspelling in sys/ comments 2018-02-23 18:15:50 +00:00
netinet Update tcp_lro with tested bugfixes from Netflix and LLNW: 2018-03-09 00:08:43 +00:00
netinet6 Update the MTU in affected routes when IPv6 RA changes the MTU 2018-02-12 19:49:20 +00:00
netipsec Rework key_sendup_mbuf() a bit: 2018-03-11 19:14:01 +00:00
netpfil Do not try to reassemble IPv6 fragments in "reass" rule. 2018-03-12 09:40:46 +00:00
netsmb
nfs Modernize nfssvc(2) registartion. 2018-02-08 20:09:42 +00:00
nfsclient
nfsserver
nlm Use syscall_helper_register() to register syscalls and initialize though 2018-02-10 01:09:22 +00:00
ofed Make sure VNET is set when calling sa6_recoverscope() in ibcore. 2018-03-07 13:32:52 +00:00
opencrypto
powerpc Reverting r330925 for now 2018-03-15 06:19:45 +00:00
riscv Unify bulk free operations in several pmaps. 2018-03-04 20:53:20 +00:00
rpc
security mac_portacl(4): stop panicing INVARIANTS-enabled kernel by loading .ko 2018-02-25 23:10:13 +00:00
sparc64 amd64: Protect the kernel text, data, and BSS by setting the RW/NX bits 2018-03-06 14:28:37 +00:00
sys Fix FSACTL_GET_NEXT_ADAPTER_FIB under 32-bit compat. 2018-03-14 21:11:41 +00:00
teken
tests
tools
ufs This change is some refactoring of Mark Johnston's changes in r329375 2018-03-02 04:34:53 +00:00
vm Revert the chunk from r330410 in vm_page_reclaim_run(). 2018-03-13 18:27:23 +00:00
x86 at_rtc: check in ACPI FADT boot flags if the RTC is present 2018-03-13 09:42:33 +00:00
xdr
xen
Makefile