From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBIiU-0001Fr-SF for qemu-devel@nongnu.org; Tue, 22 Dec 2015 03:54:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aBIiQ-0007Xp-2r for qemu-devel@nongnu.org; Tue, 22 Dec 2015 03:54:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aBIiP-0007Xl-U7 for qemu-devel@nongnu.org; Tue, 22 Dec 2015 03:54:42 -0500 From: Stefan Hajnoczi Date: Tue, 22 Dec 2015 16:54:12 +0800 Message-Id: <1450774460-17259-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1450774460-17259-1-git-send-email-stefanha@redhat.com> References: <1450774460-17259-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 02/10] block: add BlockLimits.max_iov field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Peter Lieven , Stefan Hajnoczi The maximum number of struct iovec elements depends on the BlockDriverState. The raw-posix and iSCSI protocols have a maximum of IOV_MAX but others could have different values. Cc: Peter Lieven Suggested-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- block/io.c | 7 +++++++ include/block/block_int.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/block/io.c b/block/io.c index 841f5b5..42050a0 100644 --- a/block/io.c +++ b/block/io.c @@ -166,9 +166,13 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.max_transfer_length = bs->file->bs->bl.max_transfer_length; bs->bl.min_mem_alignment = bs->file->bs->bl.min_mem_alignment; bs->bl.opt_mem_alignment = bs->file->bs->bl.opt_mem_alignment; + bs->bl.max_iov = bs->file->bs->bl.max_iov; } else { bs->bl.min_mem_alignment = 512; bs->bl.opt_mem_alignment = getpagesize(); + + /* Safe default since most protocols use readv()/writev()/etc */ + bs->bl.max_iov = IOV_MAX; } if (bs->backing) { @@ -189,6 +193,9 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.min_mem_alignment = MAX(bs->bl.min_mem_alignment, bs->backing->bs->bl.min_mem_alignment); + bs->bl.max_iov = + MIN(bs->bl.max_iov, + bs->backing->bs->bl.max_iov); } /* Then let the driver override it */ diff --git a/include/block/block_int.h b/include/block/block_int.h index 9a1c466..256609d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -330,6 +330,9 @@ typedef struct BlockLimits { /* memory alignment for bounce buffer */ size_t opt_mem_alignment; + + /* maximum number of iovec elements */ + int max_iov; } BlockLimits; typedef struct BdrvOpBlocker BdrvOpBlocker; -- 2.5.0