[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v4 4/6] nbd/server: implement dirty bitmap expor
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [Qemu-block] [PATCH v4 4/6] nbd/server: implement dirty bitmap export |
Date: |
Fri, 8 Jun 2018 20:33:33 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
08.06.2018 18:23, Vladimir Sementsov-Ogievskiy wrote:
Handle new NBD meta namespace: "qemu", and corresponding queries:
"qemu:dirty-bitmap:<export bitmap name>".
With new metadata context negotiated, BLOCK_STATUS query will reply
with dirty-bitmap data, converted to extents. New public function
nbd_export_bitmap selects bitmap to export. For now, only one bitmap
may be exported.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
[...]
+static unsigned bitmap_to_extents(BdrvDirtyBitmap *bitmap, uint64_t offset,
+ uint64_t length, NBDExtent *extents,
+ unsigned nb_extents)
+{
+ uint64_t begin = offset, end;
+ uint64_t overall_end = offset + length;
+ unsigned i = 0;
+ BdrvDirtyBitmapIter *it;
+ bool dirty;
+
+ bdrv_dirty_bitmap_lock(bitmap);
+
+ it = bdrv_dirty_iter_new(bitmap);
+ dirty = bdrv_get_dirty_locked(NULL, bitmap, offset);
+
+ while (begin < overall_end && i < nb_extents) {
+ if (dirty) {
+ end = bdrv_dirty_bitmap_next_zero(bitmap, begin);
+ } else {
+ bdrv_set_dirty_iter(it, begin);
+ end = bdrv_dirty_iter_next(it);
+ }
+ if (end == -1) {
+ end = overall_end;
here better is bdrv_dirty_bitmap_size()
+ }
and here we should crop it to overall_end in case of REQ_ONE
+
+ i += add_extents(extents + i, nb_extents - i, end - begin,
+ dirty ? NBD_STATE_DIRTY : 0);
+ begin = end;
+ dirty = !dirty;
+ }
+
+ bdrv_dirty_iter_free(it);
+
+ bdrv_dirty_bitmap_unlock(bitmap);
+
+ return i;
+}
--
Best regards,
Vladimir
- [Qemu-block] [PATCH v4 0/6] NBD export, Vladimir Sementsov-Ogievskiy, 2018/06/08
- [Qemu-block] [PATCH v4 1/6] nbd/server: fix trace, Vladimir Sementsov-Ogievskiy, 2018/06/08
- [Qemu-block] [PATCH v4 4/6] nbd/server: implement dirty bitmap export, Vladimir Sementsov-Ogievskiy, 2018/06/08
- Re: [Qemu-block] [PATCH v4 4/6] nbd/server: implement dirty bitmap export,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH v4 5/6] qapi: new qmp command nbd-server-add-bitmap, Vladimir Sementsov-Ogievskiy, 2018/06/08
- [Qemu-block] [PATCH v4 2/6] nbd/server: refactor NBDExportMetaContexts, Vladimir Sementsov-Ogievskiy, 2018/06/08
- [Qemu-block] [PATCH v4 6/6] docs/interop: add nbd.txt, Vladimir Sementsov-Ogievskiy, 2018/06/08
- [Qemu-block] [PATCH v4 3/6] nbd/server: add nbd_meta_empty_or_pattern helper, Vladimir Sementsov-Ogievskiy, 2018/06/08
- Re: [Qemu-block] [Qemu-devel] [PATCH v4 0/6] NBD export, no-reply, 2018/06/08
- Re: [Qemu-block] [Qemu-devel] [PATCH v4 0/6] NBD export, no-reply, 2018/06/09