]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Provide simple mutual exclusion between mount point update and unmount.
authorKonstantin Belousov <kib@FreeBSD.org>
Sun, 13 Nov 2016 21:49:51 +0000 (21:49 +0000)
committerKonstantin Belousov <kib@FreeBSD.org>
Sun, 13 Nov 2016 21:49:51 +0000 (21:49 +0000)
commit714b7df5020eae6168bda2a297037e3523fda3a2
tree1fb8b7f6f1ebe46b90771539ad4b80813637f978
parent9eb8f495b86947b212bafde872be404ac9d621a6
Provide simple mutual exclusion between mount point update and unmount.

Currently mount update keeps vfs_busy(9) reference on the mount point
during MNT_UPDATE VFS_MOUNT() vfsops call.  This already provides the
exclusion, but is problematic for filesystems which need to perform
namei(9) during VFS_MOUNT(MNT_UPDATE) operations, e.g. to refresh
mnt_from path, because namei(9) must not be called while the
vfs_busy(9) reference is owned.

Check for MNT_UPDATE flag before setting MNTK_UNMOUNT, and for
MNTK_UNMOUNT before entering innards of vfs_domount_update(), failing
syscalls with EBUSY if conflict is detected.  Keep vfs_busy(9)
reference around VFS_MOUNT(MNT_UPDATE) calls still to not change VFS
KPI.

In the update path in ffs_mount(), drop vfs_busy() reference around
namei(), which is now safe due to unmount never executing in parallel
with VFS_MOUNT(MNT_UPDATE), and which avoids the deadlock.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
sys/kern/vfs_mount.c
sys/ufs/ffs/ffs_vfsops.c