Skip to content

Commit

Permalink
Revert openzfs#3464 changes that crept into openzfs#2882 commit
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Yao <[email protected]>
  • Loading branch information
ryao committed Aug 14, 2013
1 parent ede88bc commit bd06e62
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 32 deletions.
4 changes: 2 additions & 2 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ zfs_do_destroy(int argc, char **argv)
{
destroy_cbdata_t cb = { 0 };
int c;
zfs_handle_t *zhp = NULL;
zfs_handle_t *zhp;
char *at;
zfs_type_t type = ZFS_TYPE_DATASET;

Expand Down Expand Up @@ -1247,7 +1247,7 @@ zfs_do_destroy(int argc, char **argv)
if (cb.cb_doclones)
err = destroy_clones(&cb);
if (err == 0) {
err = zfs_destroy_snaps_nvl(g_zfs, cb.cb_nvl,
err = zfs_destroy_snaps_nvl(zhp, cb.cb_nvl,
cb.cb_defer_destroy);
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/libzfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
extern int zfs_create_ancestors(libzfs_handle_t *, const char *);
extern int zfs_destroy(zfs_handle_t *, boolean_t);
extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
extern int zfs_destroy_snaps_nvl(libzfs_handle_t *, nvlist_t *, boolean_t);
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_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps,
Expand Down
54 changes: 25 additions & 29 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -3189,50 +3189,46 @@ zfs_destroy_snaps(zfs_handle_t *zhp, char *snapname, boolean_t defer)
dgettext(TEXT_DOMAIN, "cannot destroy '%s@%s'"),
zhp->zfs_name, snapname);
} else {
ret = zfs_destroy_snaps_nvl(zhp->zfs_hdl, dd.nvl, defer);
ret = zfs_destroy_snaps_nvl(zhp, dd.nvl, defer);
}
nvlist_free(dd.nvl);
return (ret);
}

/*
* Destroys all the snapshots named in the nvlist.
* Destroys all the snapshots named in the nvlist. They must be underneath
* the zhp (either snapshots of it, or snapshots of its descendants).
*/
int
zfs_destroy_snaps_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, boolean_t defer)
zfs_destroy_snaps_nvl(zfs_handle_t *zhp, nvlist_t *snaps, boolean_t defer)
{
int ret;
nvlist_t *errlist;
nvpair_t *pair;

ret = lzc_destroy_snaps(snaps, defer, &errlist);

if (ret == 0)
return (0);

if (nvlist_next_nvpair(errlist, NULL) == NULL) {
char errbuf[1024];
(void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN, "cannot destroy snapshots"));

ret = zfs_standard_error(hdl, ret, errbuf);
}
for (pair = nvlist_next_nvpair(errlist, NULL);
pair != NULL; pair = nvlist_next_nvpair(errlist, pair)) {
char errbuf[1024];
(void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN, "cannot destroy snapshot %s"),
nvpair_name(pair));
if (ret != 0) {
nvpair_t *pair;
for (pair = nvlist_next_nvpair(errlist, NULL);
pair != NULL; pair = nvlist_next_nvpair(errlist, pair)) {
char errbuf[1024];
(void) snprintf(errbuf, sizeof (errbuf),
dgettext(TEXT_DOMAIN, "cannot destroy snapshot %s"),
nvpair_name(pair));

switch (fnvpair_value_int32(pair)) {
case EEXIST:
zfs_error_aux(hdl,
dgettext(TEXT_DOMAIN, "snapshot is cloned"));
ret = zfs_error(hdl, EZFS_EXISTS, errbuf);
break;
default:
ret = zfs_standard_error(hdl, errno, errbuf);
break;
switch (fnvpair_value_int32(pair)) {
case EEXIST:
zfs_error_aux(zhp->zfs_hdl,
dgettext(TEXT_DOMAIN,
"snapshot is cloned"));
ret = zfs_error(zhp->zfs_hdl, EZFS_EXISTS,
errbuf);
break;
default:
ret = zfs_standard_error(zhp->zfs_hdl, errno,
errbuf);
break;
}
}
}

Expand Down

0 comments on commit bd06e62

Please sign in to comment.