summaryrefslogtreecommitdiff
path: root/drivers/md/dm-thin-metadata.c
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2012-07-27 18:08:14 +0400
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 18:08:14 +0400
commit66b1edc05e3f4c1227f51e40f2ead3e973c00cb0 (patch)
treee9c549057d91f1bb57755b1ac0a38512fcea3664 /drivers/md/dm-thin-metadata.c
parent0fa5b17b08baa37919ddd21529081e3090d47de5 (diff)
downloadlinux-66b1edc05e3f4c1227f51e40f2ead3e973c00cb0.tar.xz
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:
return r;
}
-static int __open_or_format_metadata(struct dm_pool_metadata *pmd)
+static int __open_or_format_metadata(struct dm_pool_metadata *pmd, bool format_device)
{
int r, unformatted;
@@ -633,12 +633,12 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd)
return r;
if (unformatted)
- return __format_metadata(pmd);
- else
- return __open_metadata(pmd);
+ return format_device ? __format_metadata(pmd) : -EPERM;
+
+ return __open_metadata(pmd);
}
-static int __create_persistent_data_objects(struct dm_pool_metadata *pmd)
+static int __create_persistent_data_objects(struct dm_pool_metadata *pmd, bool format_device)
{
int r;
@@ -650,7 +650,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd)
return PTR_ERR(pmd->bm);
}
- r = __open_or_format_metadata(pmd);
+ r = __open_or_format_metadata(pmd, format_device);
if (r)
dm_block_manager_destroy(pmd->bm);
@@ -792,7 +792,8 @@ out_locked:
}
struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
- sector_t data_block_size)
+ sector_t data_block_size,
+ bool format_device)
{
int r;
struct dm_pool_metadata *pmd;
@@ -809,7 +810,7 @@ struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
pmd->bdev = bdev;
pmd->data_block_size = data_block_size;
- r = __create_persistent_data_objects(pmd);
+ r = __create_persistent_data_objects(pmd, format_device);
if (r) {
kfree(pmd);
return ERR_PTR(r);