All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze
@ 2020-10-30 20:32 Eric Blake
  2020-10-30 20:32 ` [PULL v2 10/12] block: Return depth level during bdrv_is_allocated_above Eric Blake
  2020-11-02  9:53 ` [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Blake @ 2020-10-30 20:32 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit 9a2ea4f4a7230fe224dee91d9adf2ef872c3d226:

  Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-5.2-pull-request' into staging (2020-10-30 15:49:35 +0000)

are available in the Git repository at:

  https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-10-27-v2

for you to fetch changes up to dbc7b01492371e4a54b92d2b6d968f9b863cc794:

  nbd: Add 'qemu-nbd -A' to expose allocation depth (2020-10-30 15:22:00 -0500)

v2: Respin to fix compilation error due to semantic merge conflict
(only the changed patch is resent)

----------------------------------------------------------------
nbd patches for 2020-10-27

- Tweak the new block-export-add QMP command
- Allow multiple -B options for qemu-nbd
- Add qemu:allocation-depth metadata context as qemu-nbd -A
- Improve iotest use of NBD

----------------------------------------------------------------
Eric Blake (10):
      block: Simplify QAPI_LIST_ADD
      qapi: Add QAPI_LIST_PREPEND() macro
      nbd: Utilize QAPI_CLONE for type conversion
      nbd: Update qapi to support exporting multiple bitmaps
      nbd: Simplify qemu bitmap context name
      nbd: Refactor counting of metadata contexts
      nbd: Allow export of multiple bitmaps for one device
      block: Return depth level during bdrv_is_allocated_above
      nbd: Add new qemu:allocation-depth metadata context
      nbd: Add 'qemu-nbd -A' to expose allocation depth

Max Reitz (2):
      iotests/291: Filter irrelevant parts of img-info
      iotests/291: Stop NBD server

 docs/interop/nbd.txt       |  23 +++--
 docs/system/deprecated.rst |   3 +-
 docs/tools/qemu-nbd.rst    |   8 +-
 qapi/block-core.json       |   7 +-
 qapi/block-export.json     |  46 +++++++---
 block/coroutines.h         |   6 +-
 include/block/nbd.h        |   8 +-
 include/qapi/util.h        |  13 +++
 block/io.c                 |  31 +++++--
 block.c                    |  22 ++---
 block/commit.c             |   2 +-
 block/mirror.c             |   2 +-
 block/nbd.c                |  26 ++++--
 block/stream.c             |   2 +-
 blockdev-nbd.c             |  19 +++--
 nbd/server.c               | 208 +++++++++++++++++++++++++++++++++++----------
 qemu-nbd.c                 |  30 ++++---
 tests/qemu-iotests/291     |  22 +++--
 tests/qemu-iotests/291.out |  20 -----
 tests/qemu-iotests/309     |  77 +++++++++++++++++
 tests/qemu-iotests/309.out |  22 +++++
 tests/qemu-iotests/group   |   1 +
 22 files changed, 446 insertions(+), 152 deletions(-)
 create mode 100755 tests/qemu-iotests/309
 create mode 100644 tests/qemu-iotests/309.out

-- 
2.29.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PULL v2 10/12] block: Return depth level during bdrv_is_allocated_above
  2020-10-30 20:32 [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze Eric Blake
@ 2020-10-30 20:32 ` Eric Blake
  2020-11-02  9:53 ` [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2020-10-30 20:32 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Fam Zheng, Vladimir Sementsov-Ogievskiy,
	open list:Block Jobs, Max Reitz, Stefan Hajnoczi, John Snow

When checking for allocation across a chain, it's already easy to
count the depth within the chain at which the allocation is found.
Instead of throwing that information away, return it to the caller.
Existing callers only cared about allocated/non-allocated, but having
a depth available will be used by NBD in the next patch.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20201027050556.269064-9-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
[eblake: rebase to master]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 block/coroutines.h |  6 ++++--
 block/io.c         | 31 +++++++++++++++++++++++--------
 block/commit.c     |  2 +-
 block/mirror.c     |  2 +-
 block/stream.c     |  2 +-
 5 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/block/coroutines.h b/block/coroutines.h
index 1cb3128b942c..4cfb4946e65e 100644
--- a/block/coroutines.h
+++ b/block/coroutines.h
@@ -47,7 +47,8 @@ bdrv_co_common_block_status_above(BlockDriverState *bs,
                                   int64_t bytes,
                                   int64_t *pnum,
                                   int64_t *map,
-                                  BlockDriverState **file);
+                                  BlockDriverState **file,
+                                  int *depth);
 int generated_co_wrapper
 bdrv_common_block_status_above(BlockDriverState *bs,
                                BlockDriverState *base,
@@ -57,7 +58,8 @@ bdrv_common_block_status_above(BlockDriverState *bs,
                                int64_t bytes,
                                int64_t *pnum,
                                int64_t *map,
-                               BlockDriverState **file);
+                               BlockDriverState **file,
+                               int *depth);

 int coroutine_fn bdrv_co_readv_vmstate(BlockDriverState *bs,
                                        QEMUIOVector *qiov, int64_t pos);
diff --git a/block/io.c b/block/io.c
index 9918f2499c19..ec5e152bb70f 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2362,20 +2362,28 @@ bdrv_co_common_block_status_above(BlockDriverState *bs,
                                   int64_t bytes,
                                   int64_t *pnum,
                                   int64_t *map,
-                                  BlockDriverState **file)
+                                  BlockDriverState **file,
+                                  int *depth)
 {
     int ret;
     BlockDriverState *p;
     int64_t eof = 0;
+    int dummy;

     assert(!include_base || base); /* Can't include NULL base */

+    if (!depth) {
+        depth = &dummy;
+    }
+    *depth = 0;
+
     if (!include_base && bs == base) {
         *pnum = bytes;
         return 0;
     }

     ret = bdrv_co_block_status(bs, want_zero, offset, bytes, pnum, map, file);
+    ++*depth;
     if (ret < 0 || *pnum == 0 || ret & BDRV_BLOCK_ALLOCATED || bs == base) {
         return ret;
     }
@@ -2392,6 +2400,7 @@ bdrv_co_common_block_status_above(BlockDriverState *bs,
     {
         ret = bdrv_co_block_status(p, want_zero, offset, bytes, pnum, map,
                                    file);
+        ++*depth;
         if (ret < 0) {
             return ret;
         }
@@ -2450,7 +2459,7 @@ int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base,
                             int64_t *map, BlockDriverState **file)
 {
     return bdrv_common_block_status_above(bs, base, false, true, offset, bytes,
-                                          pnum, map, file);
+                                          pnum, map, file, NULL);
 }

 int bdrv_block_status(BlockDriverState *bs, int64_t offset, int64_t bytes,
@@ -2478,7 +2487,7 @@ int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,
     }

     ret = bdrv_common_block_status_above(bs, NULL, false, false, offset,
-                                         bytes, &pnum, NULL, NULL);
+                                         bytes, &pnum, NULL, NULL, NULL);

     if (ret < 0) {
         return ret;
@@ -2495,7 +2504,7 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset,

     ret = bdrv_common_block_status_above(bs, bs, true, false, offset,
                                          bytes, pnum ? pnum : &dummy, NULL,
-                                         NULL);
+                                         NULL, NULL);
     if (ret < 0) {
         return ret;
     }
