[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/43] nbd: Advertise realistic limits to block layer
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 06/43] nbd: Advertise realistic limits to block layer |
Date: |
Tue, 5 Jul 2016 17:50:15 +0200 |
From: Eric Blake <address@hidden>
We were basing the advertisement of maximum discard and transfer
length off of UINT32_MAX, but since the rest of the block layer
has signed int limits on a transaction, nothing could ever reach
that maximum, and we risk overflowing an int once things are
converted to byte-based rather than sector-based limits. What's
more, we DO have a much smaller limit: both the current kernel
and qemu-nbd have a hard limit of 32M on a read or write
transaction, and while they may also permit up to a full 32 bits
on a discard transaction, the upstream NBD protocol is proposing
wording that without any explicit advertisement otherwise,
clients should limit ALL requests to the same limits as read and
write, even though the other requests do not actually require as
many bytes across the wire. So the better limit to tell the
block layer is 32M for both values.
Behavior doesn't actually change with this patch (the block layer
is currently ignoring the max_transfer advertisements); but when
that problem is fixed in a later series, this patch will prevent
the exposure of a latent bug.
Signed-off-by: Eric Blake <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/nbd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/nbd.c b/block/nbd.c
index 6015e8b..bf67c8a 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -362,8 +362,8 @@ static int nbd_co_flush(BlockDriverState *bs)
static void nbd_refresh_limits(BlockDriverState *bs, Error **errp)
{
- bs->bl.max_discard = UINT32_MAX >> BDRV_SECTOR_BITS;
- bs->bl.max_transfer_length = UINT32_MAX >> BDRV_SECTOR_BITS;
+ bs->bl.max_discard = NBD_MAX_SECTORS;
+ bs->bl.max_transfer_length = NBD_MAX_SECTORS;
}
static int nbd_co_discard(BlockDriverState *bs, int64_t sector_num,
--
1.8.3.1
- [Qemu-devel] [PULL 00/43] Block layer patches, Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 01/43] qemu-img: fix failed autotests, Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 02/43] block: Tighter assertions on bdrv_aligned_pwritev(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 04/43] block: Fix harmless off-by-one in bdrv_aligned_preadv(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 03/43] block: Document supported flags during bdrv_aligned_preadv(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 05/43] nbd: Allow larger requests, Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 08/43] scsi: Advertise limits by blocksize, not 512, Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 06/43] nbd: Advertise realistic limits to block layer,
Kevin Wolf <=
- [Qemu-devel] [PULL 10/43] blkdebug: Set request_alignment during .bdrv_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 07/43] iscsi: Advertise realistic limits to block layer, Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 11/43] iscsi: Set request_alignment during .bdrv_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 09/43] block: Give nonzero result to blk_get_max_transfer_length(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 12/43] qcow2: Set request_alignment during .bdrv_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 15/43] block: Set default request_alignment during bdrv_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 17/43] block: Wording tweaks to write zeroes limits, Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 14/43] block: Set request_alignment during .bdrv_refresh_limits(), Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 16/43] block: Switch transfer length bounds to byte-based, Kevin Wolf, 2016/07/05
- [Qemu-devel] [PULL 13/43] raw-win32: Set request_alignment during .bdrv_refresh_limits(), Kevin Wolf, 2016/07/05