block: Fragment writes to max transfer length
commit04ed95f4843281e292d93018d56d4b14705f9f2c
authorEric Blake <eblake@redhat.com>
Fri, 15 Jul 2016 18:32:01 +0000 (15 12:32 -0600)
committerStefan Hajnoczi <stefanha@redhat.com>
Wed, 20 Jul 2016 13:11:54 +0000 (20 14:11 +0100)
tree86ecceb673bffe3412e015de6c36912706cb92be
parent8a39b4d6e2926a536027f7ffbc28a3ed2e5d32b0
block: Fragment writes 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).  We already fragment
write zeroes at the block layer; this patch adds the fragmentation
for normal writes, after requests have been aligned (fragmenting
before alignment would lead to multiple unaligned requests, rather
than just the head and tail).

When fragmenting a large request where FUA was requested, but
where we know that FUA is implemented by flushing all requests
rather than the given request, then we can still get by with
only one flush.  Note, however, that we need a followup patch
to the raw format driver to avoid a regression in the number of
flushes actually issued.

The return value was previously nebulous on success (sometimes
zero, sometimes the length written); since we never have a short
write, and since fragmenting may store yet another positive
value in 'ret', change the function to always return 0 on success,
matching what we do in bdrv_aligned_preadv().

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