loop: handle short DIO reads
authorJens Axboe <axboe@kernel.dk>
Fri, 13 Apr 2018 22:25:57 +0000 (16:25 -0600)
committerJens Axboe <axboe@kernel.dk>
Sun, 15 Apr 2018 04:34:27 +0000 (22:34 -0600)
commitf9de14bc7e7aac77fd44bb2f62206eb9e494f0d2
treed556b07b0cab85b22b3697fd85705d7e6ed8dd71
parent1894e916546df0efec9890a5c9954f4ad281494c
loop: handle short DIO reads

We ran into an issue with loop and btrfs, where btrfs would complain about
checksum errors. It turns out that is because we don't handle short reads
at all, we just zero fill the remainder. Worse than that, we don't handle
the filling properly, which results in loop trying to advance a single
bio by much more than its size, since it doesn't take chaining into
account.

Handle short reads appropriately, by simply retrying at the new correct
offset. End the remainder of the request with EIO, if we get a 0 read.

Fixes: bc07c10a3603 ("block: loop: support DIO & AIO")
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/loop.c