qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 1/8] block: add bdrv_aio_stream
Date: Wed, 27 Apr 2011 14:27:28 +0100	[thread overview]
Message-ID: <1303910855-28999-2-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1303910855-28999-1-git-send-email-stefanha@linux.vnet.ibm.com>

From: Anthony Liguori <aliguori@us.ibm.com>

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 block.c     |   32 ++++++++++++++++++++++++++++++++
 block.h     |    2 ++
 block_int.h |    3 +++
 3 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/block.c b/block.c
index f731c7a..5e3476c 100644
--- a/block.c
+++ b/block.c
@@ -2248,6 +2248,38 @@ BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
     return ret;
 }
 
+/**
+ * Attempt to stream an image starting from sector_num.
+ *
+ * @sector_num - the first sector to start streaming from
+ * @cb - block completion callback
+ * @opaque - data to pass completion callback
+ *
+ * Returns NULL if the image format not support streaming, the image is
+ * read-only, or no image is open.
+ *
+ * The intention of this function is for a user to execute it once with a
+ * sector_num of 0 and then upon receiving a completion callback, to remember
+ * the number of sectors "streamed", and then to call this function again with
+ * an offset adjusted by the number of sectors previously streamed.
+ *
+ * This allows a user to progressive stream in an image at a pace that makes
+ * sense.  In general, this function tries to do the smallest amount of I/O
+ * possible to do some useful work.
+ *
+ * This function only really makes sense in combination with a block format
+ * that supports copy on read and has it enabled.  If copy on read is not
+ * enabled, a block format driver may return NULL.
+ */
+BlockDriverAIOCB *bdrv_aio_stream(BlockDriverState *bs, int64_t sector_num,
+                                  BlockDriverCompletionFunc *cb, void *opaque)
+{
+    if (!bs->drv || bs->read_only || !bs->drv->bdrv_aio_stream) {
+        return NULL;
+    }
+
+    return bs->drv->bdrv_aio_stream(bs, sector_num, cb, opaque);
+}
 
 typedef struct MultiwriteCB {
     int error;
diff --git a/block.h b/block.h
index 52e9cad..fad828a 100644
--- a/block.h
+++ b/block.h
@@ -119,6 +119,8 @@ BlockDriverAIOCB *bdrv_aio_writev(BlockDriverState *bs, int64_t sector_num,
                                   BlockDriverCompletionFunc *cb, void *opaque);
 BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs,
 				 BlockDriverCompletionFunc *cb, void *opaque);
+BlockDriverAIOCB *bdrv_aio_stream(BlockDriverState *bs, int64_t sector_num,
+                                  BlockDriverCompletionFunc *cb, void *opaque);
 void bdrv_aio_cancel(BlockDriverAIOCB *acb);
 
 typedef struct BlockRequest {
diff --git a/block_int.h b/block_int.h
index 545ad11..0c125d0 100644
--- a/block_int.h
+++ b/block_int.h
@@ -73,6 +73,9 @@ struct BlockDriver {
         BlockDriverCompletionFunc *cb, void *opaque);
     BlockDriverAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs,
         BlockDriverCompletionFunc *cb, void *opaque);
+    BlockDriverAIOCB *(*bdrv_aio_stream)(BlockDriverState *bs,
+        int64_t sector_num,
+        BlockDriverCompletionFunc *cb, void *opaque);
     int (*bdrv_discard)(BlockDriverState *bs, int64_t sector_num,
                         int nb_sectors);
 
-- 
1.7.4.4

  reply	other threads:[~2011-04-27 13:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27 13:27 [Qemu-devel] [RFC PATCH 0/8] QED image streaming Stefan Hajnoczi
2011-04-27 13:27 ` Stefan Hajnoczi [this message]
2011-04-29 11:56   ` [Qemu-devel] [PATCH 1/8] block: add bdrv_aio_stream Kevin Wolf
2011-05-06 13:21     ` Stefan Hajnoczi
2011-05-06 13:36       ` Kevin Wolf
2011-05-06 15:47         ` Stefan Hajnoczi
2011-04-27 13:27 ` [Qemu-devel] [PATCH 2/8] qmp: Add QMP support for stream commands Stefan Hajnoczi
2011-04-29 12:09   ` Kevin Wolf
2011-05-06 13:23     ` Stefan Hajnoczi
2011-04-27 13:27 ` [Qemu-devel] [PATCH 3/8] qed: add support for Copy-on-Read Stefan Hajnoczi
2011-04-27 14:29   ` Paolo Bonzini
2011-04-29 12:14   ` Kevin Wolf
2011-05-06 13:24     ` Stefan Hajnoczi
2011-04-27 13:27 ` [Qemu-devel] [PATCH 4/8] qed: intelligent streaming implementation Stefan Hajnoczi
2011-04-27 13:27 ` [Qemu-devel] [PATCH 5/8] qed: detect zero writes and skip them when to an unalloc cluster Stefan Hajnoczi
2011-04-27 13:27 ` [Qemu-devel] [PATCH 6/8] blockdev: Allow image files to auto-enable streaming Stefan Hajnoczi
2011-04-29 12:20   ` Kevin Wolf
2011-04-27 13:27 ` [Qemu-devel] [PATCH 7/8] qed: Add QED_CF_STREAM flag " Stefan Hajnoczi
2011-04-27 13:27 ` [Qemu-devel] [PATCH 8/8] qed: Add -o stream=on image creation option Stefan Hajnoczi
2011-04-27 13:41 ` [Qemu-devel] [RFC PATCH 0/8] QED image streaming 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=1303910855-28999-2-git-send-email-stefanha@linux.vnet.ibm.com \
    --to=stefanha@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=kwolf@redhat.com \
    --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).