qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nolan <nolan@sigbus.net>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size.
Date: Fri, 26 Jun 2009 19:11:24 -0700	[thread overview]
Message-ID: <1246068684.4465.76.camel@voxel> (raw)

Allow adjustment of http block device's readahead size, via the
environment variable "HTTP_READAHEAD_SIZE".

Signed-off-by: Nolan Leake <nolan <at> sigbus.net>

diff --git a/block/curl.c b/block/curl.c
index e1a553f..32530eb 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -24,6 +24,7 @@
 #include "qemu-common.h"
 #include "block_int.h"
 #include <curl/curl.h>
+#include <stdlib.h>
 
 // #define DEBUG
 // #define DEBUG_VERBOSE
@@ -71,6 +72,7 @@ typedef struct BDRVCURLState {
     size_t len;
     CURLState states[CURL_NUM_STATES];
     char *url;
+    size_t readahead_size;
 } BDRVCURLState;
 
 static void curl_clean_state(CURLState *s);
@@ -298,9 +300,21 @@ static int curl_open(BlockDriverState *bs, const char *filename, int flags)
 {
     BDRVCURLState *s = bs->opaque;
     CURLState *state = NULL;
+    char *readahead;
     double d;
     static int inited = 0;
 
+    s->readahead_size = READ_AHEAD_SIZE;
+    readahead = getenv("HTTP_READAHEAD_SIZE");
+    if (readahead) {
+        s->readahead_size = atoi(readahead);
+    }
+    if ((s->readahead_size & 0x1ff) != 0) {
+        fprintf(stderr, "HTTP_READAHEAD_SIZE %Zd not a multiple of 512\n",
+                s->readahead_size);
+        goto out_noclean;
+    }
+
     if (!inited) {
         curl_global_init(CURL_GLOBAL_ALL);
         inited = 1;
@@ -346,6 +360,7 @@ out:
     curl_easy_cleanup(state->curl);
     state->curl = NULL;
 out_noclean:
+    qemu_free(s->url);
     return -EINVAL;
 }
 
@@ -401,7 +416,7 @@ static BlockDriverAIOCB *curl_aio_readv(BlockDriverState *bs,
     if (state->orig_buf)
         qemu_free(state->orig_buf);
     state->buf_start = start;
-    state->buf_len = acb->end + READ_AHEAD_SIZE;
+    state->buf_len = acb->end + s->readahead_size;
     end = MIN(start + state->buf_len, s->len) - 1;
     state->orig_buf = qemu_malloc(state->buf_len);
     state->acb[0] = acb;

             reply	other threads:[~2009-06-27  2:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-27  2:11 Nolan [this message]
2009-06-29 13:45 ` [Qemu-devel] [PATCH] Allow adjustment of http block device's readahead size Anthony Liguori
2009-06-30 13:09   ` Alexander Graf
2009-06-30 13:36     ` Anthony Liguori
2009-06-30 16:44       ` Jamie Lokier

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=1246068684.4465.76.camel@voxel \
    --to=nolan@sigbus.net \
    --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).