mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
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
This commit is contained in:
parent
9846ab4ed2
commit
7538677f35
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=235216
@ -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
|
||||
|
@ -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"),
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user