[Devel] [PATCH RHEL9 COMMIT] dm-qcow2: Do not fail .ctr in case dirty bit is set

Konstantin Khorenko khorenko at virtuozzo.com
Fri Nov 12 15:34:47 MSK 2021


The commit is pushed to "branch-rh9-5.14.vz9.1.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.10.25
------>
commit ffc7820251decf8ea17d4fd19b4b70467b9a9090
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date:   Fri Nov 12 15:34:47 2021 +0300

    dm-qcow2: Do not fail .ctr in case dirty bit is set
    
    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".
    
    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