Commit 625af781 authored by Shaohua Li's avatar Shaohua Li Committed by Kamal Mostafa

RAID5: check_reshape() shouldn't call mddev_suspend

commit 27a353c0 upstream.

check_reshape() is called from raid5d thread. raid5d thread shouldn't
call mddev_suspend(), because mddev_suspend() waits for all IO finish
but IO is handled in raid5d thread, we could easily deadlock here.

This issue is introduced by
738a2738 ("md/raid5: fix allocation of 'scribble' array.")
Reported-and-tested-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent b312592c
...@@ -2091,6 +2091,14 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors) ...@@ -2091,6 +2091,14 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
unsigned long cpu; unsigned long cpu;
int err = 0; int err = 0;
/*
* Never shrink. And mddev_suspend() could deadlock if this is called
* from raid5d. In that case, scribble_disks and scribble_sectors
* should equal to new_disks and new_sectors
*/
if (conf->scribble_disks >= new_disks &&
conf->scribble_sectors >= new_sectors)
return 0;
mddev_suspend(conf->mddev); mddev_suspend(conf->mddev);
get_online_cpus(); get_online_cpus();
for_each_present_cpu(cpu) { for_each_present_cpu(cpu) {
...@@ -2112,6 +2120,10 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors) ...@@ -2112,6 +2120,10 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
} }
put_online_cpus(); put_online_cpus();
mddev_resume(conf->mddev); mddev_resume(conf->mddev);
if (!err) {
conf->scribble_disks = new_disks;
conf->scribble_sectors = new_sectors;
}
return err; return err;
} }
...@@ -6379,6 +6391,12 @@ static int raid5_alloc_percpu(struct r5conf *conf) ...@@ -6379,6 +6391,12 @@ static int raid5_alloc_percpu(struct r5conf *conf)
} }
put_online_cpus(); put_online_cpus();
if (!err) {
conf->scribble_disks = max(conf->raid_disks,
conf->previous_raid_disks);
conf->scribble_sectors = max(conf->chunk_sectors,
conf->prev_chunk_sectors);
}
return err; return err;
} }
......
...@@ -501,6 +501,8 @@ struct r5conf { ...@@ -501,6 +501,8 @@ struct r5conf {
* conversions * conversions
*/ */
} __percpu *percpu; } __percpu *percpu;
int scribble_disks;
int scribble_sectors;
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
struct notifier_block cpu_notify; struct notifier_block cpu_notify;
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment