Commit 10554bbf authored by Zheng Qixing's avatar Zheng Qixing
Browse files

md/raid1: fix bitmap update when all write requests fail

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBKHTZ



------------------------

When writing to a RAID1 array where all member disks  have bad sectors
at the target location, the bitmap update is skipped because all bios[]
are NULL, leading to bitmap counter inconsistency. This can cause
subsequent I/O operations to hang while waiting for bitmap counter
to reach the expected value.

Fix this by updating the bitmap when all member disks have bad sectors.

Fixes: 1f68f0c4 ("md/raid1: avoid writing to known-bad blocks on known-bad drives.")
Signed-off-by: default avatarZheng Qixing <zhengqixing@huawei.com>
parent df354167
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1551,6 +1551,13 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
		}
	}

	/*
	 * Corresponding to md_bitmap_endwrite() from close_write(), in the case
	 * io range from all member disks are badblocks.
	 */
	if (first_clone)
		md_bitmap_startwrite(bitmap, r1_bio->sector, r1_bio->sectors, 0);

	r1_bio_write_done(r1_bio);

	/* In case raid1d snuck in to freeze_array */