]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix error handling in receive_writer_thread()
authorMatthew Ahrens <mahrens@delphix.com>
Fri, 15 May 2020 03:48:29 +0000 (20:48 -0700)
committerGitHub <noreply@github.com>
Fri, 15 May 2020 03:48:29 +0000 (20:48 -0700)
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 <behlendorf1@llnl.gov>
Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #10320

module/zfs/dmu_recv.c

index ed52b25e6187f99003ff7f649ffebcaef74db1ae..29fbe854d7937b1f52d6609b2b4e2c586716554f 100644 (file)
@@ -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));
                }
        }