From 8b03fce289862aa4607376494019f8938b13e8f8 Mon Sep 17 00:00:00 2001 From: Prawn Date: Mon, 12 Apr 2021 18:35:55 +0200 Subject: [PATCH] cmd/zfs receive: allow dry-run (-n) to check property args zfs recv -n does not report some errors it could. The code to bail out of the receive if in dry-run mode came a little early, skipping validation of cmdprops (recv -x and -o) among others. Move the check down to enable these additional checks. Reviewed-by: Brian Behlendorf Signed-off-by: InsanePrawn Closes #11862 --- lib/libzfs/libzfs_sendrecv.c | 40 ++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c index 3476575521..7db7cf74ff 100644 --- a/lib/libzfs/libzfs_sendrecv.c +++ b/lib/libzfs/libzfs_sendrecv.c @@ -4586,26 +4586,6 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, (void) fflush(stdout); } - if (flags->dryrun) { - void *buf = zfs_alloc(hdl, SPA_MAXBLOCKSIZE); - - /* - * We have read the DRR_BEGIN record, but we have - * not yet read the payload. For non-dryrun sends - * this will be done by the kernel, so we must - * emulate that here, before attempting to read - * more records. - */ - err = recv_read(hdl, infd, buf, drr->drr_payloadlen, - flags->byteswap, NULL); - free(buf); - if (err != 0) - goto out; - - err = recv_skip(hdl, infd, flags->byteswap); - goto out; - } - /* * If this is the top-level dataset, record it so we can use it * for recursive operations later. @@ -4650,6 +4630,26 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap, zfs_prop_to_name(ZFS_PROP_ENCRYPTION), ZIO_CRYPT_OFF); } + if (flags->dryrun) { + void *buf = zfs_alloc(hdl, SPA_MAXBLOCKSIZE); + + /* + * We have read the DRR_BEGIN record, but we have + * not yet read the payload. For non-dryrun sends + * this will be done by the kernel, so we must + * emulate that here, before attempting to read + * more records. + */ + err = recv_read(hdl, infd, buf, drr->drr_payloadlen, + flags->byteswap, NULL); + free(buf); + if (err != 0) + goto out; + + err = recv_skip(hdl, infd, flags->byteswap); + goto out; + } + err = ioctl_err = lzc_receive_with_cmdprops(destsnap, rcvprops, oxprops, wkeydata, wkeylen, origin, flags->force, flags->resumable, raw, infd, drr_noswap, -1, &read_bytes, &errflags,