svn commit: r235216 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common

Martin Matuska mm at FreeBSD.org
Thu May 10 08:57:59 UTC 2012


Author: mm
Date: Thu May 10 08:57:58 2012
New Revision: 235216
URL: http://svn.freebsd.org/changeset/base/235216

Log:
  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 at FreeBSD.org>
  Obtained from:	illumos (issue #2635)
  MFC after:	1 week

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Thu May 10 08:05:41 2012	(r235215)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8	Thu May 10 08:57:58 2012	(r235216)
@@ -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 at 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 con
 .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

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Thu May 10 08:05:41 2012	(r235215)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Thu May 10 08:57:58 2012	(r235216)
@@ -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 at dawidek.net>.
  * All rights reserved.
- * Copyright (c) 2011 Martin Matuska <mm at FreeBSD.org>. All rights reserved.
+ * Copyright (c) 2012 Martin Matuska <mm at 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"),

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h	Thu May 10 08:05:41 2012	(r235215)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h	Thu May 10 08:57:58 2012	(r235216)
@@ -26,6 +26,7 @@
  * All rights reserved.
  * Copyright (c) 2011 by Delphix. All rights reserved.
  * All rights reserved.
+ * Copyright (c) 2012 Martin Matuska <mm at 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);

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Thu May 10 08:05:41 2012	(r235215)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Thu May 10 08:57:58 2012	(r235216)
@@ -25,6 +25,7 @@
  * Copyright (c) 2011 by Delphix. All rights reserved.
  * Copyright (c) 2011-2012 Pawel Jakub Dawidek <pawel at dawidek.net>.
  * All rights reserved.
+ * Copyright (c) 2012 Martin Matuska <mm at FreeBSD.org>. All rights reserved.
  */
 
 #include <ctype.h>
@@ -3721,7 +3722,8 @@ zfs_rename(zfs_handle_t *zhp, const char
 
 	} 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);
 		}
 


More information about the svn-src-all mailing list