dm thin metadata: introduce dm_pool_metadata_set_read_only
Introduce dm_pool_metadata_set_read_only to put the underlying block manager into read-only mode. 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
310975573b
commit
12ba58af46
|
@ -184,6 +184,7 @@ struct dm_pool_metadata {
|
||||||
uint64_t trans_id;
|
uint64_t trans_id;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
sector_t data_block_size;
|
sector_t data_block_size;
|
||||||
|
bool read_only:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dm_thin_device {
|
struct dm_thin_device {
|
||||||
|
@ -807,6 +808,7 @@ struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev,
|
||||||
init_rwsem(&pmd->root_lock);
|
init_rwsem(&pmd->root_lock);
|
||||||
pmd->time = 0;
|
pmd->time = 0;
|
||||||
INIT_LIST_HEAD(&pmd->thin_devices);
|
INIT_LIST_HEAD(&pmd->thin_devices);
|
||||||
|
pmd->read_only = false;
|
||||||
pmd->bdev = bdev;
|
pmd->bdev = bdev;
|
||||||
pmd->data_block_size = data_block_size;
|
pmd->data_block_size = data_block_size;
|
||||||
|
|
||||||
|
@ -849,10 +851,12 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd)
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = __commit_transaction(pmd);
|
if (!pmd->read_only) {
|
||||||
if (r < 0)
|
r = __commit_transaction(pmd);
|
||||||
DMWARN("%s: __commit_transaction() failed, error = %d",
|
if (r < 0)
|
||||||
__func__, r);
|
DMWARN("%s: __commit_transaction() failed, error = %d",
|
||||||
|
__func__, r);
|
||||||
|
}
|
||||||
|
|
||||||
__destroy_persistent_data_objects(pmd);
|
__destroy_persistent_data_objects(pmd);
|
||||||
kfree(pmd);
|
kfree(pmd);
|
||||||
|
@ -1587,3 +1591,11 @@ int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_count)
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd)
|
||||||
|
{
|
||||||
|
down_write(&pmd->root_lock);
|
||||||
|
pmd->read_only = true;
|
||||||
|
dm_bm_set_read_only(pmd->bm);
|
||||||
|
up_write(&pmd->root_lock);
|
||||||
|
}
|
||||||
|
|
|
@ -174,6 +174,12 @@ int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result);
|
||||||
*/
|
*/
|
||||||
int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_size);
|
int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_size);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flicks the underlying block manager into read only mode, so you know
|
||||||
|
* that nothing is changing.
|
||||||
|
*/
|
||||||
|
void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd);
|
||||||
|
|
||||||
/*----------------------------------------------------------------*/
|
/*----------------------------------------------------------------*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue