diff options
author | mm <mm@FreeBSD.org> | 2012-05-10 08:57:58 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2012-05-10 08:57:58 +0000 |
commit | e290b949d0f602e9af6839f2f35666c98b1470b5 (patch) | |
tree | 69c342a520ee7283a86d49dfe4e46a9e7f06ec86 /cddl | |
parent | 10f60d496c9e9392a60ebec9350215094cae9472 (diff) | |
download | FreeBSD-src-e290b949d0f602e9af6839f2f35666c98b1470b5.zip FreeBSD-src-e290b949d0f602e9af6839f2f35666c98b1470b5.tar.gz |
Add support for force unmounting ZFS filesystems during "zfs rename"
with the -f flag.
Reimplementation of the illumos changeset 13677:a0cbef703c12
2635 'zfs rename -f' to perform force unmount
References:
https://www.illumos.org/issues/2635
PR: kern/164447
Suggested by: Marcelo Araujo <araujo@FreeBSD.org>
Obtained from: illumos (issue #2635)
MFC after: 1 week
Diffstat (limited to 'cddl')
-rw-r--r-- | cddl/contrib/opensolaris/cmd/zfs/zfs.8 | 11 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/cmd/zfs/zfs_main.c | 18 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h | 4 | ||||
-rw-r--r-- | cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c | 4 |
4 files changed, 28 insertions, 9 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 index fdbae4e..cfdfab0 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs.8 +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs.8 @@ -18,7 +18,7 @@ .\" information: Portions Copyright [yyyy] [name of copyright owner] .\" .\" Copyright (c) 2010, Sun Microsystems, Inc. All Rights Reserved. -.\" Copyright (c) 2011 by Delphix. All rights reserved. +.\" Copyright (c) 2012 by Delphix. All rights reserved. .\" Copyright (c) 2012 Nexenta Systems, Inc. All Rights Reserved. .\" Copyright (c) 2011, Pawel Jakub Dawidek <pjd@FreeBSD.org> .\" @@ -77,10 +77,12 @@ .Ar clone-filesystem .Nm .Cm rename +.Op Fl f .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Nm .Cm rename +.Op Fl f .Fl p .Ar filesystem Ns | Ns Ar volume .Ar filesystem Ns | Ns Ar volume @@ -1646,12 +1648,14 @@ subcommand can be used to rename any conflicting snapshots. .It Xo .Nm .Cm rename +.Op Fl f .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot .Xc .It Xo .Nm .Cm rename +.Op Fl f .Fl p .Ar filesystem Ns | Ns Ar volume .Ar filesystem Ns | Ns Ar volume @@ -1685,6 +1689,11 @@ property is set to or .Cm none , file system is not unmounted even if this option is not given. +.It Fl f +Force unmount any filesystems that need to be unmounted in the process. +This flag has no effect if used together with the +.Fl u +flag. .El .It Xo .Nm diff --git a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c index c322f08..cc20127 100644 --- a/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c +++ b/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c @@ -22,10 +22,10 @@ /* * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2012 Nexenta Systems, Inc. All rights reserved. - * Copyright (c) 2011 by Delphix. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. * Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>. * All rights reserved. - * Copyright (c) 2011 Martin Matuska <mm@FreeBSD.org>. All rights reserved. + * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. */ #include <assert.h> @@ -256,9 +256,10 @@ get_usage(zfs_help_t idx) "snapshot>\n" "\treceive [-vnFu] [-d | -e] <filesystem>\n")); case HELP_RENAME: - return (gettext("\trename <filesystem|volume|snapshot> " + return (gettext("\trename [-f] <filesystem|volume|snapshot> " "<filesystem|volume|snapshot>\n" - "\trename -p <filesystem|volume> <filesystem|volume>\n" + "\trename [-f] -p <filesystem|volume> " + "<filesystem|volume>\n" "\trename -r <snapshot> <snapshot>\n" "\trename -u [-p] <filesystem> <filesystem>")); case HELP_ROLLBACK: @@ -3091,8 +3092,8 @@ zfs_do_list(int argc, char **argv) } /* - * zfs rename <fs | snap | vol> <fs | snap | vol> - * zfs rename -p <fs | vol> <fs | vol> + * zfs rename [-f] <fs | snap | vol> <fs | snap | vol> + * zfs rename [-f] -p <fs | vol> <fs | vol> * zfs rename -r <snap> <snap> * zfs rename -u [-p] <fs> <fs> * @@ -3112,7 +3113,7 @@ zfs_do_rename(int argc, char **argv) boolean_t parents = B_FALSE; /* check options */ - while ((c = getopt(argc, argv, "pru")) != -1) { + while ((c = getopt(argc, argv, "fpru")) != -1) { switch (c) { case 'p': parents = B_TRUE; @@ -3123,6 +3124,9 @@ zfs_do_rename(int argc, char **argv) case 'u': flags.nounmount = B_TRUE; break; + case 'f': + flags.forceunmount = B_TRUE; + break; case '?': default: (void) fprintf(stderr, gettext("invalid option '%c'\n"), diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h index b11356d..fb9e337 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h @@ -26,6 +26,7 @@ * All rights reserved. * Copyright (c) 2011 by Delphix. All rights reserved. * All rights reserved. + * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. */ #ifndef _LIBZFS_H @@ -541,6 +542,9 @@ typedef struct renameflags { /* don't unmount file systems */ int nounmount : 1; + + /* force unmount file systems */ + int forceunmount : 1; } renameflags_t; extern int zfs_rename(zfs_handle_t *, const char *, renameflags_t flags); diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c index dba47ef..c01cffe 100644 --- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c +++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c @@ -25,6 +25,7 @@ * Copyright (c) 2011 by Delphix. All rights reserved. * Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel@dawidek.net>. * All rights reserved. + * Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved. */ #include <ctype.h> @@ -3721,7 +3722,8 @@ zfs_rename(zfs_handle_t *zhp, const char *target, renameflags_t flags) } else { if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, - flags.nounmount ? CL_GATHER_DONT_UNMOUNT : 0, 0)) == NULL) { + flags.nounmount ? CL_GATHER_DONT_UNMOUNT : 0, + flags.forceunmount ? MS_FORCE : 0)) == NULL) { return (-1); } |