summaryrefslogtreecommitdiff
path: root/usr/src/cmd/zfs/zfs_main.c
diff options
context:
space:
mode:
authorChris Kirby <chris.kirby@sun.com>2009-08-19 11:15:14 -0600
committerChris Kirby <chris.kirby@sun.com>2009-08-19 11:15:14 -0600
commitca45db4129beff691dc46576c328149443788af2 (patch)
tree7aaeee2d1bd6e1d38d7908011ec7feae3be96213 /usr/src/cmd/zfs/zfs_main.c
parent7be238fce69ba74b2163fc0ea898dfdc01a4aa22 (diff)
downloadillumos-gate-ca45db4129beff691dc46576c328149443788af2.tar.gz
6833815 scheduled snapshots deleted per snapshot policy can lead to replication failures
Diffstat (limited to 'usr/src/cmd/zfs/zfs_main.c')
-rw-r--r--usr/src/cmd/zfs/zfs_main.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/usr/src/cmd/zfs/zfs_main.c b/usr/src/cmd/zfs/zfs_main.c
index 1fbd8bc65b..a947413159 100644
--- a/usr/src/cmd/zfs/zfs_main.c
+++ b/usr/src/cmd/zfs/zfs_main.c
@@ -2681,15 +2681,19 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)
int i;
const char *tag;
boolean_t recursive = B_FALSE;
+ boolean_t temphold = B_FALSE;
+ const char *opts = holding ? "rt" : "r";
int c;
- int (*func)(zfs_handle_t *, const char *, const char *, boolean_t);
/* check options */
- while ((c = getopt(argc, argv, "r")) != -1) {
+ while ((c = getopt(argc, argv, opts)) != -1) {
switch (c) {
case 'r':
recursive = B_TRUE;
break;
+ case 't':
+ temphold = B_TRUE;
+ break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
@@ -2708,16 +2712,10 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)
--argc;
++argv;
- if (holding) {
- if (tag[0] == '.') {
- /* tags starting with '.' are reserved for libzfs */
- (void) fprintf(stderr,
- gettext("tag may not start with '.'\n"));
- usage(B_FALSE);
- }
- func = zfs_hold;
- } else {
- func = zfs_release;
+ if (holding && tag[0] == '.') {
+ /* tags starting with '.' are reserved for libzfs */
+ (void) fprintf(stderr, gettext("tag may not start with '.'\n"));
+ usage(B_FALSE);
}
for (i = 0; i < argc; ++i) {
@@ -2742,8 +2740,14 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)
++errors;
continue;
}
- if (func(zhp, delim+1, tag, recursive) != 0)
- ++errors;
+ if (holding) {
+ if (zfs_hold(zhp, delim+1, tag, recursive,
+ temphold) != 0)
+ ++errors;
+ } else {
+ if (zfs_release(zhp, delim+1, tag, recursive) != 0)
+ ++errors;
+ }
zfs_close(zhp);
}
@@ -2751,9 +2755,10 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)
}
/*
- * zfs hold [-r] <tag> <snap> ...
+ * zfs hold [-r] [-t] <tag> <snap> ...
*
* -r Recursively hold
+ * -t Temporary hold (hidden option)
*
* Apply a user-hold with the given tag to the list of snapshots.
*/