md: raid1/raid10: handle allocation errors during array setup.
Both raid1 and raid10 create a mempool during startup. If the 'alloc' function for this mempool fails, unplug_slaves is called. If that happens when the pool is being initialised, unplug_slaves will try to use the 'conf' structure that isn't filled in yet, and badness will happen. So ensure that unplug_slaves doesn't get called unless we know that the conf structure if fully initialised. Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
@@ -68,7 +68,7 @@ static void * r10bio_pool_alloc(gfp_t gfp_flags, void *data)
|
||||
|
||||
/* allocate a r10bio with room for raid_disks entries in the bios array */
|
||||
r10_bio = kzalloc(size, gfp_flags);
|
||||
if (!r10_bio)
|
||||
if (!r10_bio && conf->mddev)
|
||||
unplug_slaves(conf->mddev);
|
||||
|
||||
return r10_bio;
|
||||
@@ -2096,7 +2096,6 @@ static int run(mddev_t *mddev)
|
||||
if (!conf->tmppage)
|
||||
goto out_free_conf;
|
||||
|
||||
conf->mddev = mddev;
|
||||
conf->raid_disks = mddev->raid_disks;
|
||||
conf->near_copies = nc;
|
||||
conf->far_copies = fc;
|
||||
@@ -2133,6 +2132,7 @@ static int run(mddev_t *mddev)
|
||||
goto out_free_conf;
|
||||
}
|
||||
|
||||
conf->mddev = mddev;
|
||||
spin_lock_init(&conf->device_lock);
|
||||
mddev->queue->queue_lock = &conf->device_lock;
|
||||
|
||||
|
Reference in New Issue
Block a user