]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
md/md-llbitmap: skip reading rdevs that are not in_sync
authorYu Kuai <yukuai@fnnas.com>
Mon, 23 Feb 2026 02:40:34 +0000 (10:40 +0800)
committerYu Kuai <yukuai@fnnas.com>
Sun, 15 Mar 2026 17:24:59 +0000 (01:24 +0800)
When reading bitmap pages from member disks, the code iterates through
all rdevs and attempts to read from the first available one. However,
it only checks for raid_disk assignment and Faulty flag, missing the
In_sync flag check.

This can cause bitmap data to be read from spare disks that are still
being rebuilt and don't have valid bitmap information yet. Reading
stale or uninitialized bitmap data from such disks can lead to
incorrect dirty bit tracking, potentially causing data corruption
during recovery or normal operation.

Add the In_sync flag check to ensure bitmap pages are only read from
fully synchronized member disks that have valid bitmap data.

Cc: stable@vger.kernel.org
Fixes: 5ab829f1971d ("md/md-llbitmap: introduce new lockless bitmap")
Link: https://lore.kernel.org/linux-raid/20260223024038.3084853-2-yukuai@fnnas.com
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
drivers/md/md-llbitmap.c

index bf398d7476b35a07a36d966c83d5a13d6deff159..6b2d27de152856e0c19dadf3757b84a27db7657a 100644 (file)
@@ -459,7 +459,8 @@ static struct page *llbitmap_read_page(struct llbitmap *llbitmap, int idx)
        rdev_for_each(rdev, mddev) {
                sector_t sector;
 
-               if (rdev->raid_disk < 0 || test_bit(Faulty, &rdev->flags))
+               if (rdev->raid_disk < 0 || test_bit(Faulty, &rdev->flags) ||
+                   !test_bit(In_sync, &rdev->flags))
                        continue;
 
                sector = mddev->bitmap_info.offset +