diff options
author | Martin Matuska <[email protected]> | 2013-05-23 13:07:25 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2013-11-04 10:55:25 -0800 |
commit | b1118acbb16ec347f6a3eb091d9b7097d12b8d54 (patch) | |
tree | 34a11d0d8560452756be59a351d5c7ecf8d27b6d /lib/libzfs/libzfs_dataset.c | |
parent | 63fd3c6cfd264cab94dc186fe8cceecac8bc0d50 (diff) |
Illumos #3699, #3739
3699 zfs hold or release of a non-existent snapshot does not output error
3739 cannot set zfs quota or reservation on pool version < 22
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Eric Shrock <[email protected]>
Approved by: Dan McDonald <[email protected]>
References:
https://www.illumos.org/issues/3699
https://www.illumos.org/issues/3739
illumos/illumos-gate@013023d4ed2f6d0cf75380ec686a4aac392b4e43
Ported-by: Richard Yao <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #1775
Diffstat (limited to 'lib/libzfs/libzfs_dataset.c')
-rw-r--r-- | lib/libzfs/libzfs_dataset.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/lib/libzfs/libzfs_dataset.c b/lib/libzfs/libzfs_dataset.c index e2808638e..be23382b5 100644 --- a/lib/libzfs/libzfs_dataset.c +++ b/lib/libzfs/libzfs_dataset.c @@ -25,6 +25,7 @@ * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved. * Copyright (c) 2012 Pawel Jakub Dawidek <[email protected]>. * Copyright 2012 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2013 Martin Matuska. All rights reserved. */ #include <ctype.h> @@ -4455,6 +4456,20 @@ zfs_hold(zfs_handle_t *zhp, const char *snapname, const char *tag, ha.tag = tag; ha.recursive = recursive; (void) zfs_hold_one(zfs_handle_dup(zhp), &ha); + + if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) { + fnvlist_free(ha.nvl); + ret = ENOENT; + if (!enoent_ok) { + (void) snprintf(errbuf, sizeof (errbuf), + dgettext(TEXT_DOMAIN, + "cannot hold snapshot '%s@%s'"), + zhp->zfs_name, snapname); + (void) zfs_standard_error(hdl, ret, errbuf); + } + return (ret); + } + ret = lzc_hold(ha.nvl, cleanup_fd, &errors); fnvlist_free(ha.nvl); @@ -4556,12 +4571,25 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag, nvlist_t *errors; nvpair_t *elem; libzfs_handle_t *hdl = zhp->zfs_hdl; + char errbuf[1024]; ha.nvl = fnvlist_alloc(); ha.snapname = snapname; ha.tag = tag; ha.recursive = recursive; (void) zfs_release_one(zfs_handle_dup(zhp), &ha); + + if (nvlist_next_nvpair(ha.nvl, NULL) == NULL) { + fnvlist_free(ha.nvl); + ret = ENOENT; + (void) snprintf(errbuf, sizeof (errbuf), + dgettext(TEXT_DOMAIN, + "cannot release hold from snapshot '%s@%s'"), + zhp->zfs_name, snapname); + (void) zfs_standard_error(hdl, ret, errbuf); + return (ret); + } + ret = lzc_release(ha.nvl, &errors); fnvlist_free(ha.nvl); @@ -4570,8 +4598,6 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag, if (nvlist_next_nvpair(errors, NULL) == NULL) { /* no hold-specific errors */ - char errbuf[1024]; - (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot release")); switch (errno) { @@ -4588,8 +4614,6 @@ zfs_release(zfs_handle_t *zhp, const char *snapname, const char *tag, for (elem = nvlist_next_nvpair(errors, NULL); elem != NULL; elem = nvlist_next_nvpair(errors, elem)) { - char errbuf[1024]; - (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN, "cannot release hold from snapshot '%s'"), |