@@ -2505,8 +2514,9 @@ int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t offset,
 /*
  * Given an image chain: ... -> [BASE] -> [INTER1] -> [INTER2] -> [TOP]
  *
- * Return 1 if (a prefix of) the given range is allocated in any image
- * between BASE and TOP (BASE is only included if include_base is set).
+ * Return a positive depth if (a prefix of) the given range is allocated
+ * in any image between BASE and TOP (BASE is only included if include_base
+ * is set).  Depth 1 is TOP, 2 is the first backing layer, and so forth.
  * BASE can be NULL to check if the given offset is allocated in any
  * image of the chain.  Return 0 otherwise, or negative errno on
  * failure.
@@ -2523,13 +2533,18 @@ int bdrv_is_allocated_above(BlockDriverState *top,
                             bool include_base, int64_t offset,
                             int64_t bytes, int64_t *pnum)
 {
+    int depth;
     int ret = bdrv_common_block_status_above(top, base, include_base, false,
-                                             offset, bytes, pnum, NULL, NULL);
+                                             offset, bytes, pnum, NULL, NULL,
+                                             &depth);
     if (ret < 0) {
         return ret;
     }

-    return !!(ret & BDRV_BLOCK_ALLOCATED);
+    if (ret & BDRV_BLOCK_ALLOCATED) {
+        return depth;
+    }
+    return 0;
 }

 int coroutine_fn
diff --git a/block/commit.c b/block/commit.c
index 1e85c306cc41..71db7ba7472e 100644
--- a/block/commit.c
+++ b/block/commit.c
@@ -156,7 +156,7 @@ static int coroutine_fn commit_run(Job *job, Error **errp)
         /* Copy if allocated above the base */
         ret = bdrv_is_allocated_above(blk_bs(s->top), s->base_overlay, true,
                                       offset, COMMIT_BUFFER_SIZE, &n);
