summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2016-02-24 17:38:28 -0800
committerSasha Levin <sasha.levin@oracle.com>2016-04-18 08:50:41 -0400
commit503f8305ab1b82d8788a2f161e7c52c0c0f6aeac (patch)
tree579af13d6f803407abe40862735ac942dfb829b3 /drivers
parent5255a738ee6ecc0e479728efe5668efd64901197 (diff)
RAID5: check_reshape() shouldn't call mddev_suspend
[ Upstream commit 27a353c026a879a1001e5eac4bda75b16262c44a ] 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 738a273 ("md/raid5: fix allocation of 'scribble' array.") Cc: stable@vger.kernel.org (v4.1+) Reported-and-tested-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Reviewed-by: NeilBrown <neilb@suse.com> Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/raid5.c18
-rw-r--r--drivers/md/raid5.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index afa7fca3a21c..c6f44c96db88 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -2080,6 +2080,14 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
unsigned long cpu;
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);
get_online_cpus();
for_each_present_cpu(cpu) {
@@ -2101,6 +2109,10 @@ static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
}
put_online_cpus();
mddev_resume(conf->mddev);
+ if (!err) {
+ conf->scribble_disks = new_disks;
+ conf->scribble_sectors = new_sectors;
+ }
return err;
}
@@ -6366,6 +6378,12 @@ static int raid5_alloc_percpu(struct r5conf *conf)
}
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;
}
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index 03472fbbd882..d31ed93bb8a9 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -501,6 +501,8 @@ struct r5conf {
* conversions
*/
} __percpu *percpu;
+ int scribble_disks;
+ int scribble_sectors;
#ifdef CONFIG_HOTPLUG_CPU
struct notifier_block cpu_notify;
#endif