All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com,
	ronniesahlberg@gmail.com, codyprime@gmail.com, sw@weilnetz.de,
	pl@kamp.de, qemu-devel@nongnu.org, mreitz@redhat.com,
	stefanha@redhat.com, pbonzini@redhat.com, den@openvz.org
Subject: [PATCH v3 02/10] block: inline bdrv_unallocated_blocks_are_zero()
Date: Thu, 28 May 2020 12:43:57 +0300	[thread overview]
Message-ID: <20200528094405.145708-3-vsementsov@virtuozzo.com> (raw)
In-Reply-To: <20200528094405.145708-1-vsementsov@virtuozzo.com>

The function has only one user: bdrv_co_block_status(). Inline it to
simplify reviewing of the following patches, which will finally drop
unallocated_blocks_are_zero field too.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 include/block/block.h |  1 -
 block.c               | 15 ---------------
 block/io.c            | 11 ++++++++---
 3 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/include/block/block.h b/include/block/block.h
index 25e299605e..68699ebbfa 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -488,7 +488,6 @@ int bdrv_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes);
 int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes);
 int bdrv_has_zero_init_1(BlockDriverState *bs);
 int bdrv_has_zero_init(BlockDriverState *bs);
-bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs);
 bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
 int bdrv_block_status(BlockDriverState *bs, int64_t offset,
                       int64_t bytes, int64_t *pnum, int64_t *map,
diff --git a/block.c b/block.c
index 8416376c9b..34adf1298f 100644
--- a/block.c
+++ b/block.c
@@ -5408,21 +5408,6 @@ int bdrv_has_zero_init(BlockDriverState *bs)
     return 0;
 }
 
-bool bdrv_unallocated_blocks_are_zero(BlockDriverState *bs)
-{
-    BlockDriverInfo bdi;
-
-    if (bs->backing) {
-        return false;
-    }
-
-    if (bdrv_get_info(bs, &bdi) == 0) {
-        return bdi.unallocated_blocks_are_zero;
-    }
-
-    return false;
-}
-
 bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
 {
     if (!(bs->open_flags & BDRV_O_UNMAP)) {
diff --git a/block/io.c b/block/io.c
index 121ce17a49..6f9507f718 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2387,15 +2387,20 @@ static int coroutine_fn bdrv_co_block_status(BlockDriverState *bs,
     if (ret & (BDRV_BLOCK_DATA | BDRV_BLOCK_ZERO)) {
         ret |= BDRV_BLOCK_ALLOCATED;
     } else if (want_zero) {
-        if (bdrv_unallocated_blocks_are_zero(bs)) {
-            ret |= BDRV_BLOCK_ZERO;
-        } else if (bs->backing) {
+        if (bs->backing) {
             BlockDriverState *bs2 = bs->backing->bs;
             int64_t size2 = bdrv_getlength(bs2);
 
             if (size2 >= 0 && offset >= size2) {
                 ret |= BDRV_BLOCK_ZERO;
             }
+        } else {
+            BlockDriverInfo bdi;
+            int ret2 = bdrv_get_info(bs, &bdi);
+
+            if (ret2 == 0 && bdi.unallocated_blocks_are_zero) {
+                ret |= BDRV_BLOCK_ZERO;
+            }
         }
     }
 
-- 
2.18.0



  parent reply	other threads:[~2020-05-28  9:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28  9:43 [PATCH v3 00/10] drop unallocated_blocks_are_zero Vladimir Sementsov-Ogievskiy
2020-05-28  9:43 ` [PATCH v3 01/10] qemu-img: convert: don't use unallocated_blocks_are_zero Vladimir Sementsov-Ogievskiy
2020-05-28  9:43 ` Vladimir Sementsov-Ogievskiy [this message]
2020-05-28  9:43 ` [PATCH v3 03/10] block/vdi: return ZERO block-status when appropriate Vladimir Sementsov-Ogievskiy
2020-05-28  9:43 ` [PATCH v3 04/10] block/vpc: " Vladimir Sementsov-Ogievskiy
2020-07-06  8:28   ` Max Reitz
2020-07-06  9:17     ` Vladimir Sementsov-Ogievskiy
2020-05-28  9:44 ` [PATCH v3 05/10] block/crypto: drop unallocated_blocks_are_zero Vladimir Sementsov-Ogievskiy
2020-05-28  9:44 ` [PATCH v3 06/10] block/iscsi: " Vladimir Sementsov-Ogievskiy
2020-05-28  9:44 ` [PATCH v3 07/10] block/file-posix: " Vladimir Sementsov-Ogievskiy
2020-05-28  9:44 ` [PATCH v3 08/10] block/vhdx: " Vladimir Sementsov-Ogievskiy
2020-05-28  9:44 ` [PATCH v3 09/10] block: " Vladimir Sementsov-Ogievskiy
2020-05-28  9:44 ` [PATCH v3 10/10] qed: Simplify backing reads Vladimir Sementsov-Ogievskiy
2020-07-03 14:06 ` [PATCH v3 00/10] drop unallocated_blocks_are_zero Max Reitz
2020-07-03 18:08   ` Vladimir Sementsov-Ogievskiy

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=20200528094405.145708-3-vsementsov@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=codyprime@gmail.com \
    --cc=den@openvz.org \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    /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.