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".

Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
  • Loading branch information
ahrens committed May 12, 2020
1 parent a36bad1 commit b85f798
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 @@ -2574,7 +2574,8 @@ receive_writer_thread(void *arg)
* free it.
*/
if (err != EAGAIN) {
rwa->err = err;
if (err != 0)
rwa->err = err;
kmem_free(rrd, sizeof (*rrd));
}
}
Expand Down

0 comments on commit b85f798

Please sign in to comment.