aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2014-12-14 20:56:58 -0500
committerNeilBrown <neilb@suse.de>2015-02-03 16:35:52 -0500
commitafa0f557cb15176570a18fb2a093e348a793afd4 (patch)
tree7ae3f6a37ae3e6bcfbea51faadad924df8020095
parent5aa61f427e4979be733e4847b9199ff9cc48a47e (diff)
md: rename ->stop to ->free
Now that the ->stop function only frees the private data, rename is accordingly. Also pass in the private pointer as an arg rather than using mddev->private. This flexibility will be useful in level_store(). Finally, don't clear ->private. It doesn't make sense to clear it seeing that isn't what we free, and it is no longer necessary to clear ->private (it was some time ago before ->to_remove was introduced). Setting ->to_remove in ->free() is a bit of a wart, but not a big problem at the moment. Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--drivers/md/faulty.c8
-rw-r--r--drivers/md/linear.c9
-rw-r--r--drivers/md/md.c10
-rw-r--r--drivers/md/md.h2
-rw-r--r--drivers/md/multipath.c10
-rw-r--r--drivers/md/raid0.c12
-rw-r--r--drivers/md/raid1.c14
-rw-r--r--drivers/md/raid10.c8
-rw-r--r--drivers/md/raid5.c12
9 files changed, 35 insertions, 50 deletions
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index e8b4574956c7..1277eb26b58a 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -332,13 +332,11 @@ static int run(struct mddev *mddev)
332 return 0; 332 return 0;
333} 333}
334 334
335static int stop(struct mddev *mddev) 335static void faulty_free(struct mddev *mddev, void *priv)
336{ 336{
337 struct faulty_conf *conf = mddev->private; 337 struct faulty_conf *conf = priv;
338 338
339 kfree(conf); 339 kfree(conf);
340 mddev->private = NULL;
341 return 0;
342} 340}
343 341
344static struct md_personality faulty_personality = 342static struct md_personality faulty_personality =
@@ -348,7 +346,7 @@ static struct md_personality faulty_personality =
348 .owner = THIS_MODULE, 346 .owner = THIS_MODULE,
349 .make_request = make_request, 347 .make_request = make_request,
350 .run = run, 348 .run = run,
351 .stop = stop, 349 .free = faulty_free,
352 .status = status, 350 .status = status,
353 .check_reshape = reshape, 351 .check_reshape = reshape,
354 .size = faulty_size, 352 .size = faulty_size,
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index c201555b9c6c..fa7d577f3d12 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -249,14 +249,11 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
249 return 0; 249 return 0;
250} 250}
251 251
252static int linear_stop (struct mddev *mddev) 252static void linear_free(struct mddev *mddev, void *priv)
253{ 253{
254 struct linear_conf *conf = mddev->private; 254 struct linear_conf *conf = priv;
255 255
256 kfree(conf); 256 kfree(conf);
257 mddev->private = NULL;
258
259 return 0;
260} 257}
261 258
262static void linear_make_request(struct mddev *mddev, struct bio *bio) 259static void linear_make_request(struct mddev *mddev, struct bio *bio)
@@ -335,7 +332,7 @@ static struct md_personality linear_personality =
335 .owner = THIS_MODULE, 332 .owner = THIS_MODULE,
336 .make_request = linear_make_request, 333 .make_request = linear_make_request,
337 .run = linear_run, 334 .run = linear_run,
338 .stop = linear_stop, 335 .free = linear_free,
339 .status = linear_status, 336 .status = linear_status,
340 .hot_add_disk = linear_add, 337 .hot_add_disk = linear_add,
341 .size = linear_size, 338 .size = linear_size,
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 58f140bef999..2920fd004865 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -293,8 +293,8 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
293/* mddev_suspend makes sure no new requests are submitted 293/* mddev_suspend makes sure no new requests are submitted
294 * to the device, and that any requests that have been submitted 294 * to the device, and that any requests that have been submitted
295 * are completely handled. 295 * are completely handled.
296 * Once ->stop is called and completes, the module will be completely 296 * Once mddev_detach() is called and completes, the module will be
297 * unused. 297 * completely unused.
298 */ 298 */
299void mddev_suspend(struct mddev *mddev) 299void mddev_suspend(struct mddev *mddev)
300{ 300{
@@ -3374,7 +3374,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
3374 /* Looks like we have a winner */ 3374 /* Looks like we have a winner */
3375 mddev_suspend(mddev); 3375 mddev_suspend(mddev);
3376 mddev_detach(mddev); 3376 mddev_detach(mddev);
3377 mddev->pers->stop(mddev); 3377 mddev->pers->free(mddev, mddev->private);
3378 3378
3379 if (mddev->pers->sync_request == NULL && 3379 if (mddev->pers->sync_request == NULL &&
3380 pers->sync_request != NULL) { 3380 pers->sync_request != NULL) {
@@ -4940,7 +4940,7 @@ int md_run(struct mddev *mddev)
4940 } 4940 }
4941 if (err) { 4941 if (err) {
4942 mddev_detach(mddev); 4942 mddev_detach(mddev);
4943 mddev->pers->stop(mddev); 4943 mddev->pers->free(mddev, mddev->private);
4944 module_put(mddev->pers->owner); 4944 module_put(mddev->pers->owner);
4945 mddev->pers = NULL; 4945 mddev->pers = NULL;
4946 bitmap_destroy(mddev); 4946 bitmap_destroy(mddev);
@@ -5137,7 +5137,7 @@ static void __md_stop(struct mddev *mddev)
5137{ 5137{
5138 mddev->ready = 0; 5138 mddev->ready = 0;
5139 mddev_detach(mddev); 5139 mddev_detach(mddev);
5140 mddev->pers->stop(mddev); 5140 mddev->pers->free(mddev, mddev->private);
5141 if (mddev->pers->sync_request && mddev->to_remove == NULL) 5141 if (mddev->pers->sync_request && mddev->to_remove == NULL)
5142 mddev->to_remove = &md_redundancy_group; 5142 mddev->to_remove = &md_redundancy_group;
5143 module_put(mddev->pers->owner); 5143 module_put(mddev->pers->owner);
diff --git a/drivers/md/md.h b/drivers/md/md.h
index bee5b852c33f..37e7c17e56a6 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -465,7 +465,7 @@ struct md_personality
465 struct module *owner; 465 struct module *owner;
466 void (*make_request)(struct mddev *mddev, struct bio *bio); 466 void (*make_request)(struct mddev *mddev, struct bio *bio);
467 int (*run)(struct mddev *mddev); 467 int (*run)(struct mddev *mddev);
468 int (*stop)(struct mddev *mddev); 468 void (*free)(struct mddev *mddev, void *priv);
469 void (*status)(struct seq_file *seq, struct mddev *mddev); 469 void (*status)(struct seq_file *seq, struct mddev *mddev);
470 /* error_handler must set ->faulty and clear ->in_sync 470 /* error_handler must set ->faulty and clear ->in_sync
471 * if appropriate, and should abort recovery if needed 471 * if appropriate, and should abort recovery if needed
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 9fe34453835b..ac3ede2bd00e 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -399,7 +399,7 @@ static int multipath_run (struct mddev *mddev)
399 /* 399 /*
400 * copy the already verified devices into our private MULTIPATH 400 * copy the already verified devices into our private MULTIPATH
401 * bookkeeping area. [whatever we allocate in multipath_run(), 401 * bookkeeping area. [whatever we allocate in multipath_run(),
402 * should be freed in multipath_stop()] 402 * should be freed in multipath_free()]
403 */ 403 */
404 404
405 conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL); 405 conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL);
@@ -500,15 +500,13 @@ out:
500 return -EIO; 500 return -EIO;
501} 501}
502 502
503static int multipath_stop (struct mddev *mddev) 503static void multipath_free(struct mddev *mddev, void *priv)
504{ 504{
505 struct mpconf *conf = mddev->private; 505 struct mpconf *conf = priv;
506 506
507 mempool_destroy(conf->pool); 507 mempool_destroy(conf->pool);
508 kfree(conf->multipaths); 508 kfree(conf->multipaths);
509 kfree(conf); 509 kfree(conf);
510 mddev->private = NULL;
511 return 0;
512} 510}
513 511
514static struct md_personality multipath_personality = 512static struct md_personality multipath_personality =
@@ -518,7 +516,7 @@ static struct md_personality multipath_personality =
518 .owner = THIS_MODULE, 516 .owner = THIS_MODULE,
519 .make_request = multipath_make_request, 517 .make_request = multipath_make_request,
520 .run = multipath_run, 518 .run = multipath_run,
521 .stop = multipath_stop, 519 .free = multipath_free,
522 .status = multipath_status, 520 .status = multipath_status,
523 .error_handler = multipath_error, 521 .error_handler = multipath_error,
524 .hot_add_disk = multipath_add_disk, 522 .hot_add_disk = multipath_add_disk,
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 01dfca94b663..a13f738a7b39 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -415,7 +415,7 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks
415 return array_sectors; 415 return array_sectors;
416} 416}
417 417
418static int raid0_stop(struct mddev *mddev); 418static void raid0_free(struct mddev *mddev, void *priv);
419 419
420static int raid0_run(struct mddev *mddev) 420static int raid0_run(struct mddev *mddev)
421{ 421{
@@ -468,20 +468,18 @@ static int raid0_run(struct mddev *mddev)
468 468
469 ret = md_integrity_register(mddev); 469 ret = md_integrity_register(mddev);
470 if (ret) 470 if (ret)
471 raid0_stop(mddev); 471 raid0_free(mddev, conf);
472 472
473 return ret; 473 return ret;
474} 474}
475 475
476static int raid0_stop(struct mddev *mddev) 476static void raid0_free(struct mddev *mddev, void *priv)
477{ 477{
478 struct r0conf *conf = mddev->private; 478 struct r0conf *conf = priv;
479 479
480 kfree(conf->strip_zone); 480 kfree(conf->strip_zone);
481 kfree(conf->devlist); 481 kfree(conf->devlist);
482 kfree(conf); 482 kfree(conf);
483 mddev->private = NULL;
484 return 0;
485} 483}
486 484
487/* 485/*
@@ -715,7 +713,7 @@ static struct md_personality raid0_personality=
715 .owner = THIS_MODULE, 713 .owner = THIS_MODULE,
716 .make_request = raid0_make_request, 714 .make_request = raid0_make_request,
717 .run = raid0_run, 715 .run = raid0_run,
718 .stop = raid0_stop, 716 .free = raid0_free,
719 .status = raid0_status, 717 .status = raid0_status,
720 .size = raid0_size, 718 .size = raid0_size,
721 .takeover = raid0_takeover, 719 .takeover = raid0_takeover,
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index fccea0b39808..5dd0c2e59ab9 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -2872,7 +2872,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
2872 return ERR_PTR(err); 2872 return ERR_PTR(err);
2873} 2873}
2874 2874
2875static int stop(struct mddev *mddev); 2875static void raid1_free(struct mddev *mddev, void *priv);
2876static int run(struct mddev *mddev) 2876static int run(struct mddev *mddev)
2877{ 2877{
2878 struct r1conf *conf; 2878 struct r1conf *conf;
@@ -2894,7 +2894,7 @@ static int run(struct mddev *mddev)
2894 /* 2894 /*
2895 * copy the already verified devices into our private RAID1 2895 * copy the already verified devices into our private RAID1
2896 * bookkeeping area. [whatever we allocate in run(), 2896 * bookkeeping area. [whatever we allocate in run(),
2897 * should be freed in stop()] 2897 * should be freed in raid1_free()]
2898 */ 2898 */
2899 if (mddev->private == NULL) 2899 if (mddev->private == NULL)
2900 conf = setup_conf(mddev); 2900 conf = setup_conf(mddev);
@@ -2956,14 +2956,14 @@ static int run(struct mddev *mddev)
2956 ret = md_integrity_register(mddev); 2956 ret = md_integrity_register(mddev);
2957 if (ret) { 2957 if (ret) {
2958 md_unregister_thread(&mddev->thread); 2958 md_unregister_thread(&mddev->thread);
2959 stop(mddev); 2959 raid1_free(mddev, conf);
2960 } 2960 }
2961 return ret; 2961 return ret;
2962} 2962}
2963 2963
2964static int stop(struct mddev *mddev) 2964static void raid1_free(struct mddev *mddev, void *priv)
2965{ 2965{
2966 struct r1conf *conf = mddev->private; 2966 struct r1conf *conf = priv;
2967 2967
2968 if (conf->r1bio_pool) 2968 if (conf->r1bio_pool)
2969 mempool_destroy(conf->r1bio_pool); 2969 mempool_destroy(conf->r1bio_pool);
@@ -2971,8 +2971,6 @@ static int stop(struct mddev *mddev)
2971 safe_put_page(conf->tmppage); 2971 safe_put_page(conf->tmppage);
2972 kfree(conf->poolinfo); 2972 kfree(conf->poolinfo);
2973 kfree(conf); 2973 kfree(conf);
2974 mddev->private = NULL;
2975 return 0;
2976} 2974}
2977 2975
2978static int raid1_resize(struct mddev *mddev, sector_t sectors) 2976static int raid1_resize(struct mddev *mddev, sector_t sectors)
@@ -3155,7 +3153,7 @@ static struct md_personality raid1_personality =
3155 .owner = THIS_MODULE, 3153 .owner = THIS_MODULE,
3156 .make_request = make_request, 3154 .make_request = make_request,
3157 .run = run, 3155 .run = run,
3158 .stop = stop, 3156 .free = raid1_free,
3159 .status = status, 3157 .status = status,
3160 .error_handler = error, 3158 .error_handler = error,
3161 .hot_add_disk = raid1_add_disk, 3159 .hot_add_disk = raid1_add_disk,
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 654fdae906aa..d1203cddb024 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -3798,9 +3798,9 @@ out:
3798 return -EIO; 3798 return -EIO;
3799} 3799}
3800 3800
3801static int stop(struct mddev *mddev) 3801static void raid10_free(struct mddev *mddev, void *priv)
3802{ 3802{
3803 struct r10conf *conf = mddev->private; 3803 struct r10conf *conf = priv;
3804 3804
3805 if (conf->r10bio_pool) 3805 if (conf->r10bio_pool)
3806 mempool_destroy(conf->r10bio_pool); 3806 mempool_destroy(conf->r10bio_pool);
@@ -3809,8 +3809,6 @@ static int stop(struct mddev *mddev)
3809 kfree(conf->mirrors_old); 3809 kfree(conf->mirrors_old);
3810 kfree(conf->mirrors_new); 3810 kfree(conf->mirrors_new);
3811 kfree(conf); 3811 kfree(conf);
3812 mddev->private = NULL;
3813 return 0;
3814} 3812}
3815 3813
3816static void raid10_quiesce(struct mddev *mddev, int state) 3814static void raid10_quiesce(struct mddev *mddev, int state)
@@ -4692,7 +4690,7 @@ static struct md_personality raid10_personality =
4692 .owner = THIS_MODULE, 4690 .owner = THIS_MODULE,
4693 .make_request = make_request, 4691 .make_request = make_request,
4694 .run = run, 4692 .run = run,
4695 .stop = stop, 4693 .free = raid10_free,
4696 .status = status, 4694 .status = status,
4697 .error_handler = error, 4695 .error_handler = error,
4698 .hot_add_disk = raid10_add_disk, 4696 .hot_add_disk = raid10_add_disk,
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 482526077647..dab908b2aa9a 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -6313,14 +6313,12 @@ abort:
6313 return -EIO; 6313 return -EIO;
6314} 6314}
6315 6315
6316static int stop(struct mddev *mddev) 6316static void raid5_free(struct mddev *mddev, void *priv)
6317{ 6317{
6318 struct r5conf *conf = mddev->private; 6318 struct r5conf *conf = priv;
6319 6319
6320 free_conf(conf); 6320 free_conf(conf);
6321 mddev->private = NULL;
6322 mddev->to_remove = &raid5_attrs_group; 6321 mddev->to_remove = &raid5_attrs_group;
6323 return 0;
6324} 6322}
6325 6323
6326static void status(struct seq_file *seq, struct mddev *mddev) 6324static void status(struct seq_file *seq, struct mddev *mddev)
@@ -7094,7 +7092,7 @@ static struct md_personality raid6_personality =
7094 .owner = THIS_MODULE, 7092 .owner = THIS_MODULE,
7095 .make_request = make_request, 7093 .make_request = make_request,
7096 .run = run, 7094 .run = run,
7097 .stop = stop, 7095 .free = raid5_free,
7098 .status = status, 7096 .status = status,
7099 .error_handler = error, 7097 .error_handler = error,
7100 .hot_add_disk = raid5_add_disk, 7098 .hot_add_disk = raid5_add_disk,
@@ -7118,7 +7116,7 @@ static struct md_personality raid5_personality =
7118 .owner = THIS_MODULE, 7116 .owner = THIS_MODULE,
7119 .make_request = make_request, 7117 .make_request = make_request,
7120 .run = run, 7118 .run = run,
7121 .stop = stop, 7119 .free = raid5_free,
7122 .status = status, 7120 .status = status,
7123 .error_handler = error, 7121 .error_handler = error,
7124 .hot_add_disk = raid5_add_disk, 7122 .hot_add_disk = raid5_add_disk,
@@ -7143,7 +7141,7 @@ static struct md_personality raid4_personality =
7143 .owner = THIS_MODULE, 7141 .owner = THIS_MODULE,
7144 .make_request = make_request, 7142 .make_request = make_request,
7145 .run = run, 7143 .run = run,
7146 .stop = stop, 7144 .free = raid5_free,
7147 .status = status, 7145 .status = status,
7148 .error_handler = error, 7146 .error_handler = error,
7149 .hot_add_disk = raid5_add_disk, 7147 .hot_add_disk = raid5_add_disk,