md: split detach operation out from ->stop.

Each md personality has a 'stop' operation which does two
things:
 1/ it finalizes some aspects of the array to ensure nothing
    is accessing the ->private data
 2/ it frees the ->private data.

All the steps in '1' can apply to all arrays and so can be
performed in common code.

This is useful as in the case where we change the personality which
manages an array (in level_store()), it would be helpful to do
step 1 early, and step 2 later.

So split the 'step 1' functionality out into a new mddev_detach().

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown
2014-12-15 12:56:57 +11:00
parent 3be260cc18
commit 5aa61f427e
7 changed files with 29 additions and 32 deletions

View File

@@ -2954,29 +2954,17 @@ static int run(struct mddev *mddev)
}
ret = md_integrity_register(mddev);
if (ret)
if (ret) {
md_unregister_thread(&mddev->thread);
stop(mddev);
}
return ret;
}
static int stop(struct mddev *mddev)
{
struct r1conf *conf = mddev->private;
struct bitmap *bitmap = mddev->bitmap;
/* wait for behind writes to complete */
if (bitmap && atomic_read(&bitmap->behind_writes) > 0) {
printk(KERN_INFO "md/raid1:%s: behind writes in progress - waiting to stop.\n",
mdname(mddev));
/* need to kick something here to make sure I/O goes? */
wait_event(bitmap->behind_wait,
atomic_read(&bitmap->behind_writes) == 0);
}
freeze_array(conf, 0);
unfreeze_array(conf);
md_unregister_thread(&mddev->thread);
if (conf->r1bio_pool)
mempool_destroy(conf->r1bio_pool);
kfree(conf->mirrors);