Skip to content

Commit

Permalink
md: rename ->stop to ->free
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NeilBrown committed Feb 3, 2015
1 parent 5aa61f4 commit afa0f55
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 50 deletions.
8 changes: 3 additions & 5 deletions drivers/md/faulty.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,11 @@ static int run(struct mddev *mddev)
return 0;
}

static int stop(struct mddev *mddev)
static void faulty_free(struct mddev *mddev, void *priv)
{
struct faulty_conf *conf = mddev->private;
struct faulty_conf *conf = priv;

kfree(conf);
mddev->private = NULL;
return 0;
}

static struct md_personality faulty_personality =
Expand All @@ -348,7 +346,7 @@ static struct md_personality faulty_personality =
.owner = THIS_MODULE,
.make_request = make_request,
.run = run,
.stop = stop,
.free = faulty_free,
.status = status,
.check_reshape = reshape,
.size = faulty_size,
Expand Down
9 changes: 3 additions & 6 deletions drivers/md/linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,11 @@ static int linear_add(struct mddev *mddev, struct md_rdev *rdev)
return 0;
}

static int linear_stop (struct mddev *mddev)
static void linear_free(struct mddev *mddev, void *priv)
{
struct linear_conf *conf = mddev->private;
struct linear_conf *conf = priv;

kfree(conf);
mddev->private = NULL;

return 0;
}

static void linear_make_request(struct mddev *mddev, struct bio *bio)
Expand Down Expand Up @@ -335,7 +332,7 @@ static struct md_personality linear_personality =
.owner = THIS_MODULE,
.make_request = linear_make_request,
.run = linear_run,
.stop = linear_stop,
.free = linear_free,
.status = linear_status,
.hot_add_disk = linear_add,
.size = linear_size,
Expand Down
10 changes: 5 additions & 5 deletions drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ static void md_make_request(struct request_queue *q, struct bio *bio)
/* mddev_suspend makes sure no new requests are submitted
* to the device, and that any requests that have been submitted
* are completely handled.
* Once ->stop is called and completes, the module will be completely
* unused.
* Once mddev_detach() is called and completes, the module will be
* completely unused.
*/
void mddev_suspend(struct mddev *mddev)
{
Expand Down Expand Up @@ -3374,7 +3374,7 @@ level_store(struct mddev *mddev, const char *buf, size_t len)
/* Looks like we have a winner */
mddev_suspend(mddev);
mddev_detach(mddev);
mddev->pers->stop(mddev);
mddev->pers->free(mddev, mddev->private);

if (mddev->pers->sync_request == NULL &&
pers->sync_request != NULL) {
Expand Down Expand Up @@ -4940,7 +4940,7 @@ int md_run(struct mddev *mddev)
}
if (err) {
mddev_detach(mddev);
mddev->pers->stop(mddev);
mddev->pers->free(mddev, mddev->private);
module_put(mddev->pers->owner);
mddev->pers = NULL;
bitmap_destroy(mddev);
Expand Down Expand Up @@ -5137,7 +5137,7 @@ static void __md_stop(struct mddev *mddev)
{
mddev->ready = 0;
mddev_detach(mddev);
mddev->pers->stop(mddev);
mddev->pers->free(mddev, mddev->private);
if (mddev->pers->sync_request && mddev->to_remove == NULL)
mddev->to_remove = &md_redundancy_group;
module_put(mddev->pers->owner);
Expand Down
2 changes: 1 addition & 1 deletion drivers/md/md.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ struct md_personality
struct module *owner;
void (*make_request)(struct mddev *mddev, struct bio *bio);
int (*run)(struct mddev *mddev);
int (*stop)(struct mddev *mddev);
void (*free)(struct mddev *mddev, void *priv);
void (*status)(struct seq_file *seq, struct mddev *mddev);
/* error_handler must set ->faulty and clear ->in_sync
* if appropriate, and should abort recovery if needed
Expand Down
10 changes: 4 additions & 6 deletions drivers/md/multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ static int multipath_run (struct mddev *mddev)
/*
* copy the already verified devices into our private MULTIPATH
* bookkeeping area. [whatever we allocate in multipath_run(),
* should be freed in multipath_stop()]
* should be freed in multipath_free()]
*/

conf = kzalloc(sizeof(struct mpconf), GFP_KERNEL);
Expand Down Expand Up @@ -500,15 +500,13 @@ static int multipath_run (struct mddev *mddev)
return -EIO;
}

static int multipath_stop (struct mddev *mddev)
static void multipath_free(struct mddev *mddev, void *priv)
{
struct mpconf *conf = mddev->private;
struct mpconf *conf = priv;

mempool_destroy(conf->pool);
kfree(conf->multipaths);
kfree(conf);
mddev->private = NULL;
return 0;
}

static struct md_personality multipath_personality =
Expand All @@ -518,7 +516,7 @@ static struct md_personality multipath_personality =
.owner = THIS_MODULE,
.make_request = multipath_make_request,
.run = multipath_run,
.stop = multipath_stop,
.free = multipath_free,
.status = multipath_status,
.error_handler = multipath_error,
.hot_add_disk = multipath_add_disk,
Expand Down
12 changes: 5 additions & 7 deletions drivers/md/raid0.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks
return array_sectors;
}

static int raid0_stop(struct mddev *mddev);
static void raid0_free(struct mddev *mddev, void *priv);

static int raid0_run(struct mddev *mddev)
{
Expand Down Expand Up @@ -468,20 +468,18 @@ static int raid0_run(struct mddev *mddev)

ret = md_integrity_register(mddev);
if (ret)
raid0_stop(mddev);
raid0_free(mddev, conf);

return ret;
}

static int raid0_stop(struct mddev *mddev)
static void raid0_free(struct mddev *mddev, void *priv)
{
struct r0conf *conf = mddev->private;
struct r0conf *conf = priv;

kfree(conf->strip_zone);
kfree(conf->devlist);
kfree(conf);
mddev->private = NULL;
return 0;
}

/*
Expand Down Expand Up @@ -715,7 +713,7 @@ static struct md_personality raid0_personality=
.owner = THIS_MODULE,
.make_request = raid0_make_request,
.run = raid0_run,
.stop = raid0_stop,
.free = raid0_free,
.status = raid0_status,
.size = raid0_size,
.takeover = raid0_takeover,
Expand Down
14 changes: 6 additions & 8 deletions drivers/md/raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -2872,7 +2872,7 @@ static struct r1conf *setup_conf(struct mddev *mddev)
return ERR_PTR(err);
}

static int stop(struct mddev *mddev);
static void raid1_free(struct mddev *mddev, void *priv);
static int run(struct mddev *mddev)
{
struct r1conf *conf;
Expand All @@ -2894,7 +2894,7 @@ static int run(struct mddev *mddev)
/*
* copy the already verified devices into our private RAID1
* bookkeeping area. [whatever we allocate in run(),
* should be freed in stop()]
* should be freed in raid1_free()]
*/
if (mddev->private == NULL)
conf = setup_conf(mddev);
Expand Down Expand Up @@ -2956,23 +2956,21 @@ static int run(struct mddev *mddev)
ret = md_integrity_register(mddev);
if (ret) {
md_unregister_thread(&mddev->thread);
stop(mddev);
raid1_free(mddev, conf);
}
return ret;
}

