This is a note to let you know that I've just added the patch titled md/raid1: free the r1bio before waiting for blocked rdev to the 4.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: md-raid1-free-the-r1bio-before-waiting-for-blocked-r.patch and it can be found in the queue-4.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit 3295e1b663214ada8d84fed6ff028ec8e723ca99 Author: Xueshi Hu <xueshi.hu@xxxxxxxxxx> Date: Mon Aug 14 21:53:55 2023 +0800 md/raid1: free the r1bio before waiting for blocked rdev [ Upstream commit 992db13a4aee766c8bfbf046ad15c2db5fa7cab8 ] Raid1 reshape will change mempool and r1conf::raid_disks which are needed to free r1bio. allow_barrier() make a concurrent raid1_reshape() possible. So, free the in-flight r1bio before waiting blocked rdev. Fixes: 6bfe0b499082 ("md: support blocking writes to an array on device failure") Reviewed-by: Yu Kuai <yukuai3@xxxxxxxxxx> Signed-off-by: Xueshi Hu <xueshi.hu@xxxxxxxxxx> Link: https://lore.kernel.org/r/20230814135356.1113639-3-xueshi.hu@xxxxxxxxxx Signed-off-by: Song Liu <song@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 28f78199de3ba..09350e7eab8de 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1329,6 +1329,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, } wait_barrier(conf, bio->bi_iter.bi_sector); + retry_write: r1_bio = alloc_r1bio(mddev, bio); r1_bio->sectors = max_write_sectors; @@ -1350,7 +1351,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, */ disks = conf->raid_disks * 2; - retry_write: blocked_rdev = NULL; rcu_read_lock(); max_sectors = r1_bio->sectors; @@ -1421,7 +1421,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, for (j = 0; j < i; j++) if (r1_bio->bios[j]) rdev_dec_pending(conf->mirrors[j].rdev, mddev); - r1_bio->state = 0; + free_r1bio(r1_bio); allow_barrier(conf, bio->bi_iter.bi_sector); raid1_log(mddev, "wait rdev %d blocked", blocked_rdev->raid_disk); md_wait_for_blocked_rdev(blocked_rdev, mddev);