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

dm thin metadata: tidy up open and format error paths

Tidy up error path in __open_metadata and __format_metadata in dm-thin-metadata.
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>
上级 d73ec525
...@@ -500,37 +500,39 @@ static int __format_metadata(struct dm_pool_metadata *pmd) ...@@ -500,37 +500,39 @@ static int __format_metadata(struct dm_pool_metadata *pmd)
if (IS_ERR(pmd->data_sm)) { if (IS_ERR(pmd->data_sm)) {
DMERR("sm_disk_create failed"); DMERR("sm_disk_create failed");
r = PTR_ERR(pmd->data_sm); r = PTR_ERR(pmd->data_sm);
goto bad; goto bad_cleanup_tm;
} }
pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm);
if (!pmd->nb_tm) { if (!pmd->nb_tm) {
DMERR("could not create clone tm"); DMERR("could not create non-blocking clone tm");
r = -ENOMEM; r = -ENOMEM;
goto bad_data_sm; goto bad_cleanup_data_sm;
} }
__setup_btree_details(pmd); __setup_btree_details(pmd);
r = dm_btree_empty(&pmd->info, &pmd->root); r = dm_btree_empty(&pmd->info, &pmd->root);
if (r < 0) if (r < 0)
goto bad_data_sm; goto bad_cleanup_nb_tm;
r = dm_btree_empty(&pmd->details_info, &pmd->details_root); r = dm_btree_empty(&pmd->details_info, &pmd->details_root);
if (r < 0) { if (r < 0) {
DMERR("couldn't create devices root"); DMERR("couldn't create devices root");
goto bad_data_sm; goto bad_cleanup_nb_tm;
} }
r = __write_initial_superblock(pmd); r = __write_initial_superblock(pmd);
if (r) if (r)
goto bad_data_sm; goto bad_cleanup_nb_tm;
return 0; return 0;
bad_data_sm: bad_cleanup_nb_tm:
dm_tm_destroy(pmd->nb_tm);
bad_cleanup_data_sm:
dm_sm_destroy(pmd->data_sm); dm_sm_destroy(pmd->data_sm);
bad: bad_cleanup_tm:
dm_tm_destroy(pmd->tm); dm_tm_destroy(pmd->tm);
dm_sm_destroy(pmd->metadata_sm); dm_sm_destroy(pmd->metadata_sm);
...@@ -581,10 +583,8 @@ static int __open_metadata(struct dm_pool_metadata *pmd) ...@@ -581,10 +583,8 @@ static int __open_metadata(struct dm_pool_metadata *pmd)
disk_super = dm_block_data(sblock); disk_super = dm_block_data(sblock);
r = __check_incompat_features(disk_super, pmd); r = __check_incompat_features(disk_super, pmd);
if (r < 0) { if (r < 0)
dm_bm_unlock(sblock); goto bad_unlock_sblock;
return r;
}
r = dm_tm_open_with_sm(pmd->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,
...@@ -592,35 +592,34 @@ static int __open_metadata(struct dm_pool_metadata *pmd) ...@@ -592,35 +592,34 @@ static int __open_metadata(struct dm_pool_metadata *pmd)
&pmd->tm, &pmd->metadata_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); goto bad_unlock_sblock;
return r;
} }
pmd->data_sm = dm_sm_disk_open(pmd->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(pmd->data_sm)) { if (IS_ERR(pmd->data_sm)) {
DMERR("sm_disk_open failed"); DMERR("sm_disk_open failed");
dm_bm_unlock(sblock);
r = PTR_ERR(pmd->data_sm); r = PTR_ERR(pmd->data_sm);
goto bad; goto bad_cleanup_tm;
} }
dm_bm_unlock(sblock);
pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm);
if (!pmd->nb_tm) { if (!pmd->nb_tm) {
DMERR("could not create clone tm"); DMERR("could not create non-blocking clone tm");
r = -ENOMEM; r = -ENOMEM;
goto bad_data_sm; goto bad_cleanup_data_sm;
} }
__setup_btree_details(pmd); __setup_btree_details(pmd);
return dm_bm_unlock(sblock);
bad_data_sm: bad_cleanup_data_sm:
dm_sm_destroy(pmd->data_sm); dm_sm_destroy(pmd->data_sm);
bad: bad_cleanup_tm:
dm_tm_destroy(pmd->tm); dm_tm_destroy(pmd->tm);
dm_sm_destroy(pmd->metadata_sm); dm_sm_destroy(pmd->metadata_sm);
bad_unlock_sblock:
dm_bm_unlock(sblock);
return r; return r;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册