diff options
author | Joe Thornber <ejt@redhat.com> | 2012-07-27 10:08:15 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2012-07-27 10:08:15 -0400 |
commit | 12ba58af46e5973822f1cfaaf5f29a2a17a523bf (patch) | |
tree | 4641ca8730db9c61a34052cf267765305323b896 | |
parent | 310975573ba40ab526b0d76d28225d8d0999d72b (diff) |
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>
-rw-r--r-- | drivers/md/dm-thin-metadata.c | 20 | ||||
-rw-r--r-- | drivers/md/dm-thin-metadata.h | 6 |
2 files changed, 22 insertions, 4 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 4f5b11c195f4..d30bc09fd7c4 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
@@ -184,6 +184,7 @@ struct dm_pool_metadata { | |||
184 | uint64_t trans_id; | 184 | uint64_t trans_id; |
185 | unsigned long flags; | 185 | unsigned long flags; |
186 | sector_t data_block_size; | 186 | sector_t data_block_size; |
187 | bool read_only:1; | ||
187 | }; | 188 | }; |
188 | 189 | ||
189 | struct dm_thin_device { | 190 | struct dm_thin_device { |
@@ -807,6 +808,7 @@ struct dm_pool_metadata *dm_pool_metadata_open(struct block_device *bdev, | |||
807 | init_rwsem(&pmd->root_lock); | 808 | init_rwsem(&pmd->root_lock); |
808 | pmd->time = 0; | 809 | pmd->time = 0; |
809 | INIT_LIST_HEAD(&pmd->thin_devices); | 810 | INIT_LIST_HEAD(&pmd->thin_devices); |
811 | pmd->read_only = false; | ||
810 | pmd->bdev = bdev; | 812 | pmd->bdev = bdev; |
811 | pmd->data_block_size = data_block_size; | 813 | pmd->data_block_size = data_block_size; |
812 | 814 | ||
@@ -849,10 +851,12 @@ int dm_pool_metadata_close(struct dm_pool_metadata *pmd) | |||
849 | return -EBUSY; | 851 | return -EBUSY; |
850 | } | 852 | } |
851 | 853 | ||
852 | r = __commit_transaction(pmd); | 854 | if (!pmd->read_only) { |
853 | if (r < 0) | 855 | r = __commit_transaction(pmd); |
854 | DMWARN("%s: __commit_transaction() failed, error = %d", | 856 | if (r < 0) |
855 | __func__, r); | 857 | DMWARN("%s: __commit_transaction() failed, error = %d", |
858 | __func__, r); | ||
859 | } | ||
856 | 860 | ||
857 | __destroy_persistent_data_objects(pmd); | 861 | __destroy_persistent_data_objects(pmd); |
858 | kfree(pmd); | 862 | kfree(pmd); |
@@ -1587,3 +1591,11 @@ int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_count) | |||
1587 | 1591 | ||
1588 | return r; | 1592 | return r; |
1589 | } | 1593 | } |
1594 | |||
1595 | void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd) | ||
1596 | { | ||
1597 | down_write(&pmd->root_lock); | ||
1598 | pmd->read_only = true; | ||
1599 | dm_bm_set_read_only(pmd->bm); | ||
1600 | up_write(&pmd->root_lock); | ||
1601 | } | ||
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h index 1632fec1660d..2bbe622f299d 100644 --- a/drivers/md/dm-thin-metadata.h +++ b/drivers/md/dm-thin-metadata.h | |||
@@ -174,6 +174,12 @@ int dm_pool_get_data_dev_size(struct dm_pool_metadata *pmd, dm_block_t *result); | |||
174 | */ | 174 | */ |
175 | int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_size); | 175 | int dm_pool_resize_data_dev(struct dm_pool_metadata *pmd, dm_block_t new_size); |
176 | 176 | ||
177 | /* | ||
178 | * Flicks the underlying block manager into read only mode, so you know | ||
179 | * that nothing is changing. | ||
180 | */ | ||
181 | void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd); | ||
182 | |||
177 | /*----------------------------------------------------------------*/ | 183 | /*----------------------------------------------------------------*/ |
178 | 184 | ||
179 | #endif | 185 | #endif |