提交 d6332814 编写于 作者: J Joe Thornber 提交者: Alasdair G Kergon

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: NJoe Thornber <ejt@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NAlasdair G Kergon <agk@redhat.com>
上级 583ceee2
...@@ -486,31 +486,29 @@ static int __write_initial_superblock(struct dm_pool_metadata *pmd) ...@@ -486,31 +486,29 @@ static int __write_initial_superblock(struct dm_pool_metadata *pmd)
} }
static int __open_or_format_metadata(struct dm_pool_metadata *pmd, static int __open_or_format_metadata(struct dm_pool_metadata *pmd,
struct dm_block_manager *bm,
dm_block_t nr_blocks, int create) dm_block_t nr_blocks, int create)
{ {
int r; int r;
struct dm_space_map *sm, *data_sm;
struct dm_transaction_manager *tm;
struct dm_block *sblock; struct dm_block *sblock;
if (create) { 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) { if (r < 0) {
DMERR("tm_create_with_sm failed"); DMERR("tm_create_with_sm failed");
return r; return r;
} }
data_sm = dm_sm_disk_create(tm, nr_blocks); pmd->data_sm = dm_sm_disk_create(pmd->tm, nr_blocks);
if (IS_ERR(data_sm)) { if (IS_ERR(pmd->data_sm)) {
DMERR("sm_disk_create failed"); DMERR("sm_disk_create failed");
r = PTR_ERR(data_sm); r = PTR_ERR(pmd->data_sm);
goto bad; goto bad;
} }
} else { } else {
struct thin_disk_superblock *disk_super; 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); &sb_validator, &sblock);
if (r < 0) { if (r < 0) {
DMERR("couldn't read superblock"); DMERR("couldn't read superblock");
...@@ -518,33 +516,29 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd, ...@@ -518,33 +516,29 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd,
} }
disk_super = dm_block_data(sblock); 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, disk_super->metadata_space_map_root,
sizeof(disk_super->metadata_space_map_root), sizeof(disk_super->metadata_space_map_root),
&tm, &sm); &pmd->tm, &pmd->metadata_sm);
if (r < 0) { if (r < 0) {
DMERR("tm_open_with_sm failed"); DMERR("tm_open_with_sm failed");
dm_bm_unlock(sblock); dm_bm_unlock(sblock);
return r; return r;
} }
data_sm = dm_sm_disk_open(tm, disk_super->data_space_map_root, pmd->data_sm = dm_sm_disk_open(pmd->tm, disk_super->data_space_map_root,
sizeof(disk_super->data_space_map_root)); sizeof(disk_super->data_space_map_root));
if (IS_ERR(data_sm)) { if (IS_ERR(pmd->data_sm)) {
DMERR("sm_disk_open failed"); DMERR("sm_disk_open failed");
dm_bm_unlock(sblock); dm_bm_unlock(sblock);
r = PTR_ERR(data_sm); r = PTR_ERR(pmd->data_sm);
goto bad; goto bad;
} }
dm_bm_unlock(sblock); dm_bm_unlock(sblock);
} }
pmd->bm = bm; pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm);
pmd->metadata_sm = sm;
pmd->data_sm = data_sm;
pmd->tm = tm;
pmd->nb_tm = dm_tm_create_non_blocking_clone(tm);
if (!pmd->nb_tm) { if (!pmd->nb_tm) {
DMERR("could not create clone tm"); DMERR("could not create clone tm");
r = -ENOMEM; r = -ENOMEM;
...@@ -578,10 +572,10 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd, ...@@ -578,10 +572,10 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd,
return 0; return 0;
bad_data_sm: bad_data_sm:
dm_sm_destroy(data_sm); dm_sm_destroy(pmd->data_sm);
bad: bad:
dm_tm_destroy(tm); dm_tm_destroy(pmd->tm);
dm_sm_destroy(sm); dm_sm_destroy(pmd->metadata_sm);
return r; return r;
} }
...@@ -605,7 +599,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, ...@@ -605,7 +599,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd,
return r; return r;
} }
r = __open_or_format_metadata(pmd, pmd->bm, nr_blocks, *create); r = __open_or_format_metadata(pmd, nr_blocks, *create);
if (r) if (r)
dm_block_manager_destroy(pmd->bm); dm_block_manager_destroy(pmd->bm);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册