Skip to contentSkip to conversation

md/raid5: Wait sync io to finish before changing group cnt

PATCH Applied Xiao Ni 3 participants 3 messages Nov 6, 2024 – Nov 7, 2024 MD RAID

lore
Share & tools
lore

Xiao Ni

author
#0 lore raw

PATCH 1/1 md/raid5: Wait sync io to finish before changing group cnt

One customer reports a bug: raid5 is hung when changing thread cnt while resync is running. The stripes are all in conf->handle_list and new threads can't handle them.

Commit b39f35ebe86d ("md: don't quiesce in mddev_suspend()") removes pers->quiesce from mddev_suspend/resume. Before this patch, mddev_suspend needs to wait for all ios including sync io to finish. Now it's used to only wait normal io.

In this patch, it calls raid5_quiesce in raid5_store_group_thread_cnt directly to wait all sync requests to finish before changing the group cnt.

Fixes b39f35ebe86d ("md: don't quiesce in mddev_suspend()")
---
 drivers/md/raid5.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/md/raid5.c +4 -0
index dc2ea636d173..2fa1f270fb1d 100644
@@ -7177,6 +7177,8 @@ raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len)
 	err = mddev_suspend_and_lock(mddev);
 	if (err)
 		return err;
+	raid5_quiesce(mddev, true);
+
 	conf = mddev->private;
 	if (!conf)
 		err = -ENODEV;
@@ -7198,6 +7200,8 @@ raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len)
 			kfree(old_groups);
 		}
 	}
+
+	raid5_quiesce(mddev, false);
 	mddev_unlock_and_resume(mddev);
 
 	return err ?: len;
Signature · 1 line
2.32.0 (Apple Git-132)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Xiao Ni

One customer reports a bug: raid5 is hung when changing thread cnt while resync is running. The stripes are all in conf->handle_list and new threads can't handle them.

Commit b39f35ebe86d ("md: don't quiesce in mddev_suspend()") removes pers->quiesce from mddev_suspend/resume. Before this patch, mddev_suspend needs to wait for all ios including sync io to finish. Now it's used to only wait normal io.

In this patch, it calls raid5_quiesce in raid5_store_group_thread_cnt directly to wait all sync requests to finish before changing the group cnt.

Quoted 6 lines
Fixes b39f35ebe86d ("md: don't quiesce in mddev_suspend()")
---
  drivers/md/raid5.c | 4 ++++
  1 file changed, 4 insertions(+)

LGTM

Quoted 23 lines
drivers/md/raid5.c +4 -0
index dc2ea636d173..2fa1f270fb1d 100644
@@ -7177,6 +7177,8 @@ raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len)
  	err = mddev_suspend_and_lock(mddev);
  	if (err)
  		return err;
+	raid5_quiesce(mddev, true);
+
  	conf = mddev->private;
  	if (!conf)
  		err = -ENODEV;
@@ -7198,6 +7200,8 @@ raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len)
  			kfree(old_groups);
  		}
  	}
+
+	raid5_quiesce(mddev, false);
  	mddev_unlock_and_resume(mddev);
 
  	return err ?: len;
maintainer Applied
#2 lore raw
Quoted 15 lines · Yu Kuai
Quoted 13 lines · Xiao Ni

One customer reports a bug: raid5 is hung when changing thread cnt while resync is running. The stripes are all in conf->handle_list and new threads can't handle them.

Commit b39f35ebe86d ("md: don't quiesce in mddev_suspend()") removes pers->quiesce from mddev_suspend/resume. Before this patch, mddev_suspend needs to wait for all ios including sync io to finish. Now it's used to only wait normal io.

In this patch, it calls raid5_quiesce in raid5_store_group_thread_cnt directly to wait all sync requests to finish before changing the group cnt.

Quoted 8 lines
Quoted 6 lines
Fixes b39f35ebe86d ("md: don't quiesce in mddev_suspend()")
---
  drivers/md/raid5.c | 4 ++++
  1 file changed, 4 insertions(+)

LGTM

Applied to md-6.13. Thanks for the fix!

Song