aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2021-09-13 15:11:43 +0000
committerBrian Behlendorf <[email protected]>2022-02-01 17:04:01 -0800
commitd1a38ee742724047b5bfa2b2ae6012af64e3975d (patch)
tree6e882dd20b2d8f76f70a7339cb1f86dff756eeb1
parent102eb6733cf0b04b6390e0332eb31ab9321ce6f1 (diff)
libzfs_sendrecv: Factor out lzc_flags_from_resume_nvl
Improve the readability of zfs_send_resume_impl by moving resume nvl decoding into a separate helper function. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #12967
-rw-r--r--lib/libzfs/libzfs_sendrecv.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index 4b660158e..dc0a76329 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -1456,6 +1456,7 @@ static enum lzc_send_flags
lzc_flags_from_sendflags(const sendflags_t *flags)
{
enum lzc_send_flags lzc_flags = 0;
+
if (flags->largeblock)
lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
if (flags->embed_data)
@@ -1466,6 +1467,7 @@ lzc_flags_from_sendflags(const sendflags_t *flags)
lzc_flags |= LZC_SEND_FLAG_RAW;
if (flags->saved)
lzc_flags |= LZC_SEND_FLAG_SAVED;
+
return (lzc_flags);
}
@@ -1657,6 +1659,25 @@ find_redact_book(libzfs_handle_t *hdl, const char *path,
return (0);
}
+static enum lzc_send_flags
+lzc_flags_from_resume_nvl(nvlist_t *resume_nvl)
+{
+ enum lzc_send_flags lzc_flags = 0;
+
+ if (nvlist_exists(resume_nvl, "largeblockok"))
+ lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
+ if (nvlist_exists(resume_nvl, "embedok"))
+ lzc_flags |= LZC_SEND_FLAG_EMBED_DATA;
+ if (nvlist_exists(resume_nvl, "compressok"))
+ lzc_flags |= LZC_SEND_FLAG_COMPRESS;
+ if (nvlist_exists(resume_nvl, "rawok"))
+ lzc_flags |= LZC_SEND_FLAG_RAW;
+ if (nvlist_exists(resume_nvl, "savedok"))
+ lzc_flags |= LZC_SEND_FLAG_SAVED;
+
+ return (lzc_flags);
+}
+
static int
zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
nvlist_t *resume_nvl)
@@ -1668,7 +1689,6 @@ zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
zfs_handle_t *zhp;
int error = 0;
char name[ZFS_MAX_DATASET_NAME_LEN];
- enum lzc_send_flags lzc_flags = 0;
FILE *fout = (flags->verbosity > 0 && flags->dryrun) ? stdout : stderr;
uint64_t *redact_snap_guids = NULL;
int num_redact_snaps = 0;
@@ -1695,17 +1715,6 @@ zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
fromguid = 0;
(void) nvlist_lookup_uint64(resume_nvl, "fromguid", &fromguid);
- if (flags->largeblock || nvlist_exists(resume_nvl, "largeblockok"))
- lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
- if (flags->embed_data || nvlist_exists(resume_nvl, "embedok"))
- lzc_flags |= LZC_SEND_FLAG_EMBED_DATA;
- if (flags->compress || nvlist_exists(resume_nvl, "compressok"))
- lzc_flags |= LZC_SEND_FLAG_COMPRESS;
- if (flags->raw || nvlist_exists(resume_nvl, "rawok"))
- lzc_flags |= LZC_SEND_FLAG_RAW;
- if (flags->saved || nvlist_exists(resume_nvl, "savedok"))
- lzc_flags |= LZC_SEND_FLAG_SAVED;
-
if (flags->saved) {
(void) strcpy(name, toname);
} else {
@@ -1766,6 +1775,9 @@ zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
}
}
+ enum lzc_send_flags lzc_flags = lzc_flags_from_sendflags(flags) |
+ lzc_flags_from_resume_nvl(resume_nvl);
+
if (flags->verbosity != 0) {
/*
* Some of these may have come from the resume token, set them