From owner-freebsd-fs@FreeBSD.ORG Tue Jun 12 05:40:08 2012 Return-Path: Delivered-To: freebsd-fs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A18A3106566B for ; Tue, 12 Jun 2012 05:40:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 823358FC21 for ; Tue, 12 Jun 2012 05:40:08 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q5C5e8Cx017072 for ; Tue, 12 Jun 2012 05:40:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q5C5e8Bc017067; Tue, 12 Jun 2012 05:40:08 GMT (envelope-from gnats) Date: Tue, 12 Jun 2012 05:40:08 GMT Message-Id: <201206120540.q5C5e8Bc017067@freefall.freebsd.org> To: freebsd-fs@FreeBSD.org From: Bryan Drewery Cc: Subject: Re: kern/167905: [zfs] zfs set canmount=on UNMOUNTS dataset X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Bryan Drewery List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2012 05:40:08 -0000 The following reply was made to PR kern/167905; it has been noted by GNATS. From: Bryan Drewery To: bug-followup@FreeBSD.org, vermaden@interia.pl Cc: Pawel Jakub Dawidek , mm@freebsd.org Subject: Re: kern/167905: [zfs] zfs set canmount=on UNMOUNTS dataset Date: Tue, 12 Jun 2012 00:35:58 -0500 This is a multi-part message in MIME format. --------------040108060500020307070404 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Attached is a patch to fix setting 'zfs set canmount=on' to not cause a remount if the dataset is *already mounted*. This fixes the issue reported here, as well as here http://lists.freebsd.org/pipermail/freebsd-fs/2012-May/014241.html $ cd /usr/src/cddl $ patch -p1 < patch-zfs-dataset-canmount-on.txt $ make obj depend all install The change adds to the complex condition as I did not want to refactor it too much given the unclear "contrib" status of the code. Also attached is a test script to see the functionality before and after. I did some research and neither OpenIndiana/Illumos nor ZfsOnLinux have addressed this issue. Not sure the proper way to share or report this "upstream" currently. Regards, Bryan Drewery --------------040108060500020307070404 Content-Type: text/plain; charset=windows-1252; name="patch-zfs-dataset-canmount-on.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch-zfs-dataset-canmount-on.txt" --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c.orig 2012-06-12 00:10:11.000000000 -0500 +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c 2012-06-12 00:17:34.000000000 -0500 @@ -1467,11 +1467,12 @@ /* * If the dataset's canmount property is being set to noauto, + * or to on and already mounted, * then we want to prevent unmounting & remounting it. */ do_prefix = !((prop == ZFS_PROP_CANMOUNT) && (zprop_string_to_index(prop, propval, &idx, - ZFS_TYPE_DATASET) == 0) && (idx == ZFS_CANMOUNT_NOAUTO)); + ZFS_TYPE_DATASET) == 0) && (idx == ZFS_CANMOUNT_NOAUTO || (idx == ZFS_CANMOUNT_ON && zfs_is_mounted(zhp, NULL)))); if (do_prefix && (ret = changelist_prefix(cl)) != 0) goto error; --------------040108060500020307070404 Content-Type: text/plain; charset=windows-1252; name="test-zsh.sh" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test-zsh.sh" #! /bin/sh set -e cleanup() { test -z "${PASS}" && echo "FAILED" cd / zpool destroy zpool mdconfig -d -u 0 mdconfig -d -u 1 } run() { echo "$@" "$@" return $? } trap cleanup SIGINT SIGTERM SIGKILL EXIT rm -rf /tmp/test mdconfig -a -t swap -s 128M -u 0 mdconfig -a -t swap -s 128M -u 1 zpool create zpool mirror md0 md1 zfs create -o mountpoint=/tmp/test -o canmount=on zpool/test cd /tmp/test # This fails even though the property is not changing and dataset is already mounted run zfs set canmount=on zpool/test # Currently works run zfs set canmount=noauto zpool/test # Expect this to try to unmount and fail, may warrant more discussion #run zfs set canmount=off zpool/test # This fails even though the property is not changing and dataset is already mounted run zfs set canmount=on zpool/test echo "PASS" PASS=1 --------------040108060500020307070404--