[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 10/13] file-posix: Audit for read/write 64-bit cl
From: |
Eric Blake |
Subject: |
[Qemu-block] [PATCH v2 10/13] file-posix: Audit for read/write 64-bit cleanness |
Date: |
Wed, 14 Nov 2018 20:03:31 -0600 |
Any use of aio is inherently limited by size_t aio_nbytes in struct
aiocb. read() is similarly limited to size_t bytes, although in
practice, the ssize_t return means any read attempt on a 32-bit
platform for more than 2G will likely return a short read (if that
much memory was even available to begin with). And while preadv()
can technically read more than size_t bytes by use of more than one
iov, the fact that you can only pass a finite number of iov each of
which is limited to size_t bytes is a limiting factor.
While we already attempt other methods at populating a more reasonable
max_transfer limit in the cases where the kernel makes that
information available, it is important that we at least let the block
layer know about our hard limitation of size_t bytes (mainly
applicable to 32-bit compilation). At the same time, on 64-bit
platforms, that means we are now advertising that we don't have any
other unintended size-botching problems, if the block layer were to
start handing us requests larger than 2G.
Signed-off-by: Eric Blake <address@hidden>
---
block/file-posix.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/block/file-posix.c b/block/file-posix.c
index 48ad3bb372a..4b43ff8cb5c 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -1073,6 +1073,9 @@ static void raw_refresh_limits(BlockDriverState *bs,
Error **errp)
raw_probe_alignment(bs, s->fd, errp);
bs->bl.min_mem_alignment = s->buf_align;
bs->bl.opt_mem_alignment = MAX(s->buf_align, getpagesize());
+ if (!bs->bl.max_transfer) {
+ bs->bl.max_transfer = SIZE_MAX;
+ }
}
static int check_for_dasd(int fd)
--
2.17.2
- Re: [Qemu-block] [PATCH v2 05/13] block: Switch to 64-bit bl.max_transfer, (continued)
[Qemu-block] [PATCH v2 06/13] blkdebug: Audit for read/write 64-bit cleanness, Eric Blake, 2018/11/14
[Qemu-block] [PATCH v2 07/13] blklogwrites: Audit for read/write 64-bit cleanness, Eric Blake, 2018/11/14
[Qemu-block] [PATCH v2 11/13] qcow2: Audit for read/write 64-bit cleanness, Eric Blake, 2018/11/14
[Qemu-block] [PATCH v2 08/13] crypto: Audit for read/write 64-bit cleanness, Eric Blake, 2018/11/14
[Qemu-block] [PATCH v2 09/13] RFC: crypto: Rely on block layer for fragmentation, Eric Blake, 2018/11/14
[Qemu-block] [PATCH v2 10/13] file-posix: Audit for read/write 64-bit cleanness,
Eric Blake <=
[Qemu-block] [PATCH v2 12/13] block: Document need for audit of read/write 64-bit cleanness, Eric Blake, 2018/11/14
[Qemu-block] [PATCH v2 13/13] block: Enforce non-zero bl.max_transfer, Eric Blake, 2018/11/14
Re: [Qemu-block] [Qemu-devel] [PATCH v2 for-4.0 00/13] block: byte-based blocking read/write, no-reply, 2018/11/15
Re: [Qemu-block] [Qemu-devel] [PATCH v2 for-4.0 00/13] block: byte-based blocking read/write, no-reply, 2018/11/15