diff options
author | Joe Thornber <ejt@redhat.com> | 2013-12-04 16:58:19 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2013-12-10 16:35:13 -0500 |
commit | 9b7aaa64f96f7ca280d75326fca42f42017b89ef (patch) | |
tree | a0028aeb56bc229e9bc7b1dfcecbb3f03d213131 /drivers | |
parent | 5383ef3a929a1366e2ced45cd6d74be7aa2a2281 (diff) |
dm thin: allow pool in read-only mode to transition to read-write mode
A thin-pool may be in read-only mode because the pool's data or metadata
space was exhausted. To allow for recovery, by adding more space to the
pool, we must allow a pool to transition from PM_READ_ONLY to PM_WRITE
mode. Otherwise, running out of space will render the pool permanently
read-only.
Signed-off-by: Joe Thornber <ejt@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-thin-metadata.c | 8 | ||||
-rw-r--r-- | drivers/md/dm-thin-metadata.h | 1 | ||||
-rw-r--r-- | drivers/md/dm-thin.c | 12 | ||||
-rw-r--r-- | drivers/md/persistent-data/dm-block-manager.c | 6 | ||||
-rw-r--r-- | drivers/md/persistent-data/dm-block-manager.h | 7 |
5 files changed, 29 insertions, 5 deletions
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index 60bce435f4fa..8a30ad54bd46 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
@@ -1697,6 +1697,14 @@ void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd) | |||
1697 | up_write(&pmd->root_lock); | 1697 | up_write(&pmd->root_lock); |
1698 | } | 1698 | } |
1699 | 1699 | ||
1700 | void dm_pool_metadata_read_write(struct dm_pool_metadata *pmd) | ||
1701 | { | ||
1702 | down_write(&pmd->root_lock); | ||
1703 | pmd->read_only = false; | ||
1704 | dm_bm_set_read_write(pmd->bm); | ||
1705 | up_write(&pmd->root_lock); | ||
1706 | } | ||
1707 | |||
1700 | int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, | 1708 | int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, |
1701 | dm_block_t threshold, | 1709 | dm_block_t threshold, |
1702 | dm_sm_threshold_fn fn, | 1710 | dm_sm_threshold_fn fn, |
diff --git a/drivers/md/dm-thin-metadata.h b/drivers/md/dm-thin-metadata.h index 845ebbe589a9..7bcc0e1d6238 100644 --- a/drivers/md/dm-thin-metadata.h +++ b/drivers/md/dm-thin-metadata.h | |||
@@ -193,6 +193,7 @@ int dm_pool_resize_metadata_dev(struct dm_pool_metadata *pmd, dm_block_t new_siz | |||
193 | * that nothing is changing. | 193 | * that nothing is changing. |
194 | */ | 194 | */ |
195 | void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd); | 195 | void dm_pool_metadata_read_only(struct dm_pool_metadata *pmd); |
196 | void dm_pool_metadata_read_write(struct dm_pool_metadata *pmd); | ||
196 | 197 | ||
197 | int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, | 198 | int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, |
198 | dm_block_t threshold, | 199 | dm_block_t threshold, |
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 0d7852e2b275..ee29037ffc2e 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
@@ -1425,6 +1425,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode mode) | |||
1425 | break; | 1425 | break; |
1426 | 1426 | ||
1427 | case PM_WRITE: | 1427 | case PM_WRITE: |
1428 | dm_pool_metadata_read_write(pool->pmd); | ||
1428 | pool->process_bio = process_bio; | 1429 | pool->process_bio = process_bio; |
1429 | pool->process_discard = process_discard; | 1430 | pool->process_discard = process_discard; |
1430 | pool->process_prepared_mapping = process_prepared_mapping; | 1431 | pool->process_prepared_mapping = process_prepared_mapping; |
@@ -1641,12 +1642,19 @@ static int bind_control_target(struct pool *pool, struct dm_target *ti) | |||
1641 | struct pool_c *pt = ti->private; | 1642 | struct pool_c *pt = ti->private; |
1642 | 1643 | ||
1643 | /* | 1644 | /* |
1644 | * We want to make sure that degraded pools are never upgraded. | 1645 | * We want to make sure that a pool in PM_FAIL mode is never upgraded. |
1645 | */ | 1646 | */ |
1646 | enum pool_mode old_mode = pool->pf.mode; | 1647 | enum pool_mode old_mode = pool->pf.mode; |
1647 | enum pool_mode new_mode = pt->adjusted_pf.mode; | 1648 | enum pool_mode new_mode = pt->adjusted_pf.mode; |
1648 | 1649 | ||
1649 | if (old_mode > new_mode) | 1650 | /* |
1651 | * If we were in PM_FAIL mode, rollback of metadata failed. We're | ||
1652 | * not going to recover without a thin_repair. So we never let the | ||
1653 | * pool move out of the old mode. On the other hand a PM_READ_ONLY | ||
1654 | * may have been due to a lack of metadata or data space, and may | ||
1655 | * now work (ie. if the underlying devices have been resized). | ||
1656 | */ | ||
1657 | if (old_mode == PM_FAIL) | ||
1650 | new_mode = old_mode; | 1658 | new_mode = old_mode; |
1651 | 1659 | ||
1652 | pool->ti = ti; | 1660 | pool->ti = ti; |
diff --git a/drivers/md/persistent-data/dm-block-manager.c b/drivers/md/persistent-data/dm-block-manager.c index a7e8bf296388..064a3c271baa 100644 --- a/drivers/md/persistent-data/dm-block-manager.c +++ b/drivers/md/persistent-data/dm-block-manager.c | |||
@@ -626,6 +626,12 @@ void dm_bm_set_read_only(struct dm_block_manager *bm) | |||
626 | } | 626 | } |
627 | EXPORT_SYMBOL_GPL(dm_bm_set_read_only); | 627 | EXPORT_SYMBOL_GPL(dm_bm_set_read_only); |
628 | 628 | ||
629 | void dm_bm_set_read_write(struct dm_block_manager *bm) | ||
630 | { | ||
631 | bm->read_only = false; | ||
632 | } | ||
633 | EXPORT_SYMBOL_GPL(dm_bm_set_read_write); | ||
634 | |||
629 | u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor) | 635 | u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor) |
630 | { | 636 | { |
631 | return crc32c(~(u32) 0, data, len) ^ init_xor; | 637 | return crc32c(~(u32) 0, data, len) ^ init_xor; |
diff --git a/drivers/md/persistent-data/dm-block-manager.h b/drivers/md/persistent-data/dm-block-manager.h index 9a82083a66b6..13cd58e1fe69 100644 --- a/drivers/md/persistent-data/dm-block-manager.h +++ b/drivers/md/persistent-data/dm-block-manager.h | |||
@@ -108,9 +108,9 @@ int dm_bm_unlock(struct dm_block *b); | |||
108 | int dm_bm_flush_and_unlock(struct dm_block_manager *bm, | 108 | int dm_bm_flush_and_unlock(struct dm_block_manager *bm, |
109 | struct dm_block *superblock); | 109 | struct dm_block *superblock); |
110 | 110 | ||
111 | /* | 111 | /* |
112 | * Request data be prefetched into the cache. | 112 | * Request data is prefetched into the cache. |
113 | */ | 113 | */ |
114 | void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b); | 114 | void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b); |
115 | 115 | ||
116 | /* | 116 | /* |
@@ -125,6 +125,7 @@ void dm_bm_prefetch(struct dm_block_manager *bm, dm_block_t b); | |||
125 | * be returned if you do. | 125 | * be returned if you do. |
126 | */ | 126 | */ |
127 | void dm_bm_set_read_only(struct dm_block_manager *bm); | 127 | void dm_bm_set_read_only(struct dm_block_manager *bm); |
128 | void dm_bm_set_read_write(struct dm_block_manager *bm); | ||
128 | 129 | ||
129 | u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor); | 130 | u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor); |
130 | 131 | ||