From 5041986419d5eca8cf10dbfb5341d123ec1608a8 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Tue, 22 Nov 2016 11:50:52 +0000 Subject: [PATCH] 6428 set canmount=off on unmounted filesystem tries to unmount children illumos/illumos-gate@c079fa4d202eff15e318131c52755d214ffa2da7 https://github.com/illumos/illumos-gate/commit/c079fa4d202eff15e318131c52755d214ffa2da7 https://www.illumos.org/issues/6428 Scenario: $ zfs create rpool/p $ zfs set canmount=noauto rpool/p $ zfs umount rpool/p $ zfs create rpool/p/c $ zfs get -r mounted,canmount rpool/p NAME PROPERTY VALUE SOURCE rpool/p mounted no - rpool/p canmount noauto local rpool/p/c mounted yes - rpool/p/c canmount on default In another shell ensure that rpool/p/c is in use, for example: $ cd /rpool/p/c Then: $ zfs set canmount=off rpool/p cannot unmount '/rpool/p/c': Device busy But there is no reason to try to unmount rpool/p/c in this scenario. Reviewed by: Matthew Ahrens Approved by: Gordon Ross Author: Andriy Gapon --- lib/libzfs/common/libzfs_dataset.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libzfs/common/libzfs_dataset.c b/lib/libzfs/common/libzfs_dataset.c index aa557ae80b8..7327c299913 100644 --- a/lib/libzfs/common/libzfs_dataset.c +++ b/lib/libzfs/common/libzfs_dataset.c @@ -1597,8 +1597,9 @@ zfs_prop_set_list(zfs_handle_t *zhp, nvlist_t *props) * its canmount property to 'on' or 'noauto'. We only use * the changelist logic to unmount when setting canmount=off. */ - if (!(prop == ZFS_PROP_CANMOUNT && - fnvpair_value_uint64(elem) != ZFS_CANMOUNT_OFF)) { + if (prop != ZFS_PROP_CANMOUNT || + (fnvpair_value_uint64(elem) == ZFS_CANMOUNT_OFF && + zfs_is_mounted(zhp, NULL))) { cls[cl_idx] = changelist_gather(zhp, prop, 0, 0); if (cls[cl_idx] == NULL) goto error;