mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-17 10:01:01 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org> Closes #12967
This commit is contained in:
parent
102eb6733c
commit
d1a38ee742
@ -1456,6 +1456,7 @@ static enum lzc_send_flags
|
|||||||
lzc_flags_from_sendflags(const sendflags_t *flags)
|
lzc_flags_from_sendflags(const sendflags_t *flags)
|
||||||
{
|
{
|
||||||
enum lzc_send_flags lzc_flags = 0;
|
enum lzc_send_flags lzc_flags = 0;
|
||||||
|
|
||||||
if (flags->largeblock)
|
if (flags->largeblock)
|
||||||
lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
|
lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
|
||||||
if (flags->embed_data)
|
if (flags->embed_data)
|
||||||
@ -1466,6 +1467,7 @@ lzc_flags_from_sendflags(const sendflags_t *flags)
|
|||||||
lzc_flags |= LZC_SEND_FLAG_RAW;
|
lzc_flags |= LZC_SEND_FLAG_RAW;
|
||||||
if (flags->saved)
|
if (flags->saved)
|
||||||
lzc_flags |= LZC_SEND_FLAG_SAVED;
|
lzc_flags |= LZC_SEND_FLAG_SAVED;
|
||||||
|
|
||||||
return (lzc_flags);
|
return (lzc_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1657,6 +1659,25 @@ find_redact_book(libzfs_handle_t *hdl, const char *path,
|
|||||||
return (0);
|
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
|
static int
|
||||||
zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
|
zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
|
||||||
nvlist_t *resume_nvl)
|
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;
|
zfs_handle_t *zhp;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
char name[ZFS_MAX_DATASET_NAME_LEN];
|
char name[ZFS_MAX_DATASET_NAME_LEN];
|
||||||
enum lzc_send_flags lzc_flags = 0;
|
|
||||||
FILE *fout = (flags->verbosity > 0 && flags->dryrun) ? stdout : stderr;
|
FILE *fout = (flags->verbosity > 0 && flags->dryrun) ? stdout : stderr;
|
||||||
uint64_t *redact_snap_guids = NULL;
|
uint64_t *redact_snap_guids = NULL;
|
||||||
int num_redact_snaps = 0;
|
int num_redact_snaps = 0;
|
||||||
@ -1695,17 +1715,6 @@ zfs_send_resume_impl(libzfs_handle_t *hdl, sendflags_t *flags, int outfd,
|
|||||||
fromguid = 0;
|
fromguid = 0;
|
||||||
(void) nvlist_lookup_uint64(resume_nvl, "fromguid", &fromguid);
|
(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) {
|
if (flags->saved) {
|
||||||
(void) strcpy(name, toname);
|
(void) strcpy(name, toname);
|
||||||
} else {
|
} 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) {
|
if (flags->verbosity != 0) {
|
||||||
/*
|
/*
|
||||||
* Some of these may have come from the resume token, set them
|
* Some of these may have come from the resume token, set them
|
||||||
|
Loading…
Reference in New Issue
Block a user