aboutsummaryrefslogtreecommitdiff
path: root/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2020-12-01 15:15:18 +0000
committerEd Maste <emaste@FreeBSD.org>2021-01-29 01:14:30 +0000
commit545f860883cf02fc152696186436ffe6adf8f1a7 (patch)
tree8107b3f7bd37cc62757e456e034ebb925299355f /cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
parente682b62c96e94c60d830e4414215032e0d4f8dad (diff)
downloadsrc-545f860883cf02fc152696186436ffe6adf8f1a7.tar.gz
src-545f860883cf02fc152696186436ffe6adf8f1a7.zip
Fix error merging r354116 from OpenZFS
When we merged 4c0883fb4af0d5565459099b98fcf90ecbfa1ca1 from OpenZFS (svn r354116), there were some merge conflicts. One of those was resolved incorrectly, causing "zfs receive" to fail to delete snapshots that a "zfs send -R" stream has deleted. This change corrects that merge conflict, and also reduces some harmless diffs vis-a-vis OpenZFS that were also introduced by the same revision. Direct commit to stable/12 because head has moved on to OpenZFS. PR: 249438 Reported by: Dmitry Wagin <dmitry.wagin@ya.ru> Reviewed by: mmacy Sponsored by: Axcient (cherry picked from commit 861515418ac385f4198c38c28f6203135d72e651) Approved by: so
Diffstat (limited to 'cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c')
-rw-r--r--cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
index bfb7f3923cfc..2a55ca402a02 100644
--- a/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
+++ b/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
@@ -613,8 +613,8 @@ typedef struct send_data {
const char *fromsnap;
const char *tosnap;
boolean_t recursive;
- boolean_t verbose;
boolean_t replicate;
+ boolean_t verbose;
/*
* The header nvlist is of the following format:
@@ -848,36 +848,36 @@ send_iterate_fs(zfs_handle_t *zhp, void *arg)
rv = -1;
goto out;
}
- VERIFY(0 == nvlist_add_uint64(nvfs, "origin",
- origin->zfs_dmustats.dds_guid));
+ fnvlist_add_uint64(nvfs, "origin",
+ origin->zfs_dmustats.dds_guid);
}
/* iterate over props */
- VERIFY(0 == nvlist_alloc(&nv, NV_UNIQUE_NAME, 0));
+ nv = fnvlist_alloc();
send_iterate_prop(zhp, nv);
- VERIFY(0 == nvlist_add_nvlist(nvfs, "props", nv));
- nvlist_free(nv);
+ fnvlist_add_nvlist(nvfs, "props", nv);
+ fnvlist_free(nv);
/* iterate over snaps, and set sd->parent_fromsnap_guid */
+ sd->parent_fromsnap_guid = 0;
+ sd->parent_snaps = fnvlist_alloc();
+ sd->snapprops = fnvlist_alloc();
if (!sd->replicate && fromsnap_txg != 0)
min_txg = fromsnap_txg;
if (!sd->replicate && tosnap_txg != 0)
max_txg = tosnap_txg;
- sd->parent_fromsnap_guid = 0;
- VERIFY(0 == nvlist_alloc(&sd->parent_snaps, NV_UNIQUE_NAME, 0));
- VERIFY(0 == nvlist_alloc(&sd->snapprops, NV_UNIQUE_NAME, 0));
(void) zfs_iter_snapshots_sorted(zhp, send_iterate_snap, sd,
min_txg, max_txg);
- VERIFY(0 == nvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps));
- VERIFY(0 == nvlist_add_nvlist(nvfs, "snapprops", sd->snapprops));
+ fnvlist_add_nvlist(nvfs, "snaps", sd->parent_snaps);
+ fnvlist_add_nvlist(nvfs, "snapprops", sd->snapprops);
fnvlist_free(sd->parent_snaps);
fnvlist_free(sd->snapprops);
/* add this fs to nvlist */
(void) snprintf(guidstring, sizeof (guidstring),
"0x%llx", (longlong_t)guid);
- VERIFY(0 == nvlist_add_nvlist(sd->fss, guidstring, nvfs));
- nvlist_free(nvfs);
+ fnvlist_add_nvlist(sd->fss, guidstring, nvfs);
+ fnvlist_free(nvfs);
/* iterate over children */
if (sd->recursive)
@@ -894,13 +894,12 @@ out:
static int
gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap,
- const char *tosnap, boolean_t recursive, boolean_t verbose,
- boolean_t replicate, nvlist_t **nvlp, avl_tree_t **avlp)
+ const char *tosnap, boolean_t recursive, boolean_t replicate,
+ boolean_t verbose, nvlist_t **nvlp, avl_tree_t **avlp)
{
zfs_handle_t *zhp;
- int error;
- uint64_t min_txg = 0, max_txg = 0;
send_data_t sd = { 0 };
+ int error;
zhp = zfs_open(hdl, fsname, ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME);
if (zhp == NULL)
@@ -911,8 +910,8 @@ gather_nvlist(libzfs_handle_t *hdl, const char *fsname, const char *fromsnap,
sd.fromsnap = fromsnap;
sd.tosnap = tosnap;
sd.recursive = recursive;
- sd.verbose = verbose;
sd.replicate = replicate;
+ sd.verbose = verbose;
if ((error = send_iterate_fs(zhp, &sd)) != 0) {
nvlist_free(sd.fss);
@@ -1349,10 +1348,10 @@ static int
dump_filesystem(zfs_handle_t *zhp, void *arg)
{
int rv = 0;
- uint64_t min_txg = 0, max_txg = 0;
send_dump_data_t *sdd = arg;
boolean_t missingfrom = B_FALSE;
zfs_cmd_t zc = { 0 };
+ uint64_t min_txg = 0, max_txg = 0;
(void) snprintf(zc.zc_name, sizeof (zc.zc_name), "%s@%s",
zhp->zfs_name, sdd->tosnap);
@@ -1853,8 +1852,8 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
}
err = gather_nvlist(zhp->zfs_hdl, zhp->zfs_name,
- fromsnap, tosnap, flags->replicate, flags->verbose,
- flags->replicate, &fss, &fsavl);
+ fromsnap, tosnap, flags->replicate,
+ flags->replicate, flags->verbose, &fss, &fsavl);
if (err)
goto err_out;
VERIFY(0 == nvlist_add_nvlist(hdrnv, "fss", fss));
@@ -2497,7 +2496,7 @@ again:
VERIFY(0 == nvlist_alloc(&deleted, NV_UNIQUE_NAME, 0));
if ((error = gather_nvlist(hdl, tofs, fromsnap, NULL,
- recursive, B_FALSE, B_FALSE, &local_nv, &local_avl)) != 0)
+ recursive, recursive, B_FALSE, &local_nv, &local_avl)) != 0)
return (error);
/*