From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Peter Lieven <pl@kamp.de>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-block@nongnu.org
Subject: [Qemu-devel] [PATCH for-2.5 v2 1/4] block: add BlockLimits.max_iov field
Date: Thu, 9 Jul 2015 10:56:44 +0100 [thread overview]
Message-ID: <1436435807-29422-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1436435807-29422-1-git-send-email-stefanha@redhat.com>
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 <pl@kamp.de>
Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
v2:
* Change default from INT_MAX to IOV_MAX [Peter Lieven]
---
block/io.c | 5 +++++
include/block/block_int.h | 3 +++
2 files changed, 8 insertions(+)
diff --git a/block/io.c b/block/io.c
index d4bc83b..37bc0dc 100644
--- a/block/io.c
+++ b/block/io.c
@@ -165,9 +165,13 @@ 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();
+
+ /* Safe default since most protocols use readv()/writev()/etc */
+ bs->bl.max_iov = IOV_MAX;
}
if (bs->backing_hd) {
@@ -188,6 +192,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/include/block/block_int.h b/include/block/block_int.h
index 8996baf..7d578c4 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
next prev parent reply other threads:[~2015-07-09 9:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-09 9:56 [Qemu-devel] [PATCH for-2.5 v2 0/4] block: replace IOV_MAX with BlockLimits.max_iov Stefan Hajnoczi
2015-07-09 9:56 ` Stefan Hajnoczi [this message]
2015-07-09 9:56 ` [Qemu-devel] [PATCH for-2.5 v2 2/4] block-backend: add blk_get_max_iov() Stefan Hajnoczi
2015-07-09 9:56 ` [Qemu-devel] [PATCH for-2.5 v2 3/4] block: replace IOV_MAX with BlockLimits.max_iov Stefan Hajnoczi
2015-07-09 9:56 ` [Qemu-devel] [PATCH for-2.5 v2 4/4] block/mirror: replace IOV_MAX with blk_get_max_iov() Stefan Hajnoczi
2015-07-10 6:26 ` [Qemu-devel] [PATCH for-2.5 v2 0/4] block: replace IOV_MAX with BlockLimits.max_iov Fam Zheng
2015-11-18 14:51 ` Kevin Wolf
2015-11-23 10:08 ` Stefan Hajnoczi
2015-11-23 10:08 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436435807-29422-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=kwolf@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).