summaryrefslogtreecommitdiffstats
path: root/drivers/md/dm-thin-metadata.c
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2012-07-27 15:08:15 +0100
committerAlasdair G Kergon <agk@redhat.com>2012-07-27 15:08:15 +0100
commit12ba58af46e5973822f1cfaaf5f29a2a17a523bf (patch)
tree4641ca8730db9c61a34052cf267765305323b896 /drivers/md/dm-thin-metadata.c
parent310975573ba40ab526b0d76d28225d8d0999d72b (diff)
downloadop-kernel-dev-12ba58af46e5973822f1cfaaf5f29a2a17a523bf.zip
op-kernel-dev-12ba58af46e5973822f1cfaaf5f29a2a17a523bf.tar.gz
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>
Diffstat (limited to 'drivers/md/dm-thin-metadata.c')
-rw-r--r--drivers/md/dm-thin-metadata.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
index 4f5b11c..d30bc09 100644
--- a/drivers/md/dm-thin-metadata.c
+++ b/drivers/md/dm-thin-metadata.c
@@ -184,6 +184,7 @@ struct dm_pool_metadata {
uint64_t trans_id;
unsigned long flags;
sector_t data_block_size;
+ bool read_only:1;
};
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);
pmd->time = 0;
INIT_LIST_HEAD(&pmd->thin_devices);
+ pmd->read_only = false;
pmd->bdev = bdev;
pmd->data_block_size = data_block_size;
@@ -849,10 +851,12 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd)
return -EBUSY;
}
- r = __commit_transaction(pmd);
- if (r < 0)
- DMWARN("%s: __commit_transaction() failed, error = %d",
- __func__, r);
+ if (!pmd->read_only) {
+ r = __commit_transaction(pmd);
+ if (r < 0)
+ DMWARN("%s: __commit_transaction() failed, error = %d",
+ __func__, r);
+ }
__destroy_persistent_data_objects(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;
}
+
+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);
+}
OpenPOWER on IntegriCloud