zpool_disable_datasets: on Linux, detach mounts when forcing export
On Linux, MNT_FORCE makes the kernel inform that fileystem that its about to call its unmount method so it can begin to eject active IO, making it more likely that the unmount will succeed. This however does not arrange for the unmount method to always succeed; new IO between the two filesystem calls can dirty the filesystem. This is very difficult to lock out properly within ZFS, as not all operations that cause the kernel to dirty the filesystem can easily locked out (eg zfs_lookup). So, we add MNT_DETACH as well. This causes the kernel to first remove the mount from the user namespace, giving the appearance that it has been unmounted (ie no longer appears in /proc/mounts), so that userspace can't reference the filesystem anymore. The unmount then proceeds in the background. Signed-off-by: Rob Norris <rob.norris@klarasystems.com> (cherry picked from commit d2e1634fc935288aa851b5915feaa670c791265c)
This commit is contained in:
parent
40a9efd0e8
commit
7e4a9cbaee
|
@ -1538,6 +1538,10 @@ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force,
|
|||
int ret = -1;
|
||||
int flags = ((hardforce || force) ? MS_FORCE : 0);
|
||||
|
||||
#ifdef __linux__
|
||||
if (hardforce) flags |= MS_DETACH;
|
||||
#endif
|
||||
|
||||
hdl->libzfs_force_export = flags & MS_FORCE;
|
||||
namelen = strlen(zhp->zpool_name);
|
||||
|
||||
|
|
Loading…
Reference in New Issue