]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb
authorHou Tao <houtao1@huawei.com>
Mon, 6 Nov 2017 02:11:25 +0000 (10:11 +0800)
committerShaohua Li <shli@fb.com>
Thu, 9 Nov 2017 15:30:50 +0000 (07:30 -0800)
For a RAID1 device using a file-based bitmap, if a bitmap write error
occurs but the later writes succeed, it's possible both BITMAP_STALE
and BITMAP_WRITE_ERROR bits will be written to the bitmap super block,
the BITMAP_STALE bit will be handled properly and be cleared, but the
BITMAP_WRITE_ERROR bit in sb->flags will make bitmap_create() to fail.

So clear it to protect against the write failure-and-then-recovery case.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/md-bitmap.c

index d1b3b60669ea6380efccd13c27eef7904b9fa8a0..a60e46529d9f4200b9da47141c652d9807bf034e 100644 (file)
@@ -459,7 +459,11 @@ void bitmap_update_sb(struct bitmap *bitmap)
                /* rocking back to read-only */
                bitmap->events_cleared = bitmap->mddev->events;
        sb->events_cleared = cpu_to_le64(bitmap->events_cleared);
-       sb->state = cpu_to_le32(bitmap->flags);
+       /*
+        * clear BITMAP_WRITE_ERROR bit to protect against the case that
+        * a bitmap write error occurred but the later writes succeeded.
+        */
+       sb->state = cpu_to_le32(bitmap->flags & ~BIT(BITMAP_WRITE_ERROR));
        /* Just in case these have been changed via sysfs: */
        sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
        sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);