summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2012-07-27 15:08:12 +0100
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 15:08:12 +0100
commitd6332814e343c76097ff10ed8225069e6392022f (patch)
treedcd4c0a1db3f91e90cb985833dc3ab424e24a0ab /drivers
parent583ceee2ed1d171718aee348163f2ed25d461772 (diff)
dm thin metadata: use struct dm_pool_metadata members in __open_or_format_metadata
Clean up __open_or_format_metadata in dm-thin-metadata by using struct dm_pool_metadata members to replace local variables. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/dm-thin-metadata.c40
1 files changed, 17 insertions, 23 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 9f7c1e01dda2..dceec441ef30 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -486,31 +486,29 @@ bad_locked:
}
static int __open_or_format_metadata(struct dm_pool_metadata *pmd,
- struct dm_block_manager *bm,
dm_block_t nr_blocks, int create)
{
int r;
- struct dm_space_map *sm, *data_sm;
- struct dm_transaction_manager *tm;
struct dm_block *sblock;
if (create) {
- r = dm_tm_create_with_sm(bm, THIN_SUPERBLOCK_LOCATION, &tm, &sm);
+ r = dm_tm_create_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION,
+ &pmd->tm, &pmd->metadata_sm);
if (r < 0) {
DMERR("tm_create_with_sm failed");
return r;
}
- data_sm = dm_sm_disk_create(tm, nr_blocks);
- if (IS_ERR(data_sm)) {
+ pmd->data_sm = dm_sm_disk_create(pmd->tm, nr_blocks);
+ if (IS_ERR(pmd->data_sm)) {
DMERR("sm_disk_create failed");
- r = PTR_ERR(data_sm);
+ r = PTR_ERR(pmd->data_sm);
goto bad;
}
} else {
struct thin_disk_superblock *disk_super;
- r = dm_bm_read_lock(bm, THIN_SUPERBLOCK_LOCATION,
+ r = dm_bm_read_lock(pmd->bm, THIN_SUPERBLOCK_LOCATION,
&sb_validator, &sblock);
if (r < 0) {
DMERR("couldn't read superblock");
@@ -518,33 +516,29 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd,
}
disk_super = dm_block_data(sblock);
- r = dm_tm_open_with_sm(bm, THIN_SUPERBLOCK_LOCATION,
+ r = dm_tm_open_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION,
disk_super->metadata_space_map_root,
sizeof(disk_super->metadata_space_map_root),
- &tm, &sm);
+ &pmd->tm, &pmd->metadata_sm);
if (r < 0) {
DMERR("tm_open_with_sm failed");
dm_bm_unlock(sblock);
return r;
}
- data_sm = dm_sm_disk_open(tm, disk_super->data_space_map_root,
- sizeof(disk_super->data_space_map_root));
- if (IS_ERR(data_sm)) {
+ pmd->data_sm = dm_sm_disk_open(pmd->tm, disk_super->data_space_map_root,
+ sizeof(disk_super->data_space_map_root));
+ if (IS_ERR(pmd->data_sm)) {
DMERR("sm_disk_open failed");
dm_bm_unlock(sblock);
- r = PTR_ERR(data_sm);
+ r = PTR_ERR(pmd->data_sm);
goto bad;
}
dm_bm_unlock(sblock);
}
- pmd->bm = bm;
- pmd->metadata_sm = sm;
- pmd->data_sm = data_sm;
- pmd->tm = tm;
- pmd->nb_tm = dm_tm_create_non_blocking_clone(tm);
+ pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm);
if (!pmd->nb_tm) {
DMERR("could not create clone tm");
r = -ENOMEM;
@@ -578,10 +572,10 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd,
return 0;
bad_data_sm:
- dm_sm_destroy(data_sm);
+ dm_sm_destroy(pmd->data_sm);
bad:
- dm_tm_destroy(tm);
- dm_sm_destroy(sm);
+ dm_tm_destroy(pmd->tm);
+ dm_sm_destroy(pmd->metadata_sm);
return r;
}
@@ -605,7 +599,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd,
return r;
}
- r = __open_or_format_metadata(pmd, pmd->bm, nr_blocks, *create);
+ r = __open_or_format_metadata(pmd, nr_blocks, *create);
if (r)
dm_block_manager_destroy(pmd->bm);