-        copy = (ret == 1);
+        copy = (ret > 0);
         trace_commit_one_iteration(s, offset, n, ret);
         if (copy) {
             assert(n < SIZE_MAX);
diff --git a/block/mirror.c b/block/mirror.c
index 26acf4af6fb7..8e1ad6eceb57 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -846,7 +846,7 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s)
         }

         assert(count);
-        if (ret == 1) {
+        if (ret > 0) {
             bdrv_set_dirty_bitmap(s->dirty_bitmap, offset, count);
         }
         offset += count;
diff --git a/block/stream.c b/block/stream.c
index 8ce6729a33da..236384f2f739 100644
--- a/block/stream.c
+++ b/block/stream.c
@@ -167,7 +167,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp)
                 n = len - offset;
             }

-            copy = (ret == 1);
+            copy = (ret > 0);
         }
         trace_stream_one_iteration(s, offset, n, ret);
         if (copy) {
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze
  2020-10-30 20:32 [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze Eric Blake
  2020-10-30 20:32 ` [PULL v2 10/12] block: Return depth level during bdrv_is_allocated_above Eric Blake
@ 2020-11-02  9:53 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2020-11-02  9:53 UTC (permalink / raw)
  To: Eric Blake; +Cc: QEMU Developers

On Fri, 30 Oct 2020 at 20:34, Eric Blake <eblake@redhat.com> wrote:
>
> The following changes since commit 9a2ea4f4a7230fe224dee91d9adf2ef872c3d226:
>
>   Merge remote-tracking branch 'remotes/vivier2/tags/trivial-branch-for-5.2-pull-request' into staging (2020-10-30 15:49:35 +0000)
>
> are available in the Git repository at:
>
>   https://repo.or.cz/qemu/ericb.git tags/pull-nbd-2020-10-27-v2
>
> for you to fetch changes up to dbc7b01492371e4a54b92d2b6d968f9b863cc794:
>
>   nbd: Add 'qemu-nbd -A' to expose allocation depth (2020-10-30 15:22:00 -0500)
>
> v2: Respin to fix compilation error due to semantic merge conflict
> (only the changed patch is resent)
>
> ----------------------------------------------------------------
> nbd patches for 2020-10-27
>
> - Tweak the new block-export-add QMP command
> - Allow multiple -B options for qemu-nbd
> - Add qemu:allocation-depth metadata context as qemu-nbd -A
> - Improve iotest use of NBD
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.2
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-02 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30 20:32 [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze Eric Blake
2020-10-30 20:32 ` [PULL v2 10/12] block: Return depth level during bdrv_is_allocated_above Eric Blake
2020-11-02  9:53 ` [PULL v2 00/12] NBD patches for 2020-10-27 soft-freeze Peter Maydell

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.