static int stop(struct mddev *mddev)
static void raid1_free(struct mddev *mddev, void *priv)
{
struct r1conf *conf = mddev->private;
struct r1conf *conf = priv;

if (conf->r1bio_pool)
mempool_destroy(conf->r1bio_pool);
kfree(conf->mirrors);
safe_put_page(conf->tmppage);
kfree(conf->poolinfo);
kfree(conf);
mddev->private = NULL;
return 0;
}

static int raid1_resize(struct mddev *mddev, sector_t sectors)
Expand Down Expand Up @@ -3155,7 +3153,7 @@ static struct md_personality raid1_personality =
.owner = THIS_MODULE,
.make_request = make_request,
.run = run,
.stop = stop,
.free = raid1_free,
.status = status,
.error_handler = error,
.hot_add_disk = raid1_add_disk,
Expand Down
8 changes: 3 additions & 5 deletions drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -3798,9 +3798,9 @@ static int run(struct mddev *mddev)
return -EIO;
}

static int stop(struct mddev *mddev)
static void raid10_free(struct mddev *mddev, void *priv)
{
struct r10conf *conf = mddev->private;
struct r10conf *conf = priv;

if (conf->r10bio_pool)
mempool_destroy(conf->r10bio_pool);
Expand All @@ -3809,8 +3809,6 @@ static int stop(struct mddev *mddev)
kfree(conf->mirrors_old);
kfree(conf->mirrors_new);
kfree(conf);
mddev->private = NULL;
return 0;
}

static void raid10_quiesce(struct mddev *mddev, int state)
Expand Down Expand Up @@ -4692,7 +4690,7 @@ static struct md_personality raid10_personality =
.owner = THIS_MODULE,
.make_request = make_request,
.run = run,
.stop = stop,
.free = raid10_free,
.status = status,
.error_handler = error,
.hot_add_disk = raid10_add_disk,
Expand Down
12 changes: 5 additions & 7 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -6313,14 +6313,12 @@ static int run(struct mddev *mddev)
return -EIO;
}

static int stop(struct mddev *mddev)
static void raid5_free(struct mddev *mddev, void *priv)
{
struct r5conf *conf = mddev->private;
struct r5conf *conf = priv;

free_conf(conf);
mddev->private = NULL;
mddev->to_remove = &raid5_attrs_group;
return 0;
}

static void status(struct seq_file *seq, struct mddev *mddev)
Expand Down Expand Up @@ -7094,7 +7092,7 @@ static struct md_personality raid6_personality =
.owner = THIS_MODULE,
.make_request = make_request,
.run = run,
.stop = stop,
.free = raid5_free,
.status = status,
.error_handler = error,
.hot_add_disk = raid5_add_disk,
Expand All @@ -7118,7 +7116,7 @@ static struct md_personality raid5_personality =
.owner = THIS_MODULE,
.make_request = make_request,
.run = run,
.stop = stop,
.free = raid5_free,
.status = status,
.error_handler = error,
.hot_add_disk = raid5_add_disk,
Expand All @@ -7143,7 +7141,7 @@ static struct md_personality raid4_personality =
.owner = THIS_MODULE,
.make_request = make_request,
.run = run,
.stop = stop,
.free = raid5_free,
.status = status,
.error_handler = error,
.hot_add_disk = raid5_add_disk,
Expand Down

0 comments on commit afa0f55

Please sign in to comment.