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>
This commit is contained in:
parent
0fa5b17b08
commit
66b1edc05e
|
@ -624,7 +624,7 @@ bad_unlock_sblock:
|
||||||
return r;
|
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;
|
int r, unformatted;
|
||||||
|
|
||||||
|
@ -633,12 +633,12 @@ static int __open_or_format_metadata(struct dm_pool_metadata *pmd)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (unformatted)
|
if (unformatted)
|
||||||
return __format_metadata(pmd);
|
return format_device ? __format_metadata(pmd) : -EPERM;
|
||||||
else
|
|
||||||
return __open_metadata(pmd);
|
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;
|
int r;
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ static int __create_persistent_data_objects(struct dm_pool_metadata *pmd)
|
||||||
return PTR_ERR(pmd->bm);
|
return PTR_ERR(pmd->bm);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = __open_or_format_metadata(pmd);
|
r = __open_or_format_metadata(pmd, format_device);
|
||||||
if (r)
|
if (r)
|
||||||
dm_block_manager_destroy(pmd->bm);
|
dm_block_manager_destroy(pmd->bm);
|
||||||
|
|
||||||
|
@ -792,7 +792,8 @@ out_locked:
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
|
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;
|
int r;
|
||||||
struct dm_pool_metadata *pmd;
|
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->bdev = bdev;
|
||||||
pmd->data_block_size = data_block_size;
|
pmd->data_block_size = data_block_size;
|
||||||
|
|
||||||
r = __create_persistent_data_objects(pmd);
|
r = __create_persistent_data_objects(pmd, format_device);
|
||||||
if (r) {
|
if (r) {
|
||||||
kfree(pmd);
|
kfree(pmd);
|
||||||
return ERR_PTR(r);
|
return ERR_PTR(r);
|
||||||
|
|
|
@ -38,7 +38,8 @@ typedef uint64_t dm_thin_id;
|
||||||
* Reopens or creates a new, empty metadata volume.
|
* Reopens or creates a new, empty metadata volume.
|
||||||
*/
|
*/
|
||||||
struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
|
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 dm_pool_metadata_close(struct dm_pool_metadata *pmd);
|
int dm_pool_metadata_close(struct dm_pool_metadata *pmd);
|
||||||
|
|
||||||
|
|
|
@ -1712,7 +1712,7 @@ static struct pool *pool_create(struct mapped_device *pool_md,
|
||||||
struct pool *pool;
|
struct pool *pool;
|
||||||
struct dm_pool_metadata *pmd;
|
struct dm_pool_metadata *pmd;
|
||||||
|
|
||||||
pmd = dm_pool_metadata_open(metadata_dev, block_size);
|
pmd = dm_pool_metadata_open(metadata_dev, block_size, true);
|
||||||
if (IS_ERR(pmd)) {
|
if (IS_ERR(pmd)) {
|
||||||
*error = "Error creating metadata object";
|
*error = "Error creating metadata object";
|
||||||
return (struct pool *)pmd;
|
return (struct pool *)pmd;
|
||||||
|
|
Loading…
Reference in New Issue