From 3e8d5e4ff3a67fd3eb4d5d8af9370a5133e7dc4e Mon Sep 17 00:00:00 2001 From: Jorgen Lundman Date: Wed, 1 Sep 2021 00:56:00 +0900 Subject: [PATCH] Add zpool_disable_datasets_os() / zfs_unmount_os() zpool_disable_datasets_os(): macOS needs to do a bunch of work to kick everything off zvols. zfs_unmount_os(): This allows us to unmount any zvols that may be mounted. Like with zfs destroy foo/vol Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Jorgen Lundman Closes #12436 --- include/libzfs.h | 4 +++- lib/libzfs/libzfs.abi | 17 +++++++++++++++++ lib/libzfs/libzfs_mount.c | 4 ++++ lib/libzfs/os/freebsd/libzfs_zmount.c | 12 ++++++++++++ lib/libzfs/os/linux/libzfs_mount_os.c | 12 ++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/libzfs.h b/include/libzfs.h index 9ef280636..270f81002 100644 --- a/include/libzfs.h +++ b/include/libzfs.h @@ -839,7 +839,7 @@ _LIBZFS_H int zfs_unmount(zfs_handle_t *, const char *, int); _LIBZFS_H int zfs_unmountall(zfs_handle_t *, int); _LIBZFS_H int zfs_mount_delegation_check(void); -#if defined(__linux__) +#if defined(__linux__) || defined(__APPLE__) _LIBZFS_H int zfs_parse_mount_options(char *mntopts, unsigned long *mntflags, unsigned long *zfsflags, int sloppy, char *badopt, char *mtabopt); _LIBZFS_H void zfs_adjust_mount_options(zfs_handle_t *zhp, const char *mntpoint, @@ -930,6 +930,8 @@ _LIBZFS_H int zfs_smb_acl_rename(libzfs_handle_t *, char *, char *, char *, */ _LIBZFS_H int zpool_enable_datasets(zpool_handle_t *, const char *, int); _LIBZFS_H int zpool_disable_datasets(zpool_handle_t *, boolean_t); +_LIBZFS_H void zpool_disable_datasets_os(zpool_handle_t *, boolean_t); +_LIBZFS_H void zpool_disable_volume_os(const char *); /* * Parse a features file for -o compatibility diff --git a/lib/libzfs/libzfs.abi b/lib/libzfs/libzfs.abi index bb4bde247..4d134a3a0 100644 --- a/lib/libzfs/libzfs.abi +++ b/lib/libzfs/libzfs.abi @@ -230,6 +230,8 @@ + + @@ -2501,6 +2503,9 @@ + + + @@ -2540,6 +2545,9 @@ + + + @@ -3937,6 +3945,15 @@ + + + + + + + + + diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 5729f120e..b0279d8fb 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -672,6 +672,8 @@ zfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags) } } + zpool_disable_volume_os(zhp->zfs_name); + return (0); } @@ -1637,6 +1639,8 @@ zpool_disable_datasets(zpool_handle_t *zhp, boolean_t force) remove_mountpoint(sets[i].dataset); } + zpool_disable_datasets_os(zhp, force); + ret = 0; out: (void) fclose(mnttab); diff --git a/lib/libzfs/os/freebsd/libzfs_zmount.c b/lib/libzfs/os/freebsd/libzfs_zmount.c index 6bc073cb0..12317fdde 100644 --- a/lib/libzfs/os/freebsd/libzfs_zmount.c +++ b/lib/libzfs/os/freebsd/libzfs_zmount.c @@ -133,3 +133,15 @@ zfs_mount_delegation_check(void) { return (0); } + +/* Called from the tail end of zpool_disable_datasets() */ +void +zpool_disable_datasets_os(zpool_handle_t *zhp, boolean_t force) +{ +} + +/* Called from the tail end of zfs_unmount() */ +void +zpool_disable_volume_os(const char *name) +{ +} diff --git a/lib/libzfs/os/linux/libzfs_mount_os.c b/lib/libzfs/os/linux/libzfs_mount_os.c index 42f300b36..29fea736b 100644 --- a/lib/libzfs/os/linux/libzfs_mount_os.c +++ b/lib/libzfs/os/linux/libzfs_mount_os.c @@ -411,3 +411,15 @@ zfs_mount_delegation_check(void) { return ((geteuid() != 0) ? EACCES : 0); } + +/* Called from the tail end of zpool_disable_datasets() */ +void +zpool_disable_datasets_os(zpool_handle_t *zhp, boolean_t force) +{ +} + +/* Called from the tail end of zfs_unmount() */ +void +zpool_disable_volume_os(const char *name) +{ +}