All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hu Tao <hutao@cn.fujitsu.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
	Peter Lieven <pl@kamp.de>,
	hutao@cn.fujitsu.com
Subject: [Qemu-devel] [RFC PATCH v3 2/6] block: add BlockDriver.bdrv_preallocate.
Date: Thu, 19 Dec 2013 10:27:37 +0800	[thread overview]
Message-ID: <521cd9f1c99d5912c7438b1714fe4d0de758344e.1387419339.git.hutao@cn.fujitsu.com> (raw)
In-Reply-To: <cover.1387419339.git.hutao@cn.fujitsu.com>

This field is used to preallocate disk space for block device.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
---
 block.c                   | 13 +++++++++++++
 include/block/block.h     |  1 +
 include/block/block_int.h |  3 +++
 3 files changed, 17 insertions(+)

diff --git a/block.c b/block.c
index 64e7d22..b901587 100644
--- a/block.c
+++ b/block.c
@@ -3216,6 +3216,19 @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
     return false;
 }
 
+int bdrv_preallocate(BlockDriverState *bs, int64_t offset, int64_t length)
+{
+    if (bs->backing_hd) {
+        return -ENOTSUP;
+    }
+
+    if (bs->drv->bdrv_preallocate) {
+        return bs->drv->bdrv_preallocate(bs, offset, length);
+    }
+
+    return -ENOTSUP;
+}
+
 typedef struct BdrvCoGetBlockStatusData {
     BlockDriverState *bs;
     BlockDriverState *base;
diff --git a/include/block/block.h b/include/block/block.h
index 3732f25..bc1f277 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -349,6 +349,7 @@ int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
 int bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors);
 int bdrv_has_zero_init_1(BlockDriverState *bs);
 int bdrv_has_zero_init(BlockDriverState *bs);
+int bdrv_preallocate(BlockDriverState *bs, int64_t offset, int64_t length);
 bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs);
 bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
 int64_t bdrv_get_block_status(BlockDriverState *bs, int64_t sector_num,
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8b132d7..5bb1005 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -232,6 +232,9 @@ struct BlockDriver {
      */
     int (*bdrv_has_zero_init)(BlockDriverState *bs);
 
+    int (*bdrv_preallocate)(BlockDriverState *bs, int64_t offset,
+                            int64_t length);
+
     QLIST_ENTRY(BlockDriver) list;
 };
 
-- 
1.7.11.7

  parent reply	other threads:[~2013-12-19  2:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19  2:27 [Qemu-devel] [RFC PATCH v3 0/6] qemu-img: add preallocation=full Hu Tao
2013-12-19  2:27 ` [Qemu-devel] [RFC PATCH v3 1/6] block: introduce prealloc_mode Hu Tao
2013-12-20 10:08   ` Stefan Hajnoczi
2013-12-20 12:36   ` Eric Blake
2013-12-19  2:27 ` Hu Tao [this message]
2013-12-20 10:10   ` [Qemu-devel] [RFC PATCH v3 2/6] block: add BlockDriver.bdrv_preallocate Stefan Hajnoczi
2013-12-24  8:31     ` Hu Tao
2013-12-19  2:27 ` [Qemu-devel] [RFC PATCH v3 3/6] block/raw-posix: implement bdrv_preallocate Hu Tao
2013-12-20 10:14   ` Stefan Hajnoczi
2013-12-23  1:45     ` Hu Tao
2013-12-19  2:27 ` [Qemu-devel] [RFC PATCH v3 4/6] raw-posix: Add full image preallocation option Hu Tao
2013-12-19  2:27 ` [Qemu-devel] [RFC PATCH v3 5/6] qcow2: implement bdrv_preallocate Hu Tao
2013-12-20 10:19   ` Stefan Hajnoczi
2013-12-19  2:27 ` [Qemu-devel] [RFC PATCH v3 6/6] qcow2: Add full image preallocation option Hu Tao
2013-12-20 10:21   ` Stefan Hajnoczi
2013-12-20 10:30 ` [Qemu-devel] [RFC PATCH v3 0/6] qemu-img: add preallocation=full Stefan Hajnoczi
2013-12-20 12:54   ` Eric Blake
2013-12-23  1:59   ` Hu Tao

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=521cd9f1c99d5912c7438b1714fe4d0de758344e.1387419339.git.hutao@cn.fujitsu.com \
    --to=hutao@cn.fujitsu.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pl@kamp.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.