Commit 82b0fad1 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Remove bdput calls from raid personalities.

Remove bdput calls from raid personalities.

Some of the md personalities currently hold a counted reference
on a bdev.  This is not necessary as the main md module will always
hold a counted reference in the rdev.
This patch removes the code to take and drop these unnecessary
references.
parent 389a5884
...@@ -61,7 +61,6 @@ static int linear_run (mddev_t *mddev) ...@@ -61,7 +61,6 @@ static int linear_run (mddev_t *mddev)
} }
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
atomic_inc(&rdev->bdev->bd_count);
disk->size = rdev->size; disk->size = rdev->size;
if (!conf->smallest || (disk->size < conf->smallest->size)) if (!conf->smallest || (disk->size < conf->smallest->size))
...@@ -112,12 +111,8 @@ static int linear_run (mddev_t *mddev) ...@@ -112,12 +111,8 @@ static int linear_run (mddev_t *mddev)
return 0; return 0;
out: out:
if (conf) { if (conf)
for (i = 0; i < MD_SB_DISKS; i++)
if (conf->disks[i].bdev)
bdput(conf->disks[i].bdev);
kfree(conf); kfree(conf);
}
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 1; return 1;
} }
...@@ -125,11 +120,7 @@ static int linear_run (mddev_t *mddev) ...@@ -125,11 +120,7 @@ static int linear_run (mddev_t *mddev)
static int linear_stop (mddev_t *mddev) static int linear_stop (mddev_t *mddev)
{ {
linear_conf_t *conf = mddev_to_conf(mddev); linear_conf_t *conf = mddev_to_conf(mddev);
int i;
for (i = 0; i < MD_SB_DISKS; i++)
if (conf->disks[i].bdev)
bdput(conf->disks[i].bdev);
kfree(conf->hash_table); kfree(conf->hash_table);
kfree(conf); kfree(conf);
......
...@@ -881,7 +881,6 @@ static int multipath_run (mddev_t *mddev) ...@@ -881,7 +881,6 @@ static int multipath_run (mddev_t *mddev)
disk->number = desc->number; disk->number = desc->number;
disk->raid_disk = desc->raid_disk; disk->raid_disk = desc->raid_disk;
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
atomic_inc(&rdev->bdev->bd_count);
disk->operational = 0; disk->operational = 0;
disk->spare = 1; disk->spare = 1;
disk->used_slot = 1; disk->used_slot = 1;
...@@ -1006,9 +1005,6 @@ static int multipath_run (mddev_t *mddev) ...@@ -1006,9 +1005,6 @@ static int multipath_run (mddev_t *mddev)
out_free_conf: out_free_conf:
multipath_shrink_mpbh(conf); multipath_shrink_mpbh(conf);
for (i = 0; i < MD_SB_DISKS; i++)
if (conf->multipaths[i].bdev)
bdput(conf->multipaths[i].bdev);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
out: out:
...@@ -1031,13 +1027,9 @@ static int multipath_run (mddev_t *mddev) ...@@ -1031,13 +1027,9 @@ static int multipath_run (mddev_t *mddev)
static int multipath_stop (mddev_t *mddev) static int multipath_stop (mddev_t *mddev)
{ {
multipath_conf_t *conf = mddev_to_conf(mddev); multipath_conf_t *conf = mddev_to_conf(mddev);
int i;
md_unregister_thread(conf->thread); md_unregister_thread(conf->thread);
multipath_shrink_mpbh(conf); multipath_shrink_mpbh(conf);
for (i = 0; i < MD_SB_DISKS; i++)
if (conf->multipaths[i].bdev)
bdput(conf->multipaths[i].bdev);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
......
...@@ -1301,7 +1301,6 @@ static int run(mddev_t *mddev) ...@@ -1301,7 +1301,6 @@ static int run(mddev_t *mddev)
disk->number = descriptor->number; disk->number = descriptor->number;
disk->raid_disk = disk_idx; disk->raid_disk = disk_idx;
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
atomic_inc(&rdev->bdev->bd_count);
disk->operational = 0; disk->operational = 0;
disk->write_only = 0; disk->write_only = 0;
disk->spare = 0; disk->spare = 0;
...@@ -1333,7 +1332,6 @@ static int run(mddev_t *mddev) ...@@ -1333,7 +1332,6 @@ static int run(mddev_t *mddev)
disk->number = descriptor->number; disk->number = descriptor->number;
disk->raid_disk = disk_idx; disk->raid_disk = disk_idx;
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
atomic_inc(&rdev->bdev->bd_count);
disk->operational = 1; disk->operational = 1;
disk->write_only = 0; disk->write_only = 0;
disk->spare = 0; disk->spare = 0;
...@@ -1348,7 +1346,6 @@ static int run(mddev_t *mddev) ...@@ -1348,7 +1346,6 @@ static int run(mddev_t *mddev)
disk->number = descriptor->number; disk->number = descriptor->number;
disk->raid_disk = disk_idx; disk->raid_disk = disk_idx;
disk->bdev = rdev->bdev; disk->bdev = rdev->bdev;
atomic_inc(&rdev->bdev->bd_count);
disk->operational = 0; disk->operational = 0;
disk->write_only = 0; disk->write_only = 0;
disk->spare = 1; disk->spare = 1;
...@@ -1434,9 +1431,6 @@ static int run(mddev_t *mddev) ...@@ -1434,9 +1431,6 @@ static int run(mddev_t *mddev)
out_free_conf: out_free_conf:
if (conf->r1bio_pool) if (conf->r1bio_pool)
mempool_destroy(conf->r1bio_pool); mempool_destroy(conf->r1bio_pool);
for (i = 0; i < MD_SB_DISKS; i++)
if (conf->mirrors[i].bdev)
bdput(conf->mirrors[i].bdev);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
out: out:
...@@ -1447,14 +1441,10 @@ static int run(mddev_t *mddev) ...@@ -1447,14 +1441,10 @@ static int run(mddev_t *mddev)
static int stop(mddev_t *mddev) static int stop(mddev_t *mddev)
{ {
conf_t *conf = mddev_to_conf(mddev); conf_t *conf = mddev_to_conf(mddev);
int i;
md_unregister_thread(conf->thread); md_unregister_thread(conf->thread);
if (conf->r1bio_pool) if (conf->r1bio_pool)
mempool_destroy(conf->r1bio_pool); mempool_destroy(conf->r1bio_pool);
for (i = 0; i < MD_SB_DISKS; i++)
if (conf->mirrors[i].bdev)
bdput(conf->mirrors[i].bdev);
kfree(conf); kfree(conf);
mddev->private = NULL; mddev->private = NULL;
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
......
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