diff options
author | Joe Thornber <ejt@redhat.com> | 2012-07-27 16:08:14 +0200 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-07-27 16:08:14 +0200 |
commit | 0fa5b17b08baa37919ddd21529081e3090d47de5 (patch) | |
tree | f6e5ad3bf444e20856c4be52752056a4dfdd0973 /drivers/md/dm-thin-metadata.c | |
parent | dm thin metadata: only check incompat features on open (diff) | |
download | linux-0fa5b17b08baa37919ddd21529081e3090d47de5.tar.xz linux-0fa5b17b08baa37919ddd21529081e3090d47de5.zip |
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: 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 '')
-rw-r--r-- | drivers/md/dm-thin-metadata.c | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 867ee52121d4..1b6d2857b3f1 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c @@ -500,37 +500,39 @@ static int __format_metadata(struct dm_pool_metadata *pmd) if (IS_ERR(pmd->data_sm)) { DMERR("sm_disk_create failed"); r = PTR_ERR(pmd->data_sm); - goto bad; + goto bad_cleanup_tm; } pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); if (!pmd->nb_tm) { - DMERR("could not create clone tm"); + DMERR("could not create non-blocking clone tm"); r = -ENOMEM; - goto bad_data_sm; + goto bad_cleanup_data_sm; } __setup_btree_details(pmd); r = dm_btree_empty(&pmd->info, &pmd->root); if (r < 0) - goto bad_data_sm; + goto bad_cleanup_nb_tm; r = dm_btree_empty(&pmd->details_info, &pmd->details_root); if (r < 0) { DMERR("couldn't create devices root"); - goto bad_data_sm; + goto bad_cleanup_nb_tm; } r = __write_initial_superblock(pmd); if (r) - goto bad_data_sm; + goto bad_cleanup_nb_tm; 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); -bad: +bad_cleanup_tm: dm_tm_destroy(pmd->tm); dm_sm_destroy(pmd->metadata_sm); @@ -581,10 +583,8 @@ static int __open_metadata(struct dm_pool_metadata *pmd) disk_super = dm_block_data(sblock); r = __check_incompat_features(disk_super, pmd); - if (r < 0) { - dm_bm_unlock(sblock); - return r; - } + if (r < 0) + goto bad_unlock_sblock; r = dm_tm_open_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION, disk_super->metadata_space_map_root, @@ -592,35 +592,34 @@ static int __open_metadata(struct dm_pool_metadata *pmd) &pmd->tm, &pmd->metadata_sm); if (r < 0) { DMERR("tm_open_with_sm failed"); - dm_bm_unlock(sblock); - return r; + goto bad_unlock_sblock; } 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(pmd->data_sm); - goto bad; + goto bad_cleanup_tm; } - dm_bm_unlock(sblock); - pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); if (!pmd->nb_tm) { - DMERR("could not create clone tm"); + DMERR("could not create non-blocking clone tm"); r = -ENOMEM; - goto bad_data_sm; + goto bad_cleanup_data_sm; } __setup_btree_details(pmd); + return dm_bm_unlock(sblock); -bad_data_sm: +bad_cleanup_data_sm: dm_sm_destroy(pmd->data_sm); -bad: +bad_cleanup_tm: dm_tm_destroy(pmd->tm); dm_sm_destroy(pmd->metadata_sm); +bad_unlock_sblock: + dm_bm_unlock(sblock); return r; } |