freebsd-dev/sys/compat/linux
Konstantin Belousov 78022527bb Switch to use shared vnode locks for text files during image activation.
kern_execve() locks text vnode exclusive to be able to set and clear
VV_TEXT flag. VV_TEXT is mutually exclusive with the v_writecount > 0
condition.

The change removes VV_TEXT, replacing it with the condition
v_writecount <= -1, and puts v_writecount under the vnode interlock.
Each text reference decrements v_writecount.  To clear the text
reference when the segment is unmapped, it is recorded in the
vm_map_entry backed by the text file as MAP_ENTRY_VN_TEXT flag, and
v_writecount is incremented on the map entry removal

The operations like VOP_ADD_WRITECOUNT() and VOP_SET_TEXT() check that
v_writecount does not contradict the desired change.  vn_writecheck()
is now racy and its use was eliminated everywhere except access.
Atomic check for writeability and increment of v_writecount is
performed by the VOP.  vn_truncate() now increments v_writecount
around VOP_SETATTR() call, lack of which is arguably a bug on its own.

nullfs bypasses v_writecount to the lower vnode always, so nullfs
vnode has its own v_writecount correct, and lower vnode gets all
references, since object->handle is always lower vnode.

On the text vnode' vm object dealloc, the v_writecount value is reset
to zero, and deadfs vop_unset_text short-circuit the operation.
Reclamation of lowervp always reclaims all nullfs vnodes referencing
lowervp first, so no stray references are left.

Reviewed by:	markj, trasz
Tested by:	mjg, pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 month
Differential revision:	https://reviews.freebsd.org/D19923
2019-05-05 11:20:43 +00:00
..
check_error.d
check_internal_locks.d Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
linux_common.c On amd64 both Linux compat modules, linux.ko and linux64.ko, provide 2018-11-06 13:51:08 +00:00
linux_common.h In order to reduce duplication between MD parts of the Linuxulator 2019-05-03 08:42:49 +00:00
linux_dtrace.h sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
linux_emul.c Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator. 2019-04-30 17:18:05 +00:00
linux_emul.h Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator. 2019-04-30 17:18:05 +00:00
linux_errno.c Share Linux errno table with libsysdecode 2018-03-22 12:58:49 +00:00
linux_errno.inc Create new EINTEGRITY error with message "Integrity check failed". 2019-01-17 06:35:45 +00:00
linux_event.c Pass malloc flags directly through kevent(2) subroutines. 2018-11-24 17:06:01 +00:00
linux_event.h Implement timerfd family syscalls. 2017-02-26 09:48:18 +00:00
linux_file.c Introduce funlinkat syscall that always us to check if we are removing 2019-04-06 09:34:26 +00:00
linux_file.h Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
linux_fork.c Whitespace cleanup (annoying). 2019-03-24 15:08:30 +00:00
linux_futex.c Make timespecadd(3) and friends public 2018-07-30 15:46:40 +00:00
linux_futex.h Fix futexes on i386 after the 4/4G split. 2018-04-24 12:50:21 +00:00
linux_getcwd.c sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
linux_ioctl.c In order to reduce duplication between MD parts of the Linuxulator 2019-05-03 08:42:49 +00:00
linux_ioctl.h On amd64 both Linux compat modules, linux.ko and linux64.ko, provide 2018-11-06 13:51:08 +00:00
linux_ipc64.h Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
linux_ipc.c Linux between 4.18 and 5.0 split IPC system calls. 2019-03-24 14:44:35 +00:00
linux_ipc.h Update syscall.master to 5.0. 2019-03-24 14:50:02 +00:00
linux_mib.c Fix the Linux kernel version number calculation 2018-06-22 00:02:03 +00:00
linux_mib.h Rationalize license text on Linuxolator files 2018-03-23 14:39:34 +00:00
linux_misc.c Switch to use shared vnode locks for text files during image activation. 2019-05-05 11:20:43 +00:00
linux_misc.h Rationalize license text on Linuxolator files 2018-03-23 14:39:34 +00:00
linux_mmap.c Eliminate the overhead of gratuitous repeated reinitialization of cap_rights 2018-05-09 18:47:24 +00:00
linux_mmap.h Fix a copy/paste bug introduced during X86_64 Linuxulator work. 2016-07-10 08:22:04 +00:00
linux_persona.h Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
linux_signal.c Linuxulator: apply style(9) to return 2018-03-12 15:35:24 +00:00
linux_signal.h Rationalize license text on Linuxolator files 2018-03-23 14:39:34 +00:00
linux_socket.c Specify the correct option level when emulating SO_PEERCRED. 2019-01-08 17:21:59 +00:00
linux_socket.h Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
linux_stats.c linuxulator: do not include legacy syscalls on arm64 2018-06-15 14:41:51 +00:00
linux_sysctl.c Quiet unused fn warning for linuxulator w/o legacy syscalls 2018-06-25 19:24:50 +00:00
linux_sysproto.h sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
linux_time.c Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
linux_timer.c Return EINVAL in case of incorrect sigev_signo value specified instead of panicing. 2015-12-26 09:09:49 +00:00
linux_timer.h Use the kern_clock_nanosleep() to implement Linux clock_nanosleep() with 2017-04-02 18:16:00 +00:00
linux_uid16.c Remove unused argument to priv_check_cred. 2018-12-11 19:32:16 +00:00
linux_util.c Move most of the contents of opt_compat.h to opt_global.h. 2018-04-06 17:35:35 +00:00
linux_util.h Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
linux_vdso.c Avoid using [LINUX_]SHAREDPAGE constant directly in the vdso code. 2017-07-30 21:24:20 +00:00
linux_vdso.h Avoid using [LINUX_]SHAREDPAGE constant directly in the vdso code. 2017-07-30 21:24:20 +00:00
linux_videodev2_compat.h
linux_videodev_compat.h
linux.c In order to reduce duplication between MD parts of the Linuxulator 2019-05-03 08:42:49 +00:00
linux.h In order to reduce duplication between MD parts of the Linuxulator 2019-05-03 08:42:49 +00:00
stats_timing.d Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00
trace_futexes.d Linuxolator whitespace cleanup 2018-02-05 17:29:12 +00:00