Skip to content

Commit b42cd7b

Browse files
YuKuai-huaweiliu-song-6
authored andcommitted
md/raid5: replace suspend with quiesce() callback
raid5 is the only personality to suspend array in check_reshape() and start_reshape() callback, suspend and quiesce() callback can both wait for all normal io to be done, and prevent new io to be dispatched, the difference is that suspend is implemented in common layer, and quiesce() callback is implemented in raid5. In order to cleanup all the usage of mddev_suspend(), the new apis __mddev_suspend() need to be called before 'reconfig_mutex' is held, and it's not good to affect all the personalities in common layer just for raid5. Hence replace suspend with quiesce() callaback, prepare to reomove all the users of mddev_suspend(). Signed-off-by: Yu Kuai <[email protected]> Signed-off-by: Song Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1978c74 commit b42cd7b

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

drivers/md/raid5.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ MODULE_PARM_DESC(devices_handle_discard_safely,
7070
"Set to Y if all devices in each array reliably return zeroes on reads from discarded regions");
7171
static struct workqueue_struct *raid5_wq;
7272

73+
static void raid5_quiesce(struct mddev *mddev, int quiesce);
74+
7375
static inline struct hlist_head *stripe_hash(struct r5conf *conf, sector_t sect)
7476
{
7577
int hash = (sect >> RAID5_STRIPE_SHIFT(conf)) & HASH_MASK;
@@ -2492,15 +2494,12 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
24922494
unsigned long cpu;
24932495
int err = 0;
24942496

2495-
/*
2496-
* Never shrink. And mddev_suspend() could deadlock if this is called
2497-
* from raid5d. In that case, scribble_disks and scribble_sectors
2498-
* should equal to new_disks and new_sectors
2499-
*/
2497+
/* Never shrink. */
25002498
if (conf->scribble_disks >= new_disks &&
25012499
conf->scribble_sectors >= new_sectors)
25022500
return 0;
2503-
mddev_suspend(conf->mddev);
2501+
2502+
raid5_quiesce(conf->mddev, true);
25042503
cpus_read_lock();
25052504

25062505
for_each_present_cpu(cpu) {
@@ -2514,7 +2513,8 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
25142513
}
25152514

25162515
cpus_read_unlock();
2517-
mddev_resume(conf->mddev);
2516+
raid5_quiesce(conf->mddev, false);
2517+
25182518
if (!err) {
25192519
conf->scribble_disks = new_disks;
25202520
conf->scribble_sectors = new_sectors;
@@ -8551,8 +8551,8 @@ static int raid5_start_reshape(struct mddev *mddev)
85518551
* the reshape wasn't running - like Discard or Read - have
85528552
* completed.
85538553
*/
8554-
mddev_suspend(mddev);
8555-
mddev_resume(mddev);
8554+
raid5_quiesce(mddev, true);
8555+
raid5_quiesce(mddev, false);
85568556

85578557
/* Add some new drives, as many as will fit.
85588558
* We know there are enough to make the newly sized array work.

0 commit comments

Comments
 (0)