From: David Edmondson <david.edmondson@oracle.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>,
David Edmondson <david.edmondson@oracle.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [RFC PATCH 9/9] block/curl: Add readahead support
Date: Tue, 18 Aug 2020 12:08:45 +0100 [thread overview]
Message-ID: <20200818110845.3825105-10-david.edmondson@oracle.com> (raw)
In-Reply-To: <20200818110845.3825105-1-david.edmondson@oracle.com>
Re-add support for a readahead parameter, which is the number of bytes
added to the request from the upper layer before breaking the request
into blocks. The default is zero. The number of bytes specified has no
alignment requirements.
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
block/curl.c | 11 +++++++++++
docs/system/device-url-syntax.rst.inc | 7 +++++++
qapi/block-core.json | 3 +++
3 files changed, 21 insertions(+)
diff --git a/block/curl.c b/block/curl.c
index 8ee314739a..a182a55b93 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -65,6 +65,7 @@ static CURLMcode __curl_multi_socket_action(CURLM *multi_handle,
#define CURL_TIMEOUT_MAX 10000
#define CURL_BLOCK_OPT_URL "url"
+#define CURL_BLOCK_OPT_READAHEAD "readahead"
#define CURL_BLOCK_OPT_SSLVERIFY "sslverify"
#define CURL_BLOCK_OPT_TIMEOUT "timeout"
#define CURL_BLOCK_OPT_COOKIE "cookie"
@@ -149,6 +150,7 @@ typedef struct BDRVCURLState {
uint64_t len;
CURLState states[CURL_NUM_STATES];
char *url;
+ size_t readahead_size;
bool sslverify;
uint64_t timeout;
char *cookie;
@@ -881,6 +883,11 @@ static QemuOptsList runtime_opts = {
.type = QEMU_OPT_STRING,
.help = "URL to open",
},
+ {
+ .name = CURL_BLOCK_OPT_READAHEAD,
+ .type = QEMU_OPT_SIZE,
+ .help = "Readahead size",
+ },
{
.name = CURL_BLOCK_OPT_SSLVERIFY,
.type = QEMU_OPT_BOOL,
@@ -976,6 +983,8 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
goto out_noclean;
}
+ s->readahead_size = qemu_opt_get_size(opts, CURL_BLOCK_OPT_READAHEAD, 0);
+
s->timeout = qemu_opt_get_number(opts, CURL_BLOCK_OPT_TIMEOUT,
CURL_BLOCK_OPT_TIMEOUT_DEFAULT);
if (s->timeout > CURL_TIMEOUT_MAX) {
@@ -1247,6 +1256,8 @@ static int coroutine_fn curl_co_preadv(BlockDriverState *bs,
trace_curl_co_preadv(qemu_coroutine_self(), offset, bytes);
+ bytes += s->readahead_size;
+
while (bytes > 0) {
uint64_t len = MIN(bytes, s->blocksize - curl_block_offset(s, off));
CURLAIOCB acb = {
diff --git a/docs/system/device-url-syntax.rst.inc b/docs/system/device-url-syntax.rst.inc
index 56843cb38f..58245e017c 100644
--- a/docs/system/device-url-syntax.rst.inc
+++ b/docs/system/device-url-syntax.rst.inc
@@ -174,6 +174,13 @@ These are specified using a special URL syntax.
``url``
The full URL when passing options to the driver explicitly.
+ ``readahead``
+ The amount of data to read ahead with each range request to the
+ remote server. This value may optionally have the suffix 'T', 'G',
+ 'M', 'K', 'k' or 'b'. If it does not have a suffix, it will be
+ assumed to be in bytes. The value must be a multiple of 512 bytes.
+ It defaults to 256k.
+
``sslverify``
Whether to verify the remote server's certificate when connecting
over SSL. It can have the value 'on' or 'off'. It defaults to
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 91888166fa..f4092ccc14 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3752,6 +3752,8 @@
#
# @url: URL of the image file
#
+# @readahead: Amount of read-ahead (defaults to 0)
+#
# @timeout: Timeout for connections, in seconds (defaults to 5)
#
# @username: Username for authentication (defaults to none)
@@ -3776,6 +3778,7 @@
'data': { 'url': 'str',
'*blocksize': 'int',
'*blockcount': 'int',
+ '*readahead': 'int',
'*timeout': 'int',
'*username': 'str',
'*password-secret': 'str',
--
2.27.0
next prev parent reply other threads:[~2020-08-18 11:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 11:08 [RFC PATCH 0/9] block/curl: Add caching of data downloaded from the remote server David Edmondson
2020-08-18 11:08 ` [RFC PATCH 1/9] block/curl: Add an 'offset' parameter, affecting all range requests David Edmondson
2020-08-18 11:08 ` [RFC PATCH 2/9] block/curl: Remove readahead support David Edmondson
2020-08-18 11:08 ` [RFC PATCH 3/9] block/curl: Tracing David Edmondson
2020-08-18 11:08 ` [RFC PATCH 4/9] block/curl: Perform IO in fixed size chunks David Edmondson
2020-08-18 11:08 ` [RFC PATCH 5/9] block/curl: Allow the blocksize to be specified by the user David Edmondson
2020-08-24 13:19 ` Markus Armbruster
2020-08-24 14:21 ` David Edmondson
2020-08-18 11:08 ` [RFC PATCH 6/9] block/curl: Cache downloaded blocks David Edmondson
2020-08-18 11:08 ` [RFC PATCH 7/9] block/curl: Allow the user to control the number of cache blocks David Edmondson
2020-08-18 11:08 ` [RFC PATCH 8/9] block/curl: Allow 16 sockets/ACB David Edmondson
2020-08-18 11:08 ` David Edmondson [this message]
2020-08-19 14:11 ` [RFC PATCH 0/9] block/curl: Add caching of data downloaded from the remote server Stefan Hajnoczi
2020-08-19 14:19 ` David Edmondson
2020-08-25 10:03 ` Max Reitz
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=20200818110845.3825105-10-david.edmondson@oracle.com \
--to=david.edmondson@oracle.com \
--cc=armbru@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).