stream: Drop reached_end for stream_complete()
commit158c6492571c82c5632070c7ccee36b3dffd3ca9
authorEric Blake <eblake@redhat.com>
Fri, 7 Jul 2017 12:44:42 +0000 (7 07:44 -0500)
committerKevin Wolf <kwolf@redhat.com>
Mon, 10 Jul 2017 11:18:06 +0000 (10 13:18 +0200)
treefa69751bc86ce53b92b600b6f3397b88a649f4a1
parent8493211c02bbc74d1ae051422f90bbfd20debb5e
stream: Drop reached_end for stream_complete()

stream_complete() skips the work of rewriting the backing file if
the job was cancelled, if data->reached_end is false, or if there
was an error detected (non-zero data->ret) during the streaming.
But note that in stream_run(), data->reached_end is only set if the
loop ran to completion, and data->ret is only 0 in two cases:
either the loop ran to completion (possibly by cancellation, but
stream_complete checks for that), or we took an early goto out
because there is no bs->backing.  Thus, we can preserve the same
semantics without the use of reached_end, by merely checking for
bs->backing (and logically, if there was no backing file, streaming
is a no-op, so there is no backing file to rewrite).

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/stream.c