[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 5/6] blockdev: use state.bitmap in block-dirty-bitmap-add acti
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v9 5/6] blockdev: use state.bitmap in block-dirty-bitmap-add action |
Date: |
Wed, 10 May 2023 18:06:23 +0300 |
Other bitmap related actions use the .bitmap pointer in .abort action,
let's do same here:
1. It helps further refactoring, as bitmap-add is the only bitmap
action that uses state.action in .abort
2. It must be safe: transaction actions rely on the fact that on
.abort() the state is the same as at the end of .prepare(), so that
in .abort() we could precisely rollback the changes done by
.prepare().
The only way to remove the bitmap during transaction should be
block-dirty-bitmap-remove action, but it postpones actual removal to
.commit(), so we are OK on any rollback path. (Note also that
bitmap-remove is the only bitmap action that has .commit() phase,
except for simple g_free the state on .clean())
3. Again, other bitmap actions behave this way: keep the bitmap pointer
during the transaction.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
blockdev.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 6bcf80b18b..10003bdc52 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1998,7 +1998,8 @@ static void block_dirty_bitmap_add_action(BlkActionState
*common,
&local_err);
if (!local_err) {
- state->prepared = true;
+ state->bitmap = block_dirty_bitmap_lookup(action->node, action->name,
+ NULL, &error_abort);
} else {
error_propagate(errp, local_err);
}
@@ -2006,15 +2007,10 @@ static void
block_dirty_bitmap_add_action(BlkActionState *common,
static void block_dirty_bitmap_add_abort(void *opaque)
{
- BlockDirtyBitmapAdd *action;
BlockDirtyBitmapState *state = opaque;
- action = state->common.action->u.block_dirty_bitmap_add.data;
- /* Should not be able to fail: IF the bitmap was added via .prepare(),
- * then the node reference and bitmap name must have been valid.
- */
- if (state->prepared) {
- qmp_block_dirty_bitmap_remove(action->node, action->name,
&error_abort);
+ if (state->bitmap) {
+ bdrv_release_dirty_bitmap(state->bitmap);
}
}
--
2.34.1
- [PATCH v9 0/6] block: refactor blockdev transactions, Vladimir Sementsov-Ogievskiy, 2023/05/10
- [PATCH v9 5/6] blockdev: use state.bitmap in block-dirty-bitmap-add action,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v9 2/6] blockdev: transactions: rename some things, Vladimir Sementsov-Ogievskiy, 2023/05/10
- [PATCH v9 1/6] blockdev: refactor transaction to use Transaction API, Vladimir Sementsov-Ogievskiy, 2023/05/10
- [PATCH v9 4/6] blockdev: transaction: refactor handling transaction properties, Vladimir Sementsov-Ogievskiy, 2023/05/10
- [PATCH v9 3/6] blockdev: qmp_transaction: refactor loop to classic for, Vladimir Sementsov-Ogievskiy, 2023/05/10
- [PATCH v9 6/6] blockdev: qmp_transaction: drop extra generic layer, Vladimir Sementsov-Ogievskiy, 2023/05/10
- Re: [PATCH v9 0/6] block: refactor blockdev transactions, Vladimir Sementsov-Ogievskiy, 2023/05/10
- Re: [PATCH v9 0/6] block: refactor blockdev transactions, Kevin Wolf, 2023/05/11