zfs clone should not mount the clone if canmount == noauto
Creation of a new filesystem does not imply an intent to mount it.
Since canmount property is not inherited and its default value is 'on',
the only scenario where this matters is zfs clone -o canmount=noauto.
zfs create -o canmount=noauto already does not mount the new filesystem.
Also see:
https://www.illumos.org/issues/5984
https://reviews.csiden.org/r/228/
dd0e0e69f5
https://github.com/zfsonlinux/zfs/issues/2241
Reviewed by: mahrens
MFC after: 8 days
Sponsored by: ClusterHQ
This commit is contained in:
parent
01628dbd09
commit
a565264d3c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=284309
@ -592,6 +592,17 @@ finish_progress(char *done)
|
|||||||
pt_header = NULL;
|
pt_header = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check if the dataset is mountable and should be automatically mounted.
|
||||||
|
*/
|
||||||
|
static boolean_t
|
||||||
|
should_auto_mount(zfs_handle_t *zhp)
|
||||||
|
{
|
||||||
|
if (!zfs_prop_valid_for_type(ZFS_PROP_CANMOUNT, zfs_get_type(zhp)))
|
||||||
|
return (B_FALSE);
|
||||||
|
return (zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_ON);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* zfs clone [-p] [-o prop=value] ... <snap> <fs | vol>
|
* zfs clone [-p] [-o prop=value] ... <snap> <fs | vol>
|
||||||
*
|
*
|
||||||
@ -677,9 +688,22 @@ zfs_do_clone(int argc, char **argv)
|
|||||||
|
|
||||||
clone = zfs_open(g_zfs, argv[1], ZFS_TYPE_DATASET);
|
clone = zfs_open(g_zfs, argv[1], ZFS_TYPE_DATASET);
|
||||||
if (clone != NULL) {
|
if (clone != NULL) {
|
||||||
if (zfs_get_type(clone) != ZFS_TYPE_VOLUME)
|
/*
|
||||||
if ((ret = zfs_mount(clone, NULL, 0)) == 0)
|
* If the user doesn't want the dataset
|
||||||
ret = zfs_share(clone);
|
* automatically mounted, then skip the mount/share
|
||||||
|
* step.
|
||||||
|
*/
|
||||||
|
if (should_auto_mount(clone)) {
|
||||||
|
if ((ret = zfs_mount(clone, NULL, 0)) != 0) {
|
||||||
|
(void) fprintf(stderr, gettext("clone "
|
||||||
|
"successfully created, "
|
||||||
|
"but not mounted\n"));
|
||||||
|
} else if ((ret = zfs_share(clone)) != 0) {
|
||||||
|
(void) fprintf(stderr, gettext("clone "
|
||||||
|
"successfully created, "
|
||||||
|
"but not shared\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
zfs_close(clone);
|
zfs_close(clone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -728,7 +752,6 @@ zfs_do_create(int argc, char **argv)
|
|||||||
int ret = 1;
|
int ret = 1;
|
||||||
nvlist_t *props;
|
nvlist_t *props;
|
||||||
uint64_t intval;
|
uint64_t intval;
|
||||||
int canmount = ZFS_CANMOUNT_OFF;
|
|
||||||
|
|
||||||
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0)
|
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0)
|
||||||
nomem();
|
nomem();
|
||||||
@ -868,19 +891,15 @@ zfs_do_create(int argc, char **argv)
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
/*
|
|
||||||
* if the user doesn't want the dataset automatically mounted,
|
|
||||||
* then skip the mount/share step
|
|
||||||
*/
|
|
||||||
if (zfs_prop_valid_for_type(ZFS_PROP_CANMOUNT, type))
|
|
||||||
canmount = zfs_prop_get_int(zhp, ZFS_PROP_CANMOUNT);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mount and/or share the new filesystem as appropriate. We provide a
|
* Mount and/or share the new filesystem as appropriate. We provide a
|
||||||
* verbose error message to let the user know that their filesystem was
|
* verbose error message to let the user know that their filesystem was
|
||||||
* in fact created, even if we failed to mount or share it.
|
* in fact created, even if we failed to mount or share it.
|
||||||
|
* If the user doesn't want the dataset automatically mounted,
|
||||||
|
* then skip the mount/share step altogether.
|
||||||
*/
|
*/
|
||||||
if (!nomount && canmount == ZFS_CANMOUNT_ON) {
|
if (!nomount && should_auto_mount(zhp)) {
|
||||||
if (zfs_mount(zhp, NULL, 0) != 0) {
|
if (zfs_mount(zhp, NULL, 0) != 0) {
|
||||||
(void) fprintf(stderr, gettext("filesystem "
|
(void) fprintf(stderr, gettext("filesystem "
|
||||||
"successfully created, but not mounted\n"));
|
"successfully created, but not mounted\n"));
|
||||||
|
Loading…
Reference in New Issue
Block a user