aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
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
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')
-rw-r--r--drivers/md/dm-thin-metadata.c17
-rw-r--r--drivers/md/dm-thin-metadata.h3
-rw-r--r--drivers/md/dm-thin.c2
3 files changed, 12 insertions, 10 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);
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h
index 7b47c0a9a8e3..7e6656c49bd5 100644
--- a/drivers/md/dm-thin-metadata.h
+++ b/drivers/md/dm-thin-metadata.h
@@ -38,7 +38,8 @@ typedef uint64_t dm_thin_id;
38 * Reopens or creates a new, empty metadata volume. 38 * Reopens or creates a new, empty metadata volume.
39 */ 39 */
40struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, 40struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
41 sector_t data_block_size); 41 sector_t data_block_size,
42 bool format_device);
42 43
43int dm_pool_metadata_close(struct dm_pool_metadata *pmd); 44int dm_pool_metadata_close(struct dm_pool_metadata *pmd);
44 45
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 026215566abd..bc9d08c0218b 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -1712,7 +1712,7 @@ static struct pool *pool_create(struct mapped_device *pool_md,
1712 struct pool *pool; 1712 struct pool *pool;
1713 struct dm_pool_metadata *pmd; 1713 struct dm_pool_metadata *pmd;
1714 1714
1715 pmd = dm_pool_metadata_open(metadata_dev, block_size); 1715 pmd = dm_pool_metadata_open(metadata_dev, block_size, true);
1716 if (IS_ERR(pmd)) { 1716 if (IS_ERR(pmd)) {
1717 *error = "Error creating metadata object"; 1717 *error = "Error creating metadata object";
1718 return (struct pool *)pmd; 1718 return (struct pool *)pmd;