From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCrJZ-0005iT-3w for qemu-devel@nongnu.org; Wed, 08 Jul 2015 11:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCrJY-0001Ln-2f for qemu-devel@nongnu.org; Wed, 08 Jul 2015 11:31:13 -0400 From: Stefan Hajnoczi Date: Wed, 8 Jul 2015 16:30:59 +0100 Message-Id: <1436369462-24252-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1436369462-24252-1-git-send-email-stefanha@redhat.com> References: <1436369462-24252-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH for-2.5 1/4] block: add BlockLimits.max_iov field List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , Stefan Hajnoczi , qemu-block@nongnu.org The maximum number of struct iovec elements depends on the BlockDriverState. The raw-posix protocol has a maximum of IOV_MAX but others could have different values. Instead of assuming raw-posix and hardcoding IOV_MAX in several places, put the limit into BlockLimits. Cc: Peter Lieven Suggested-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- Peter Lieven: I think the SCSI LUN level does not have a maximum scatter-gather segments constraint. That is probably only at the HBA level. CCed you anyway in case you think block/iscsi.c should set the max_iov field. Kevin: The default is now INT_MAX. This means non-raw-posix users will now be able to merge more requests than before. They were limited to IOV_MAX previously. This could expose limits in other BlockDrivers which we weren't aware of... --- block/io.c | 3 +++ block/raw-posix.c | 1 + include/block/block_int.h | 3 +++ 3 files changed, 7 insertions(+) diff --git a/block/io.c b/block/io.c index e295992..6750de6 100644 --- a/block/io.c +++ b/block/io.c @@ -165,9 +165,11 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.max_transfer_length = bs->file->bl.max_transfer_length; bs->bl.min_mem_alignment = bs->file->bl.min_mem_alignment; bs->bl.opt_mem_alignment = bs->file->bl.opt_mem_alignment; + bs->bl.max_iov = bs->file->bl.max_iov; } else { bs->bl.min_mem_alignment = 512; bs->bl.opt_mem_alignment = getpagesize(); + bs->bl.max_iov = INT_MAX; } if (bs->backing_hd) { @@ -188,6 +190,7 @@ void bdrv_refresh_limits(BlockDriverState *bs, Error **errp) bs->bl.min_mem_alignment = MAX(bs->bl.min_mem_alignment, bs->backing_hd->bl.min_mem_alignment); + bs->bl.max_iov = MIN(bs->bl.max_iov, bs->backing_hd->bl.max_iov); } /* Then let the driver override it */ diff --git a/block/raw-posix.c b/block/raw-posix.c index cbe6574..faa6ae0 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -735,6 +735,7 @@ 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()); + bs->bl.max_iov = IOV_MAX; /* limit comes from preadv()/pwritev()/etc */ } static int check_for_dasd(int fd) diff --git a/include/block/block_int.h b/include/block/block_int.h index b0476fc..767e83d 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -315,6 +315,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.4.3