From 1b9cd1a9d9ebd213df1427d38e75d3233c873bde Mon Sep 17 00:00:00 2001 From: Matthew Ahrens Date: Thu, 14 May 2020 20:48:29 -0700 Subject: [PATCH] Fix error handling in receive_writer_thread() If `receive_writer_thread()` gets an error from `receive_process_record()`, it should be saved in `rwa->err` so that we will stop processing records, and the main thread will notice that the receive has failed. When an error is first encountered, this happens correctly. However, if there are more records to dequeue, the next time through the loop we will reset `rwa->err` to zero, allowing us to try to process the following record (2 after the failed record). Depending on what types of records remain, we may incorrectly complete the receive "successfully", but without actually having processed all the records. The fix is to only set `rwa->err` if we got a *non-zero* error. This bug was introduced by #10099 "Improve zfs receive performance by batching writes". Reviewed-by: Brian Behlendorf Reviewed-by: Paul Dagnelie Signed-off-by: Matthew Ahrens Closes #10320 --- module/zfs/dmu_recv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/zfs/dmu_recv.c b/module/zfs/dmu_recv.c index ed52b25e6187..29fbe854d793 100644 --- a/module/zfs/dmu_recv.c +++ b/module/zfs/dmu_recv.c @@ -2572,7 +2572,8 @@ receive_writer_thread(void *arg) * free it. */ if (err != EAGAIN) { - rwa->err = err; + if (rwa->err == 0) + rwa->err = err; kmem_free(rrd, sizeof (*rrd)); } }