diff mbox series

[v2,1/3] md/raid1: gave up reshape in case there's queued io

Message ID 20230709102956.1716708-2-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>

When an IO error happens, reschedule_retry() will increase
r1conf::nr_queued, which makes freeze_array() unblocked. However, before
all r1bio in the memory pool are released, the memory pool should not be
modified.

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

Comments

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

在 2023/07/09 18:29, Xueshi Hu 写道:
> From: Xueshi Hu <xueshi.hu@smartx.com>
> 
> When an IO error happens, reschedule_retry() will increase
> r1conf::nr_queued, which makes freeze_array() unblocked. However, before
> all r1bio in the memory pool are released, the memory pool should not be
> modified.
> 

I didn't recieve these emails directly, I just notice this patchse...

It's right this is a problem, but I'm not sure about the fix, this fix
will work fine for the case that new reshape is started, however, for
the case that reshape is interrupted, this might cause that
md_check_recovery() can't continue to reshape atomically.

Perhaps raid1_reshape() can be improved that if oldpool and newpool is
the same, don't reallocate it.

Thanks,
Kuai
> Signed-off-by: Xueshi Hu <xueshi.hu@smartx.com>
> ---
>   drivers/md/raid1.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index dd25832eb045..ce48cb3af301 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -3298,6 +3298,13 @@ static int raid1_reshape(struct mddev *mddev)
>   
>   	freeze_array(conf, 0);
>   
> +	if (unlikely(atomic_read(conf->nr_queued))) {
> +		kfree(newpoolinfo);
> +		mempool_exit(&newpool);
> +		unfreeze_array(conf);
> +		return -EBUSY;
> +	}
> +
>   	/* ok, everything is stopped */
>   	oldpool = conf->r1bio_pool;
>   	conf->r1bio_pool = newpool;
>
diff mbox series

Patch

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index dd25832eb045..ce48cb3af301 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3298,6 +3298,13 @@  static int raid1_reshape(struct mddev *mddev)
 
 	freeze_array(conf, 0);
 
+	if (unlikely(atomic_read(conf->nr_queued))) {
+		kfree(newpoolinfo);
+		mempool_exit(&newpool);
+		unfreeze_array(conf);
+		return -EBUSY;
+	}
+
 	/* ok, everything is stopped */
 	oldpool = conf->r1bio_pool;
 	conf->r1bio_pool = newpool;