Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Dec 2020 15:15:19 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r368233 - in stable/12: cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/uts/common/sys/fs
Message-ID:  <202012011515.0B1FFJnC038068@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Tue Dec  1 15:15:18 2020
New Revision: 368233
URL: https://svnweb.freebsd.org/changeset/base/368233

Log:
  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

Modified:
  stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
  stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h

Modified: stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==============================================================================
--- stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	Tue Dec  1 15:11:16 2020	(r368232)
+++ stable/12/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	Tue Dec  1 15:15:18 2020	(r368233)
@@ -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
 	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, cons
 			}
 
 			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);
 
 	/*

Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
==============================================================================
--- stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h	Tue Dec  1 15:11:16 2020	(r368232)
+++ stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h	Tue Dec  1 15:15:18 2020	(r368233)
@@ -882,6 +882,13 @@ typedef enum {
 } vdev_initializing_state_t;
 
 /*
+ * nvlist name constants. Facilitate restricting snapshot iteration range for
+ * the "list next snapshot" ioctl
+ */
+#define	SNAP_ITER_MIN_TXG	"snap_iter_min_txg"
+#define	SNAP_ITER_MAX_TXG	"snap_iter_max_txg"
+
+/*
  * Vdev statistics.  Note: all fields should be 64-bit because this
  * is passed between kernel and userland as an nvlist uint64 array.
  */
@@ -1156,13 +1163,6 @@ typedef enum {
 #define	ZCP_MAX_INSTRLIMIT	(10 * ZCP_DEFAULT_INSTRLIMIT)
 #define	ZCP_DEFAULT_MEMLIMIT	(10 * 1024 * 1024)
 #define	ZCP_MAX_MEMLIMIT	(10 * ZCP_DEFAULT_MEMLIMIT)
-
-/*
- * nvlist name constants. Facilitate restricting snapshot iteration range for
- * the "list next snapshot" ioctl
- */
-#define	SNAP_ITER_MIN_TXG	"snap_iter_min_txg"
-#define	SNAP_ITER_MAX_TXG	"snap_iter_max_txg"
 
 /*
  * Sysevent payload members.  ZFS will generate the following sysevents with the



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202012011515.0B1FFJnC038068>