aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-thin-metadata.c
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2012-07-27 10:08:14 -0400
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 10:08:14 -0400
commit66b1edc05e3f4c1227f51e40f2ead3e973c00cb0 (patch)
treee9c549057d91f1bb57755b1ac0a38512fcea3664 /drivers/md/dm-thin-metadata.c
parent0fa5b17b08baa37919ddd21529081e3090d47de5 (diff)
dm thin metadata: add format option to dm_pool_metadata_open
Add a parameter to dm_pool_metadata_open to indicate whether or not an unformatted metadata area should be formatted. 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.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 1b6d2857b3f1..5ae31185e47c 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -624,7 +624,7 @@ bad_unlock_sblock:
624 return r; 624 return r;
625} 625}
626 626
627static int __open_or_format_metadata(struct dm_pool_metadata *pmd) 627static int __open_or_format_metadata(struct dm_pool_metadata *pmd, bool format_device)
628{ 628{
629 int r, unformatted; 629 int r, unformatted;
630 630
@@ -633,12 +633,12 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd)
633 return r; 633 return r;
634 634
635 if (unformatted) 635 if (unformatted)
636 return __format_metadata(pmd); 636 return format_device ? __format_metadata(pmd) : -EPERM;
637 else 637
638 return __open_metadata(pmd); 638 return __open_metadata(pmd);
639} 639}
640 640
641static int __create_persistent_data_objects(struct dm_pool_metadata *pmd) 641static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool format_device)
642{ 642{
643 int r; 643 int r;
644 644
@@ -650,7 +650,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd)
650 return PTR_ERR(pmd->bm); 650 return PTR_ERR(pmd->bm);
651 } 651 }
652 652
653 r = __open_or_format_metadata(pmd); 653 r = __open_or_format_metadata(pmd, format_device);
654 if (r) 654 if (r)
655 dm_block_manager_destroy(pmd->bm); 655 dm_block_manager_destroy(pmd->bm);
656 656
@@ -792,7 +792,8 @@ out_locked:
792} 792}
793 793
794struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, 794struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
795 sector_t data_block_size) 795 sector_t data_block_size,
796 bool format_device)
796{ 797{
797 int r; 798 int r;
798 struct dm_pool_metadata *pmd; 799 struct dm_pool_metadata *pmd;
@@ -809,7 +810,7 @@ struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
809 pmd->bdev = bdev; 810 pmd->bdev = bdev;
810 pmd->data_block_size = data_block_size; 811 pmd->data_block_size = data_block_size;
811 812
812 r = __create_persistent_data_objects(pmd); 813 r = __create_persistent_data_objects(pmd, format_device);
813 if (r) { 814 if (r) {
814 kfree(pmd); 815 kfree(pmd);
815 return ERR_PTR(r); 816 return ERR_PTR(r);