Skip to content

Commit

Permalink
Fix error handling in receive_writer_thread()
Browse files Browse the repository at this point in the history
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 openzfs#10099 "Improve zfs receive performance by
batching writes".

Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Paul Dagnelie <[email protected]>
Signed-off-by: Matthew Ahrens <[email protected]>
Closes openzfs#10320
  • Loading branch information
ahrens committed May 15, 2020
1 parent 1faff4c commit 135d4d0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion module/zfs/dmu_recv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2700,7 +2700,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));
}
}
Expand Down

0 comments on commit 135d4d0

Please sign in to comment.