This commit is contained in:
Andriy Gapon 2024-07-17 07:18:57 +08:00 committed by GitHub
commit f9a820dbe8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 10 deletions

View File

@ -6549,6 +6549,7 @@ zfs_do_release(int argc, char **argv)
typedef struct holds_cbdata {
boolean_t cb_recursive;
boolean_t cb_all;
const char *cb_snapname;
nvlist_t **cb_nvlp;
size_t cb_max_namelen;
@ -6641,7 +6642,7 @@ holds_callback(zfs_handle_t *zhp, void *data)
return (0);
snapname = delim + 1;
if (strcmp(cbp->cb_snapname, snapname))
if (!cbp->cb_all && strcmp(cbp->cb_snapname, snapname) != 0)
return (0);
}
@ -6724,17 +6725,24 @@ zfs_do_holds(int argc, char **argv)
delim = strchr(snapshot, '@');
if (delim == NULL) {
(void) fprintf(stderr,
gettext("'%s' is not a snapshot\n"), snapshot);
errors = B_TRUE;
continue;
if (!recursive) {
(void) fprintf(stderr,
gettext("'%s' is not a snapshot\n"),
snapshot);
errors = B_TRUE;
continue;
} else {
cb.cb_all = B_TRUE;
cb.cb_snapname = NULL;
}
} else {
snapname = delim + 1;
if (recursive)
snapshot[delim - snapshot] = '\0';
cb.cb_all = B_FALSE;
cb.cb_snapname = snapname;
}
snapname = delim + 1;
if (recursive)
snapshot[delim - snapshot] = '\0';
cb.cb_recursive = recursive;
cb.cb_snapname = snapname;
cb.cb_nvlp = &nvl;
/*

View File

@ -91,6 +91,21 @@ Prints holds timestamps as unix epoch timestamps.
.El
.It Xo
.Nm zfs
.Cm holds
.Fl r
.Op Fl H
.Ar dataset Ns
.Xc
Lists all existing user references for all snapshots of the given datasets and
their descendants.
.Bl -tag -width "-r"
.It Fl r
Recursive operation, mandatory for dataset arguments.
.It Fl H
Do not print headers, use tab-delimited output.
.El
.It Xo
.Nm zfs
.Cm release
.Op Fl r
.Ar tag Ar snapshot Ns