Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

NeilBrown afa0f557 5aa61f42

+35 -50
+3 -5
drivers/md/faulty.c
··· 332 332 return 0; 333 333 } 334 334 335 - static int stop(struct mddev *mddev) 335 + static 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 339 kfree(conf); 340 - mddev->private = NULL; 341 - return 0; 342 340 } 343 341 344 342 static struct md_personality faulty_personality = ··· 346 348 .owner = THIS_MODULE, 347 349 .make_request = make_request, 348 350 .run = run, 349 - .stop = stop, 351 + .free = faulty_free, 350 352 .status = status, 351 353 .check_reshape = reshape, 352 354 .size = faulty_size,
+3 -6
drivers/md/linear.c
··· 249 249 return 0; 250 250 } 251 251 252 - static int linear_stop (struct mddev *mddev) 252 + static 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 256 kfree(conf); 257 - mddev->private = NULL; 258 - 259 - return 0; 260 257 } 261 258 262 259 static void linear_make_request(struct mddev *mddev, struct bio *bio) ··· 332 335 .owner = THIS_MODULE, 333 336 .make_request = linear_make_request, 334 337 .run = linear_run, 335 - .stop = linear_stop, 338 + .free = linear_free, 336 339 .status = linear_status, 337 340 .hot_add_disk = linear_add, 338 341 .size = linear_size,
+5 -5
drivers/md/md.c
··· 293 293 /* mddev_suspend makes sure no new requests are submitted 294 294 * to the device, and that any requests that have been submitted 295 295 * are completely handled. 296 - * Once ->stop is called and completes, the module will be completely 297 - * unused. 296 + * Once mddev_detach() is called and completes, the module will be 297 + * completely unused. 298 298 */ 299 299 void mddev_suspend(struct mddev *mddev) 300 300 { ··· 3374 3374 /* Looks like we have a winner */ 3375 3375 mddev_suspend(mddev); 3376 3376 mddev_detach(mddev); 3377 - mddev->pers->stop(mddev); 3377 + mddev->pers->free(mddev, mddev->private); 3378 3378 3379 3379 if (mddev->pers->sync_request == NULL && 3380 3380 pers->sync_request != NULL) { ··· 4940 4940 } 4941 4941 if (err) { 4942 4942 mddev_detach(mddev); 4943 - mddev->pers->stop(mddev); 4943 + mddev->pers->free(mddev, mddev->private); 4944 4944 module_put(mddev->pers->owner); 4945 4945 mddev->pers = NULL; 4946 4946 bitmap_destroy(mddev); ··· 5137 5137 { 5138 5138 mddev->ready = 0; 5139 5139 mddev_detach(mddev); 5140 - mddev->pers->stop(mddev); 5140 + mddev->pers->free(mddev, mddev->private); 5141 5141 if (mddev->pers->sync_request && mddev->to_remove == NULL) 5142 5142 mddev->to_remove = &md_redundancy_group; 5143 5143 module_put(mddev->pers->owner);
+1 -1
drivers/md/md.h
··· 465 465 struct module *owner; 466 466 void (*make_request)(struct mddev *mddev, struct bio *bio); 467 467 int (*run)(struct mddev *mddev); 468 - int (*stop)(struct mddev *mddev); 468 + void (*free)(struct mddev *mddev, void *priv); 469 469 void (*status)(struct seq_file *seq, struct mddev *mddev); 470 470 /* error_handler must set ->faulty and clear ->in_sync 471 471 * if appropriate, and should abort recovery if needed
+4 -6
drivers/md/multipath.c
··· 399 399 /* 400 400 * copy the already verified devices into our private MULTIPATH 401 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 405 conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL); ··· 500 500 return -EIO; 501 501 } 502 502 503 - static int multipath_stop (struct mddev *mddev) 503 + static void multipath_free(struct mddev *mddev, void *priv) 504 504 { 505 - struct mpconf *conf = mddev->private; 505 + struct mpconf *conf = priv; 506 506 507 507 mempool_destroy(conf->pool); 508 508 kfree(conf->multipaths); 509 509 kfree(conf); 510 - mddev->private = NULL; 511 - return 0; 512 510 } 513 511 514 512 static struct md_personality multipath_personality = ··· 516 518 .owner = THIS_MODULE, 517 519 .make_request = multipath_make_request, 518 520 .run = multipath_run, 519 - .stop = multipath_stop, 521 + .free = multipath_free, 520 522 .status = multipath_status, 521 523 .error_handler = multipath_error, 522 524 .hot_add_disk = multipath_add_disk,
+5 -7
drivers/md/raid0.c
··· 415 415 return array_sectors; 416 416 } 417 417 418 - static int raid0_stop(struct mddev *mddev); 418 + static void raid0_free(struct mddev *mddev, void *priv); 419 419 420 420 static int raid0_run(struct mddev *mddev) 421 421 { ··· 468 468 469 469 ret = md_integrity_register(mddev); 470 470 if (ret) 471 - raid0_stop(mddev); 471 + raid0_free(mddev, conf); 472 472 473 473 return ret; 474 474 } 475 475 476 - static int raid0_stop(struct mddev *mddev) 476 + static void raid0_free(struct mddev *mddev, void *priv) 477 477 { 478 - struct r0conf *conf = mddev->private; 478 + struct r0conf *conf = priv; 479 479 480 480 kfree(conf->strip_zone); 481 481 kfree(conf->devlist); 482 482 kfree(conf); 483 - mddev->private = NULL; 484 - return 0; 485 483 } 486 484 487 485 /* ··· 713 715 .owner = THIS_MODULE, 714 716 .make_request = raid0_make_request, 715 717 .run = raid0_run, 716 - .stop = raid0_stop, 718 + .free = raid0_free, 717 719 .status = raid0_status, 718 720 .size = raid0_size, 719 721 .takeover = raid0_takeover,
+6 -8
drivers/md/raid1.c
··· 2872 2872 return ERR_PTR(err); 2873 2873 } 2874 2874 2875 - static int stop(struct mddev *mddev); 2875 + static void raid1_free(struct mddev *mddev, void *priv); 2876 2876 static int run(struct mddev *mddev) 2877 2877 { 2878 2878 struct r1conf *conf; ··· 2894 2894 /* 2895 2895 * copy the already verified devices into our private RAID1 2896 2896 * bookkeeping area. [whatever we allocate in run(), 2897 - * should be freed in stop()] 2897 + * should be freed in raid1_free()] 2898 2898 */ 2899 2899 if (mddev->private == NULL) 2900 2900 conf = setup_conf(mddev); ··· 2956 2956 ret = md_integrity_register(mddev); 2957 2957 if (ret) { 2958 2958 md_unregister_thread(&mddev->thread); 2959 - stop(mddev); 2959 + raid1_free(mddev, conf); 2960 2960 } 2961 2961 return ret; 2962 2962 } 2963 2963 2964 - static int stop(struct mddev *mddev) 2964 + static void raid1_free(struct mddev *mddev, void *priv) 2965 2965 { 2966 - struct r1conf *conf = mddev->private; 2966 + struct r1conf *conf = priv; 2967 2967 2968 2968 if (conf->r1bio_pool) 2969 2969 mempool_destroy(conf->r1bio_pool); ··· 2971 2971 safe_put_page(conf->tmppage); 2972 2972 kfree(conf->poolinfo); 2973 2973 kfree(conf); 2974 - mddev->private = NULL; 2975 - return 0; 2976 2974 } 2977 2975 2978 2976 static int raid1_resize(struct mddev *mddev, sector_t sectors) ··· 3153 3155 .owner = THIS_MODULE, 3154 3156 .make_request = make_request, 3155 3157 .run = run, 3156 - .stop = stop, 3158 + .free = raid1_free, 3157 3159 .status = status, 3158 3160 .error_handler = error, 3159 3161 .hot_add_disk = raid1_add_disk,
+3 -5
drivers/md/raid10.c
··· 3798 3798 return -EIO; 3799 3799 } 3800 3800 3801 - static int stop(struct mddev *mddev) 3801 + static void raid10_free(struct mddev *mddev, void *priv) 3802 3802 { 3803 - struct r10conf *conf = mddev->private; 3803 + struct r10conf *conf = priv; 3804 3804 3805 3805 if (conf->r10bio_pool) 3806 3806 mempool_destroy(conf->r10bio_pool); ··· 3809 3809 kfree(conf->mirrors_old); 3810 3810 kfree(conf->mirrors_new); 3811 3811 kfree(conf); 3812 - mddev->private = NULL; 3813 - return 0; 3814 3812 } 3815 3813 3816 3814 static void raid10_quiesce(struct mddev *mddev, int state) ··· 4690 4692 .owner = THIS_MODULE, 4691 4693 .make_request = make_request, 4692 4694 .run = run, 4693 - .stop = stop, 4695 + .free = raid10_free, 4694 4696 .status = status, 4695 4697 .error_handler = error, 4696 4698 .hot_add_disk = raid10_add_disk,
+5 -7
drivers/md/raid5.c
··· 6313 6313 return -EIO; 6314 6314 } 6315 6315 6316 - static int stop(struct mddev *mddev) 6316 + static void raid5_free(struct mddev *mddev, void *priv) 6317 6317 { 6318 - struct r5conf *conf = mddev->private; 6318 + struct r5conf *conf = priv; 6319 6319 6320 6320 free_conf(conf); 6321 - mddev->private = NULL; 6322 6321 mddev->to_remove = &raid5_attrs_group; 6323 - return 0; 6324 6322 } 6325 6323 6326 6324 static void status(struct seq_file *seq, struct mddev *mddev) ··· 7092 7094 .owner = THIS_MODULE, 7093 7095 .make_request = make_request, 7094 7096 .run = run, 7095 - .stop = stop, 7097 + .free = raid5_free, 7096 7098 .status = status, 7097 7099 .error_handler = error, 7098 7100 .hot_add_disk = raid5_add_disk, ··· 7116 7118 .owner = THIS_MODULE, 7117 7119 .make_request = make_request, 7118 7120 .run = run, 7119 - .stop = stop, 7121 + .free = raid5_free, 7120 7122 .status = status, 7121 7123 .error_handler = error, 7122 7124 .hot_add_disk = raid5_add_disk, ··· 7141 7143 .owner = THIS_MODULE, 7142 7144 .make_request = make_request, 7143 7145 .run = run, 7144 - .stop = stop, 7146 + .free = raid5_free, 7145 7147 .status = status, 7146 7148 .error_handler = error, 7147 7149 .hot_add_disk = raid5_add_disk,