diff options
author | Eric Schrock <Eric.Schrock@delphix.com> | 2012-04-27 11:14:46 -0700 |
---|---|---|
committer | Eric Schrock <Eric.Schrock@delphix.com> | 2012-04-27 11:14:46 -0700 |
commit | 6a9cb0ea17f11529b1bb8ca31944abd37736b99e (patch) | |
tree | c0efe885d4921bc461e7da8edb7e825c38ad5c34 /usr/src | |
parent | 7d7551bcfe5ded1738ddbe3268520996a32023b4 (diff) | |
download | illumos-gate-6a9cb0ea17f11529b1bb8ca31944abd37736b99e.tar.gz |
2635 'zfs rename -f' to perform force unmount
Reviewed by: Matt Ahrens <matt@delphix.com>
Reviewed by: George Wilson <George.Wilson@delphix.com>
Reviewed by: Bill Pijewski <wdp@joyent.com>
Reviewed by: Richard Elling <richard.elling@richardelling.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/zfs/zfs_main.c | 18 | ||||
-rw-r--r-- | usr/src/cmd/zoneadm/zfs.c | 3 | ||||
-rw-r--r-- | usr/src/lib/libbe/common/be_rename.c | 3 | ||||
-rw-r--r-- | usr/src/lib/libzfs/common/libzfs.h | 2 | ||||
-rw-r--r-- | usr/src/lib/libzfs/common/libzfs_dataset.c | 6 | ||||
-rw-r--r-- | usr/src/man/man1m/zfs.1m | 20 |
6 files changed, 35 insertions, 17 deletions
diff --git a/usr/src/cmd/zfs/zfs_main.c b/usr/src/cmd/zfs/zfs_main.c index 1fa16f0574..3fda39150e 100644 --- a/usr/src/cmd/zfs/zfs_main.c +++ b/usr/src/cmd/zfs/zfs_main.c @@ -22,7 +22,7 @@ /* * 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 2012 Milan Jurik. All rights reserved. */ @@ -242,9 +242,9 @@ 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>")); case HELP_ROLLBACK: return (gettext("\trollback [-rRf] <snapshot>\n")); @@ -3043,8 +3043,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> * * Renames the given dataset to another of the same type. @@ -3060,9 +3060,10 @@ zfs_do_rename(int argc, char **argv) int ret = 0; boolean_t recurse = B_FALSE; boolean_t parents = B_FALSE; + boolean_t force_unmount = B_FALSE; /* check options */ - while ((c = getopt(argc, argv, "pr")) != -1) { + while ((c = getopt(argc, argv, "prf")) != -1) { switch (c) { case 'p': parents = B_TRUE; @@ -3070,6 +3071,9 @@ zfs_do_rename(int argc, char **argv) case 'r': recurse = B_TRUE; break; + case 'f': + force_unmount = B_TRUE; + break; case '?': default: (void) fprintf(stderr, gettext("invalid option '%c'\n"), @@ -3120,7 +3124,7 @@ zfs_do_rename(int argc, char **argv) return (1); } - ret = (zfs_rename(zhp, argv[1], recurse) != 0); + ret = (zfs_rename(zhp, argv[1], recurse, force_unmount) != 0); zfs_close(zhp); return (ret); diff --git a/usr/src/cmd/zoneadm/zfs.c b/usr/src/cmd/zoneadm/zfs.c index 8966023ebe..78c4583465 100644 --- a/usr/src/cmd/zoneadm/zfs.c +++ b/usr/src/cmd/zoneadm/zfs.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ /* @@ -723,7 +724,7 @@ rename_snap(zfs_handle_t *zhp, void *data) (void) snprintf(template, sizeof (template), "%s%d", cbp->match_name, cbp->max++); - res = (zfs_rename(zhp, template, B_FALSE) != 0); + res = (zfs_rename(zhp, template, B_FALSE, B_FALSE) != 0); if (res != 0) (void) fprintf(stderr, gettext("failed to rename snapshot %s " "to %s: %s\n"), zfs_get_name(zhp), template, diff --git a/usr/src/lib/libbe/common/be_rename.c b/usr/src/lib/libbe/common/be_rename.c index 1439424d13..dee131834c 100644 --- a/usr/src/lib/libbe/common/be_rename.c +++ b/usr/src/lib/libbe/common/be_rename.c @@ -21,6 +21,7 @@ /* * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012 by Delphix. All rights reserved. */ #include <assert.h> @@ -175,7 +176,7 @@ be_rename(nvlist_t *be_attrs) } /* Rename of BE's root dataset. */ - if (zfs_rename(zhp, bt.nbe_root_ds, B_FALSE) != 0) { + if (zfs_rename(zhp, bt.nbe_root_ds, B_FALSE, B_FALSE) != 0) { be_print_err(gettext("be_rename: failed to " "rename dataset (%s): %s\n"), bt.obe_root_ds, libzfs_error_description(g_zfs)); diff --git a/usr/src/lib/libzfs/common/libzfs.h b/usr/src/lib/libzfs/common/libzfs.h index 4fa1f441f3..ccdbf9b4e2 100644 --- a/usr/src/lib/libzfs/common/libzfs.h +++ b/usr/src/lib/libzfs/common/libzfs.h @@ -531,7 +531,7 @@ extern int zfs_destroy_snaps_nvl(zfs_handle_t *, nvlist_t *, boolean_t); extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *); extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *); extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t); -extern int zfs_rename(zfs_handle_t *, const char *, boolean_t); +extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t); typedef struct sendflags { /* print informational messages (ie, -v was specified) */ diff --git a/usr/src/lib/libzfs/common/libzfs_dataset.c b/usr/src/lib/libzfs/common/libzfs_dataset.c index 86b24bb7e1..43d71a465e 100644 --- a/usr/src/lib/libzfs/common/libzfs_dataset.c +++ b/usr/src/lib/libzfs/common/libzfs_dataset.c @@ -3546,7 +3546,8 @@ zfs_rollback(zfs_handle_t *zhp, zfs_handle_t *snap, boolean_t force) * Renames the given dataset. */ int -zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive) +zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive, + boolean_t force_unmount) { int ret; zfs_cmd_t zc = { 0 }; @@ -3658,7 +3659,8 @@ zfs_rename(zfs_handle_t *zhp, const char *target, boolean_t recursive) } } else { - if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, 0, 0)) == NULL) + if ((cl = changelist_gather(zhp, ZFS_PROP_NAME, 0, + force_unmount ? MS_FORCE : 0)) == NULL) return (-1); if (changelist_haszonedchild(cl)) { diff --git a/usr/src/man/man1m/zfs.1m b/usr/src/man/man1m/zfs.1m index 60dc80a0b5..a50a8c82e3 100644 --- a/usr/src/man/man1m/zfs.1m +++ b/usr/src/man/man1m/zfs.1m @@ -1,6 +1,6 @@ '\" te .\" Copyright (c) 2009 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. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. .\" See the License for the specific language governing permissions and limitations under the License. When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with @@ -58,13 +58,13 @@ zfs \- configures ZFS file systems .LP .nf -\fBzfs\fR \fBrename\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR +\fBzfs\fR \fBrename\fR [\fB-f\fR] \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR .fi .LP .nf -\fBzfs\fR \fBrename\fR [\fB-p\fR] \fIfilesystem\fR|\fIvolume\fR \fIfilesystem\fR|\fIvolume\fR +\fBzfs\fR \fBrename\fR [\fB-fp\fR] \fIfilesystem\fR|\fIvolume\fR \fIfilesystem\fR|\fIvolume\fR .fi .LP @@ -1979,7 +1979,7 @@ any conflicting snapshots. .sp .ne 2 .na -\fB\fBzfs rename\fR \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR\fR +\fB\fBzfs rename\fR [\fB-f\fR] \fIfilesystem\fR|\fIvolume\fR|\fIsnapshot\fR\fR .ad .br .na @@ -1987,7 +1987,7 @@ any conflicting snapshots. .ad .br .na -\fB\fBzfs rename\fR [\fB-p\fR] \fIfilesystem\fR|\fIvolume\fR +\fB\fBzfs rename\fR [\fB-fp\fR] \fIfilesystem\fR|\fIvolume\fR \fIfilesystem\fR|\fIvolume\fR\fR .ad .sp .6 @@ -2010,6 +2010,16 @@ are automatically mounted according to the \fBmountpoint\fR property inherited from their parent. .RE +.sp +.ne 2 +.na +\fB\fB-f\fR\fR +.ad +.sp .6 +.RS 4n +Force unmount any filesystems that need to be unmounted in the process. +.RE + .RE .sp |