diff mbox series

[v2,3/3] md/raid1: keep holding the barrier in handle_read_error()

Message ID 20230709102956.1716708-4-hubachelar@gmail.com (mailing list archive)
State Superseded, archived
Headers show
Series md/raid1: don't change mempool if in-flight r1bio exists | expand

Commit Message

Xueshi Hu July 9, 2023, 10:29 a.m. UTC
From: Xueshi Hu <xueshi.hu@smartx.com>

Raid reshape changes the r1conf::raid_disks and mempool. Keep holding the
barrier in handle_read_error() to avoid raid reshape.

Signed-off-by: Xueshi Hu <xueshi.hu@smartx.com>
---
 drivers/md/raid1.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

Comments

Yu Kuai July 11, 2023, 12:37 p.m. UTC | #1
Hi,

在 2023/07/09 18:29, Xueshi Hu 写道:
> From: Xueshi Hu <xueshi.hu@smartx.com>
> 
> Raid reshape changes the r1conf::raid_disks and mempool. Keep holding the
> barrier in handle_read_error() to avoid raid reshape.
> 
> Signed-off-by: Xueshi Hu <xueshi.hu@smartx.com>
> ---
>   drivers/md/raid1.c | 25 ++++++++++++-------------
>   1 file changed, 12 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index 6c54786067b4..43a9c095f94d 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -1240,20 +1240,20 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio,
>   		rcu_read_unlock();
>   	}
>   
> -	/*
> -	 * Still need barrier for READ in case that whole
> -	 * array is frozen.
> -	 */
> -	if (!wait_read_barrier(conf, bio->bi_iter.bi_sector,
> -				bio->bi_opf & REQ_NOWAIT)) {
> -		bio_wouldblock_error(bio);
> -		return;
> -	}
> -
> -	if (!r1_bio)
> +	if (!r1_bio) {
> +		/*
> +		 * Still need barrier for READ in case that whole
> +		 * array is frozen.
> +		 */
> +		if (!wait_read_barrier(conf, bio->bi_iter.bi_sector,
> +					bio->bi_opf & REQ_NOWAIT)) {
> +			bio_wouldblock_error(bio);
> +			return;
> +		}
>   		r1_bio = alloc_r1bio(mddev, bio);
> -	else
> +	} else
>   		init_r1bio(r1_bio, mddev, bio);
> +
>   	r1_bio->sectors = max_read_sectors;
>   
>   	/*
> @@ -2527,7 +2527,6 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
>   	}
>   
>   	rdev_dec_pending(rdev, conf->mddev);
> -	allow_barrier(conf, r1_bio->sector);

I think it's better to just move allow_barrier() to after
raid1_read_request().

Thanks,
Kuai
>   	bio = r1_bio->master_bio;
>   
>   	/* Reuse the old r1_bio so that the IO_BLOCKED settings are preserved */
>
diff mbox series

Patch

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 6c54786067b4..43a9c095f94d 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1240,20 +1240,20 @@  static void raid1_read_request(struct mddev *mddev, struct bio *bio,
 		rcu_read_unlock();
 	}
 
-	/*
-	 * Still need barrier for READ in case that whole
-	 * array is frozen.
-	 */
-	if (!wait_read_barrier(conf, bio->bi_iter.bi_sector,
-				bio->bi_opf & REQ_NOWAIT)) {
-		bio_wouldblock_error(bio);
-		return;
-	}
-
-	if (!r1_bio)
+	if (!r1_bio) {
+		/*
+		 * Still need barrier for READ in case that whole
+		 * array is frozen.
+		 */
+		if (!wait_read_barrier(conf, bio->bi_iter.bi_sector,
+					bio->bi_opf & REQ_NOWAIT)) {
+			bio_wouldblock_error(bio);
+			return;
+		}
 		r1_bio = alloc_r1bio(mddev, bio);
-	else
+	} else
 		init_r1bio(r1_bio, mddev, bio);
+
 	r1_bio->sectors = max_read_sectors;
 
 	/*
@@ -2527,7 +2527,6 @@  static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)
 	}
 
 	rdev_dec_pending(rdev, conf->mddev);
-	allow_barrier(conf, r1_bio->sector);
 	bio = r1_bio->master_bio;
 
 	/* Reuse the old r1_bio so that the IO_BLOCKED settings are preserved */