block: Fragment reads to max transfer length
authorEric Blake <eblake@redhat.com>
Fri, 15 Jul 2016 18:31:59 +0000 (12:31 -0600)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 20 Jul 2016 13:11:54 +0000 (14:11 +0100)
commit1a62d0accdf85fbeac149018ee8d1728e754de73
tree60774298934aa4df5a07c36874d490dd45c35c64
parent338404d061144956b76f9893ca3434d057dff2d4
block: Fragment reads to max transfer length

Drivers should be able to rely on the block layer honoring the
max transfer length, rather than needing to return -EINVAL
(iscsi) or manually fragment things (nbd).  This patch adds
the fragmentation in the block layer, after requests have been
aligned (fragmenting before alignment would lead to multiple
unaligned requests, rather than just the head and tail).

The return value was previously nebulous on success on whether
it was zero or the length read; and fragmenting may introduce
yet other non-zero values if we use the last length read.  But
as at least some callers are sloppy and expect only zero on
success, it is easiest to just guarantee 0.

[Fix uninitialized ret local variable in bdrv_aligned_preadv().
--Stefan]

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-id: 1468607524-19021-2-git-send-email-eblake@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/io.c