Commit 545c8795 authored by NeilBrown's avatar NeilBrown

md: dm-raid should call helper function to clear rdev.

dm-raid currently open-codes the freeing of some members of
and rdev.  It is more maintainable to have it call common code
from md.c which does this for all call-sites.

So remove free_disk_sb to md_rdev_clear, export it, and use it in
dm-raid.c
Signed-off-by: default avatarNeilBrown <neilb@suse.de>
parent 96e67703
...@@ -155,10 +155,7 @@ static void context_free(struct raid_set *rs) ...@@ -155,10 +155,7 @@ static void context_free(struct raid_set *rs)
for (i = 0; i < rs->md.raid_disks; i++) { for (i = 0; i < rs->md.raid_disks; i++) {
if (rs->dev[i].meta_dev) if (rs->dev[i].meta_dev)
dm_put_device(rs->ti, rs->dev[i].meta_dev); dm_put_device(rs->ti, rs->dev[i].meta_dev);
if (rs->dev[i].rdev.sb_page) md_rdev_clear(&rs->dev[i].rdev);
put_page(rs->dev[i].rdev.sb_page);
rs->dev[i].rdev.sb_page = NULL;
rs->dev[i].rdev.sb_loaded = 0;
if (rs->dev[i].data_dev) if (rs->dev[i].data_dev)
dm_put_device(rs->ti, rs->dev[i].data_dev); dm_put_device(rs->ti, rs->dev[i].data_dev);
} }
......
...@@ -803,7 +803,7 @@ static int alloc_disk_sb(struct md_rdev * rdev) ...@@ -803,7 +803,7 @@ static int alloc_disk_sb(struct md_rdev * rdev)
return 0; return 0;
} }
static void free_disk_sb(struct md_rdev * rdev) void md_rdev_clear(struct md_rdev *rdev)
{ {
if (rdev->sb_page) { if (rdev->sb_page) {
put_page(rdev->sb_page); put_page(rdev->sb_page);
...@@ -817,7 +817,7 @@ static void free_disk_sb(struct md_rdev * rdev) ...@@ -817,7 +817,7 @@ static void free_disk_sb(struct md_rdev * rdev)
rdev->bb_page = NULL; rdev->bb_page = NULL;
} }
} }
EXPORT_SYMBOL_GPL(md_rdev_clear);
static void super_written(struct bio *bio, int error) static void super_written(struct bio *bio, int error)
{ {
...@@ -2244,7 +2244,7 @@ static void export_rdev(struct md_rdev * rdev) ...@@ -2244,7 +2244,7 @@ static void export_rdev(struct md_rdev * rdev)
bdevname(rdev->bdev,b)); bdevname(rdev->bdev,b));
if (rdev->mddev) if (rdev->mddev)
MD_BUG(); MD_BUG();
free_disk_sb(rdev); md_rdev_clear(rdev);
#ifndef MODULE #ifndef MODULE
if (test_bit(AutoDetected, &rdev->flags)) if (test_bit(AutoDetected, &rdev->flags))
md_autodetect_dev(rdev->bdev->bd_dev); md_autodetect_dev(rdev->bdev->bd_dev);
...@@ -3324,7 +3324,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe ...@@ -3324,7 +3324,7 @@ static struct md_rdev *md_import_device(dev_t newdev, int super_format, int supe
abort_free: abort_free:
if (rdev->bdev) if (rdev->bdev)
unlock_rdev(rdev); unlock_rdev(rdev);
free_disk_sb(rdev); md_rdev_clear(rdev);
kfree(rdev->badblocks.page); kfree(rdev->badblocks.page);
kfree(rdev); kfree(rdev);
return ERR_PTR(err); return ERR_PTR(err);
......
...@@ -619,6 +619,7 @@ extern int md_run(struct mddev *mddev); ...@@ -619,6 +619,7 @@ extern int md_run(struct mddev *mddev);
extern void md_stop(struct mddev *mddev); extern void md_stop(struct mddev *mddev);
extern void md_stop_writes(struct mddev *mddev); extern void md_stop_writes(struct mddev *mddev);
extern int md_rdev_init(struct md_rdev *rdev); extern int md_rdev_init(struct md_rdev *rdev);
extern void md_rdev_clear(struct md_rdev *rdev);
extern void mddev_suspend(struct mddev *mddev); extern void mddev_suspend(struct mddev *mddev);
extern void mddev_resume(struct mddev *mddev); extern void mddev_resume(struct mddev *mddev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment