[PATCH v5 3/5] block/io: bdrv_common_block_status_above: support bs == base

Vladimir Sementsov-Ogievskiy posted 5 patches 5 years, 8 months ago
Maintainers: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>, Max Reitz <mreitz@redhat.com>
There is a newer version of this series
[PATCH v5 3/5] block/io: bdrv_common_block_status_above: support bs == base
Posted by Vladimir Sementsov-Ogievskiy 5 years, 8 months ago
We are going to reuse bdrv_common_block_status_above in
bdrv_is_allocated_above. bdrv_is_allocated_above may be called with
include_base == false and still bs == base (for ex. from img_rebase()).

So, support this corner case.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 block/io.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/io.c b/block/io.c
index c3ef387f7e..3df3a5b8ee 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2369,7 +2369,11 @@ bdrv_co_common_block_status_above(BlockDriverState *bs,
     int ret = 0;
     bool first = true;
 
-    assert(include_base || bs != base);
+    if (!include_base && bs == base) {
+        *pnum = bytes;
+        return 0;
+    }
+
     for (p = bs; include_base || p != base; p = backing_bs(p)) {
         ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map,
                                    file);
-- 
2.21.0


Re: [PATCH v5 3/5] block/io: bdrv_common_block_status_above: support bs == base
Posted by Alberto Garcia 5 years, 5 months ago
On Wed 10 Jun 2020 02:04:24 PM CEST, Vladimir Sementsov-Ogievskiy wrote:
> We are going to reuse bdrv_common_block_status_above in
> bdrv_is_allocated_above. bdrv_is_allocated_above may be called with
> include_base == false and still bs == base (for ex. from img_rebase()).
>
> So, support this corner case.

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto