diff options
author | Joe Thornber <ejt@redhat.com> | 2012-07-27 10:08:14 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-07-27 10:08:14 -0400 |
commit | 0fa5b17b08baa37919ddd21529081e3090d47de5 (patch) | |
tree | f6e5ad3bf444e20856c4be52752056a4dfdd0973 /drivers/md/dm-thin-metadata.c | |
parent | d73ec52538041f29a8ae22bc72521222279439b9 (diff) |
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 'drivers/md/dm-thin-metadata.c')
-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) | |||
500 | if (IS_ERR(pmd->data_sm)) { | 500 | if (IS_ERR(pmd->data_sm)) { |
501 | DMERR("sm_disk_create failed"); | 501 | DMERR("sm_disk_create failed"); |
502 | r = PTR_ERR(pmd->data_sm); | 502 | r = PTR_ERR(pmd->data_sm); |
503 | goto bad; | 503 | goto bad_cleanup_tm; |
504 | } | 504 | } |
505 | 505 | ||
506 | pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); | 506 | pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); |
507 | if (!pmd->nb_tm) { | 507 | if (!pmd->nb_tm) { |
508 | DMERR("could not create clone tm"); | 508 | DMERR("could not create non-blocking clone tm"); |
509 | r = -ENOMEM; | 509 | r = -ENOMEM; |
510 | goto bad_data_sm; | 510 | goto bad_cleanup_data_sm; |
511 | } | 511 | } |
512 | 512 | ||
513 | __setup_btree_details(pmd); | 513 | __setup_btree_details(pmd); |
514 | 514 | ||
515 | r = dm_btree_empty(&pmd->info, &pmd->root); | 515 | r = dm_btree_empty(&pmd->info, &pmd->root); |
516 | if (r < 0) | 516 | if (r < 0) |
517 | goto bad_data_sm; | 517 | goto bad_cleanup_nb_tm; |
518 | 518 | ||
519 | r = dm_btree_empty(&pmd->details_info, &pmd->details_root); | 519 | r = dm_btree_empty(&pmd->details_info, &pmd->details_root); |
520 | if (r < 0) { | 520 | if (r < 0) { |
521 | DMERR("couldn't create devices root"); | 521 | DMERR("couldn't create devices root"); |
522 | goto bad_data_sm; | 522 | goto bad_cleanup_nb_tm; |
523 | } | 523 | } |
524 | 524 | ||
525 | r = __write_initial_superblock(pmd); | 525 | r = __write_initial_superblock(pmd); |
526 | if (r) | 526 | if (r) |
527 | goto bad_data_sm; | 527 | goto bad_cleanup_nb_tm; |
528 | 528 | ||
529 | return 0; | 529 | return 0; |
530 | 530 | ||
531 | bad_data_sm: | 531 | bad_cleanup_nb_tm: |
532 | dm_tm_destroy(pmd->nb_tm); | ||
533 | bad_cleanup_data_sm: | ||
532 | dm_sm_destroy(pmd->data_sm); | 534 | dm_sm_destroy(pmd->data_sm); |
533 | bad: | 535 | bad_cleanup_tm: |
534 | dm_tm_destroy(pmd->tm); | 536 | dm_tm_destroy(pmd->tm); |
535 | dm_sm_destroy(pmd->metadata_sm); | 537 | dm_sm_destroy(pmd->metadata_sm); |
536 | 538 | ||
@@ -581,10 +583,8 @@ static int __open_metadata(struct dm_pool_metadata *pmd) | |||
581 | disk_super = dm_block_data(sblock); | 583 | disk_super = dm_block_data(sblock); |
582 | 584 | ||
583 | r = __check_incompat_features(disk_super, pmd); | 585 | r = __check_incompat_features(disk_super, pmd); |
584 | if (r < 0) { | 586 | if (r < 0) |
585 | dm_bm_unlock(sblock); | 587 | goto bad_unlock_sblock; |
586 | return r; | ||
587 | } | ||
588 | 588 | ||
589 | r = dm_tm_open_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION, | 589 | r = dm_tm_open_with_sm(pmd->bm, THIN_SUPERBLOCK_LOCATION, |
590 | disk_super->metadata_space_map_root, | 590 | disk_super->metadata_space_map_root, |
@@ -592,35 +592,34 @@ static int __open_metadata(struct dm_pool_metadata *pmd) | |||
592 | &pmd->tm, &pmd->metadata_sm); | 592 | &pmd->tm, &pmd->metadata_sm); |
593 | if (r < 0) { | 593 | if (r < 0) { |
594 | DMERR("tm_open_with_sm failed"); | 594 | DMERR("tm_open_with_sm failed"); |
595 | dm_bm_unlock(sblock); | 595 | goto bad_unlock_sblock; |
596 | return r; | ||
597 | } | 596 | } |
598 | 597 | ||
599 | pmd->data_sm = dm_sm_disk_open(pmd->tm, disk_super->data_space_map_root, | 598 | pmd->data_sm = dm_sm_disk_open(pmd->tm, disk_super->data_space_map_root, |
600 | sizeof(disk_super->data_space_map_root)); | 599 | sizeof(disk_super->data_space_map_root)); |
601 | if (IS_ERR(pmd->data_sm)) { | 600 | if (IS_ERR(pmd->data_sm)) { |
602 | DMERR("sm_disk_open failed"); | 601 | DMERR("sm_disk_open failed"); |
603 | dm_bm_unlock(sblock); | ||
604 | r = PTR_ERR(pmd->data_sm); | 602 | r = PTR_ERR(pmd->data_sm); |
605 | goto bad; | 603 | goto bad_cleanup_tm; |
606 | } | 604 | } |
607 | 605 | ||
608 | dm_bm_unlock(sblock); | ||
609 | |||
610 | pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); | 606 | pmd->nb_tm = dm_tm_create_non_blocking_clone(pmd->tm); |
611 | if (!pmd->nb_tm) { | 607 | if (!pmd->nb_tm) { |
612 | DMERR("could not create clone tm"); | 608 | DMERR("could not create non-blocking clone tm"); |
613 | r = -ENOMEM; | 609 | r = -ENOMEM; |
614 | goto bad_data_sm; | 610 | goto bad_cleanup_data_sm; |
615 | } | 611 | } |
616 | 612 | ||
617 | __setup_btree_details(pmd); | 613 | __setup_btree_details(pmd); |
614 | return dm_bm_unlock(sblock); | ||
618 | 615 | ||
619 | bad_data_sm: | 616 | bad_cleanup_data_sm: |
620 | dm_sm_destroy(pmd->data_sm); | 617 | dm_sm_destroy(pmd->data_sm); |
621 | bad: | 618 | bad_cleanup_tm: |
622 | dm_tm_destroy(pmd->tm); | 619 | dm_tm_destroy(pmd->tm); |
623 | dm_sm_destroy(pmd->metadata_sm); | 620 | dm_sm_destroy(pmd->metadata_sm); |
621 | bad_unlock_sblock: | ||
622 | dm_bm_unlock(sblock); | ||
624 | 623 | ||
625 | return r; | 624 | return r; |
626 | } | 625 | } |