[Devel] [PATCH RH9 v2 1/2] dm-qcow2: Do not fail .ctr in case dirty bit is set

Kirill Tkhai ktkhai at virtuozzo.com
Fri Nov 12 12:22:39 MSK 2021


The protocol is (#PSBM-128992):

1)Userspace sets DIRTY bit in top delta.

(https://github.com/qemu/qemu/blob/master/docs/interop/qcow2.txt, incompatible_features: dirty bit).

2)Kernel checks that dirty bit is set.

In case of power down or crash, userspace on mount sees that dirty bit is already set
and it calls "qemu-img check -r all file.qcow2".

Note. Q: Why isn't dirty bit set by kernel? A: We have such the mode in driver,
but it is disabled by default. The reason is that "dmsetup reload" creates
new target before old target is destructed, so synchronization of this is not possible.

Currenly, this protocol is broken in kernel: kernel fails, if it sees dirty bit.
This patch fixes the problem.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 drivers/md/dm-qcow2-target.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 30d4275cc21c..2de817154ba3 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -504,7 +504,8 @@ static int qcow2_check_convert_hdr(struct QCowHeader *raw_hdr,
 	if (kernel_sets_dirty_bit !=
 	    !(hdr->incompatible_features & INCOMPATIBLE_FEATURES_DIRTY_BIT))
 		return kernel_sets_dirty_bit ? -EUCLEAN : -ENOLCK;
-	if (hdr->incompatible_features & ~INCOMPATIBLE_FEATURES_EXTL2_BIT)
+	if (hdr->incompatible_features &
+	    ~(INCOMPATIBLE_FEATURES_EXTL2_BIT|INCOMPATIBLE_FEATURES_DIRTY_BIT))
 		return -EOPNOTSUPP;
 	ext_l2 = hdr->incompatible_features & INCOMPATIBLE_FEATURES_EXTL2_BIT;
 




More information about the Devel mailing list