All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [Qemu-devel] [PATCH v3 13/14] block: Remove "growable" from BDS
Date: Mon, 26 Jan 2015 10:00:43 -0500	[thread overview]
Message-ID: <1422284444-12529-14-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1422284444-12529-1-git-send-email-mreitz@redhat.com>

Now that request clamping is done in the BlockBackend, the "growable"
field can be removed from the BlockDriverState. All BDSs are now treated
as being "growable" (that is, they are allowed to grow; they are not
necessarily actually able to).

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block.c                   | 24 +++++-------------------
 block/qcow2.c             |  6 ------
 block/raw-posix.c         |  2 +-
 block/raw-win32.c         |  2 +-
 block/sheepdog.c          |  2 +-
 include/block/block_int.h |  3 ---
 6 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/block.c b/block.c
index d45e4dd..356a857 100644
--- a/block.c
+++ b/block.c
@@ -970,7 +970,6 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
     bs->zero_beyond_eof = true;
     open_flags = bdrv_open_flags(bs, flags);
     bs->read_only = !(open_flags & BDRV_O_RDWR);
-    bs->growable = !!(flags & BDRV_O_PROTOCOL);
 
     if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv, bs->read_only)) {
         error_setg(errp,
@@ -1885,7 +1884,6 @@ void bdrv_close(BlockDriverState *bs)
         bs->encrypted = 0;
         bs->valid_key = 0;
         bs->sg = 0;
-        bs->growable = 0;
         bs->zero_beyond_eof = false;
         QDECREF(bs->options);
         bs->options = NULL;
@@ -2645,25 +2643,13 @@ exit:
 static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,
                                    size_t size)
 {
-    int64_t len;
-
     if (size > INT_MAX) {
         return -EIO;
     }
 
-    if (!bdrv_is_inserted(bs))
+    if (!bdrv_is_inserted(bs)) {
         return -ENOMEDIUM;
-
-    if (bs->growable)
-        return 0;
-
-    len = bdrv_getlength(bs);
-
-    if (offset < 0)
-        return -EIO;
-
-    if ((offset > len) || (len - offset < size))
-        return -EIO;
+    }
 
     return 0;
 }
@@ -3045,10 +3031,10 @@ static int coroutine_fn bdrv_aligned_preadv(BlockDriverState *bs,
     }
 
     /* Forward the request to the BlockDriver */
-    if (!(bs->zero_beyond_eof && bs->growable)) {
+    if (!bs->zero_beyond_eof) {
         ret = drv->bdrv_co_readv(bs, sector_num, nb_sectors, qiov);
     } else {
-        /* Read zeros after EOF of growable BDSes */
+        /* Read zeros after EOF */
         int64_t total_sectors, max_nb_sectors;
 
         total_sectors = bdrv_nb_sectors(bs);
@@ -3328,7 +3314,7 @@ static int coroutine_fn bdrv_aligned_pwritev(BlockDriverState *bs,
 
     block_acct_highest_sector(&bs->stats, sector_num, nb_sectors);
 
-    if (bs->growable && ret >= 0) {
+    if (ret >= 0) {
         bs->total_sectors = MAX(bs->total_sectors, sector_num + nb_sectors);
     }
 
diff --git a/block/qcow2.c b/block/qcow2.c
index dbaf016..2b31dac 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2521,15 +2521,12 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov,
 {
     BDRVQcowState *s = bs->opaque;
     int64_t total_sectors = bs->total_sectors;
-    int growable = bs->growable;
     bool zero_beyond_eof = bs->zero_beyond_eof;
     int ret;
 
     BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE);
-    bs->growable = 1;
     bs->zero_beyond_eof = false;
     ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
-    bs->growable = growable;
     bs->zero_beyond_eof = zero_beyond_eof;
 
     /* bdrv_co_do_writev will have increased the total_sectors value to include
@@ -2544,15 +2541,12 @@ static int qcow2_load_vmstate(BlockDriverState *bs, uint8_t *buf,
                               int64_t pos, int size)
 {
     BDRVQcowState *s = bs->opaque;
-    int growable = bs->growable;
     bool zero_beyond_eof = bs->zero_beyond_eof;
     int ret;
 
     BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_LOAD);
-    bs->growable = 1;
     bs->zero_beyond_eof = false;
     ret = bdrv_pread(bs, qcow2_vm_state_offset(s) + pos, buf, size);
-    bs->growable = growable;
     bs->zero_beyond_eof = zero_beyond_eof;
 
     return ret;
diff --git a/block/raw-posix.c b/block/raw-posix.c
index e51293a..5debc72 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -984,7 +984,7 @@ static int aio_worker(void *arg)
     switch (aiocb->aio_type & QEMU_AIO_TYPE_MASK) {
     case QEMU_AIO_READ:
         ret = handle_aiocb_rw(aiocb);
-        if (ret >= 0 && ret < aiocb->aio_nbytes && aiocb->bs->growable) {
+        if (ret >= 0 && ret < aiocb->aio_nbytes) {
             iov_memset(aiocb->aio_iov, aiocb->aio_niov, ret,
                       0, aiocb->aio_nbytes - ret);
 
diff --git a/block/raw-win32.c b/block/raw-win32.c
index 06243d7..dae5d2f 100644
--- a/block/raw-win32.c
+++ b/block/raw-win32.c
@@ -101,7 +101,7 @@ static int aio_worker(void *arg)
     switch (aiocb->aio_type & QEMU_AIO_TYPE_MASK) {
     case QEMU_AIO_READ:
         count = handle_aiocb_rw(aiocb);
-        if (count < aiocb->aio_nbytes && aiocb->bs->growable) {
+        if (count < aiocb->aio_nbytes) {
             /* A short read means that we have reached EOF. Pad the buffer
              * with zeros for bytes after EOF. */
             iov_memset(aiocb->aio_iov, aiocb->aio_niov, count,
diff --git a/block/sheepdog.c b/block/sheepdog.c
index be3176f..b84e215 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -2117,7 +2117,7 @@ static coroutine_fn int sd_co_writev(BlockDriverState *bs, int64_t sector_num,
     int64_t offset = (sector_num + nb_sectors) * BDRV_SECTOR_SIZE;
     BDRVSheepdogState *s = bs->opaque;
 
-    if (bs->growable && offset > s->inode.vdi_size) {
+    if (offset > s->inode.vdi_size) {
         ret = sd_truncate(bs, offset);
         if (ret < 0) {
             return ret;
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 7ad1950..b340e7e 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -369,9 +369,6 @@ struct BlockDriverState {
     /* I/O Limits */
     BlockLimits bl;
 
-    /* Whether the disk can expand beyond total_sectors */
-    int growable;
-
     /* Whether produces zeros when read beyond eof */
     bool zero_beyond_eof;
 
-- 
2.1.0

  parent reply	other threads:[~2015-01-26 15:01 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26 15:00 [Qemu-devel] [PATCH v3 00/14] block: Remove "growable", add blk_new_open() Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 01/14] block: Lift some BDS functions to the BlockBackend Max Reitz
2015-01-26 21:48   ` Eric Blake
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 02/14] block: Add blk_new_open() Max Reitz
2015-01-26 21:56   ` Eric Blake
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 03/14] blockdev: Use blk_new_open() in blockdev_init() Max Reitz
2015-01-26 22:37   ` Eric Blake
2015-01-27  2:08     ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 04/14] block/xen: Use blk_new_open() in blk_connect() Max Reitz
2015-01-26 22:46   ` Eric Blake
2015-02-02 18:27   ` Kevin Wolf
2015-02-02 19:41     ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 05/14] qemu-img: Use blk_new_open() in img_open() Max Reitz
2015-01-26 22:47   ` Eric Blake
2015-02-02 18:35   ` Kevin Wolf
2015-02-02 19:42     ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 06/14] qemu-img: Use blk_new_open() in img_rebase() Max Reitz
2015-01-27  3:05   ` Eric Blake
2015-01-27 15:01     ` Max Reitz
2015-02-02 19:00   ` Kevin Wolf
2015-02-02 19:47     ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 07/14] qemu-img: Use BlockBackend as far as possible Max Reitz
2015-01-27  3:38   ` Eric Blake
2015-01-27 15:07     ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 08/14] qemu-nbd: Use blk_new_open() in main() Max Reitz
2015-01-27  4:59   ` Eric Blake
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 09/14] qemu-io: Use blk_new_open() in openfile() Max Reitz
2015-01-27 16:23   ` Eric Blake
2015-02-02 19:34   ` Kevin Wolf
2015-02-02 19:51     ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 10/14] qemu-io: Remove "growable" option Max Reitz
2015-01-27 16:59   ` Eric Blake
2015-01-27 17:04     ` Max Reitz
2015-01-27 17:10       ` Eric Blake
2015-01-27 17:11         ` Max Reitz
2015-02-02 19:36           ` Kevin Wolf
2015-02-02 19:52             ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 11/14] qemu-io: Use BlockBackend Max Reitz
2015-01-27 17:08   ` Eric Blake
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 12/14] block: Clamp BlockBackend requests Max Reitz
2015-01-27 17:15   ` Eric Blake
2015-01-26 15:00 ` Max Reitz [this message]
2015-01-27 17:29   ` [Qemu-devel] [PATCH v3 13/14] block: Remove "growable" from BDS Eric Blake
2015-02-02 19:46   ` Kevin Wolf
2015-02-02 19:54     ` Max Reitz
2015-01-26 15:00 ` [Qemu-devel] [PATCH v3 14/14] block: Keep bdrv_check*_request()'s return value Max Reitz
2015-01-27 17:36   ` Eric Blake
2015-01-26 15:49 ` [Qemu-devel] [PATCH v3 00/14] block: Remove "growable", add blk_new_open() Stefano Stabellini
2015-02-02 19:50 ` Kevin Wolf

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=1422284444-12529-14-git-send-email-mreitz@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=stefano.stabellini@eu.citrix.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 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.