qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, pkrempa@redhat.com, qemu-block@nongnu.org,
	armbru@redhat.com, rjones@redhat.com, vsementsov@virtuozzo.com,
	stefanha@redhat.com
Subject: [PATCH v6 05/11] nbd: Simplify qemu bitmap context name
Date: Tue, 27 Oct 2020 00:05:50 -0500	[thread overview]
Message-ID: <20201027050556.269064-6-eblake@redhat.com> (raw)
In-Reply-To: <20201027050556.269064-1-eblake@redhat.com>

Each dirty bitmap already knows its name; by reducing the scope of the
places where we construct "qemu:dirty-bitmap:NAME" strings, tracking
the name is more localized, and there are fewer per-export fields to
worry about.  This in turn will make it easier for an upcoming patch
to export more than one bitmap at once.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 nbd/server.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/nbd/server.c b/nbd/server.c
index 8d01662b4511..77fdecdf9dec 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -95,7 +95,6 @@ struct NBDExport {
     Notifier eject_notifier;

     BdrvDirtyBitmap *export_bitmap;
-    char *export_bitmap_context;
 };

 static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports);
@@ -871,14 +870,15 @@ static bool nbd_meta_qemu_query(NBDClient *client, NBDExportMetaContexts *meta,
     }

     if (nbd_strshift(&query, "dirty-bitmap:")) {
+        const char *bm_name;
+
         trace_nbd_negotiate_meta_query_parse("dirty-bitmap:");
         if (!meta->exp->export_bitmap) {
             trace_nbd_negotiate_meta_query_skip("no dirty-bitmap exported");
             return true;
         }
-        if (nbd_meta_empty_or_pattern(client,
-                                      meta->exp->export_bitmap_context +
-                                      strlen("qemu:dirty-bitmap:"), query)) {
+        bm_name = bdrv_dirty_bitmap_name(meta->exp->export_bitmap);
+        if (nbd_meta_empty_or_pattern(client, bm_name, query)) {
             meta->bitmap = true;
         }
         return true;
@@ -1004,8 +1004,11 @@ static int nbd_negotiate_meta_queries(NBDClient *client,
     }

     if (meta->bitmap) {
-        ret = nbd_negotiate_send_meta_context(client,
-                                              meta->exp->export_bitmap_context,
+        const char *bm_name = bdrv_dirty_bitmap_name(meta->exp->export_bitmap);
+        g_autofree char *context = g_strdup_printf("qemu:dirty-bitmap:%s",
+                                                   bm_name);
+
+        ret = nbd_negotiate_send_meta_context(client, context,
                                               NBD_META_ID_DIRTY_BITMAP,
                                               errp);
         if (ret < 0) {
@@ -1576,9 +1579,6 @@ static int nbd_export_create(BlockExport *blk_exp, BlockExportOptions *exp_args,
         bdrv_dirty_bitmap_set_busy(bm, true);
         exp->export_bitmap = bm;
         assert(strlen(bitmap) <= BDRV_BITMAP_MAX_NAME_SIZE);
-        exp->export_bitmap_context = g_strdup_printf("qemu:dirty-bitmap:%s",
-                                                     bitmap);
-        assert(strlen(exp->export_bitmap_context) < NBD_MAX_STRING_SIZE);
     }

     blk_add_aio_context_notifier(blk, blk_aio_attached, blk_aio_detach, exp);
@@ -1656,7 +1656,6 @@ static void nbd_export_delete(BlockExport *blk_exp)

     if (exp->export_bitmap) {
         bdrv_dirty_bitmap_set_busy(exp->export_bitmap, false);
-        g_free(exp->export_bitmap_context);
     }
 }

-- 
2.29.0



  parent reply	other threads:[~2020-10-27  5:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27  5:05 [PATCH v6 00/11] Exposing backing-chain allocation over NBD Eric Blake
2020-10-27  5:05 ` [PATCH v6 01/11] block: Simplify QAPI_LIST_ADD Eric Blake
2020-10-27 10:06   ` Vladimir Sementsov-Ogievskiy
2020-10-27 12:58   ` Markus Armbruster
2020-10-27  5:05 ` [PATCH v6 02/11] qapi: Make QAPI_LIST_ADD() public Eric Blake
2020-10-27  5:05 ` [PATCH v6 03/11] nbd: Utilize QAPI_CLONE for type conversion Eric Blake
2020-10-27  5:05 ` [PATCH v6 04/11] nbd: Update qapi to support exporting multiple bitmaps Eric Blake
2020-10-27 10:29   ` Vladimir Sementsov-Ogievskiy
2020-10-27 12:37   ` Peter Krempa
2020-10-27  5:05 ` Eric Blake [this message]
2020-10-27  5:05 ` [PATCH v6 06/11] nbd: Refactor counting of metadata contexts Eric Blake
2020-10-27 10:33   ` Vladimir Sementsov-Ogievskiy
2020-10-27  5:05 ` [PATCH v6 07/11] nbd: Allow export of multiple bitmaps for one device Eric Blake
2020-10-27  5:05 ` [PATCH v6 08/11] block: Return depth level during bdrv_is_allocated_above Eric Blake
2020-10-27 12:05   ` Vladimir Sementsov-Ogievskiy
2020-10-27  5:05 ` [PATCH v6 09/11] nbd: Add new qemu:allocation-depth metadata context Eric Blake
2020-10-27 10:53   ` Vladimir Sementsov-Ogievskiy
2020-10-27  5:05 ` [PATCH v6 10/11] nbd: Add 'qemu-nbd -A' to expose allocation depth Eric Blake
2020-10-27 11:03   ` Vladimir Sementsov-Ogievskiy
2020-10-27  5:05 ` [PATCH v6 11/11] qapi: Use QAPI_LIST_ADD() where possible Eric Blake
2020-10-27  5:53   ` Thomas Huth
2020-10-27  6:39   ` David Gibson
2020-10-27 10:09   ` Markus Armbruster
2020-10-27 12:28     ` Eric Blake
2020-10-27 15:36       ` Markus Armbruster
2020-10-27 18:44         ` Eric Blake
2020-10-27 11:26   ` Dr. David Alan Gilbert
2020-10-27 13:42   ` 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=20201027050556.269064-6-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).