diff options
author | Joe Thornber <ejt@redhat.com> | 2014-12-11 06:12:19 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2014-12-17 11:59:36 -0500 |
commit | 2c43fd26e46734430122b8d2ad3024bb532df3ef (patch) | |
tree | d0166f1fe97d83eef8f51a633201b817e309734b /drivers/md | |
parent | 45ec9bd0fd7abf8705e7cf12205ff69fe9d51181 (diff) |
dm thin: fix missing out-of-data-space to write mode transition if blocks are released
Discard bios and thin device deletion have the potential to release data
blocks. If the thin-pool is in out-of-data-space mode, and blocks were
released, transition the thin-pool back to full write mode.
The correct time to do this is just after the thin-pool metadata commit.
It cannot be done before the commit because the space maps will not
allow immediate reuse of the data blocks in case there's a rollback
following power failure.
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/md')
-rw-r--r-- | drivers/md/dm-thin.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 14b51a4fdf6b..922aa553e9e0 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
@@ -1127,6 +1127,24 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block, | |||
1127 | schedule_zero(tc, virt_block, data_dest, cell, bio); | 1127 | schedule_zero(tc, virt_block, data_dest, cell, bio); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); | ||
1131 | |||
1132 | static void check_for_space(struct pool *pool) | ||
1133 | { | ||
1134 | int r; | ||
1135 | dm_block_t nr_free; | ||
1136 | |||
1137 | if (get_pool_mode(pool) != PM_OUT_OF_DATA_SPACE) | ||
1138 | return; | ||
1139 | |||
1140 | r = dm_pool_get_free_block_count(pool->pmd, &nr_free); | ||
1141 | if (r) | ||
1142 | return; | ||
1143 | |||
1144 | if (nr_free) | ||
1145 | set_pool_mode(pool, PM_WRITE); | ||
1146 | } | ||
1147 | |||
1130 | /* | 1148 | /* |
1131 | * A non-zero return indicates read_only or fail_io mode. | 1149 | * A non-zero return indicates read_only or fail_io mode. |
1132 | * Many callers don't care about the return value. | 1150 | * Many callers don't care about the return value. |
@@ -1141,6 +1159,8 @@ static int commit(struct pool *pool) | |||
1141 | r = dm_pool_commit_metadata(pool->pmd); | 1159 | r = dm_pool_commit_metadata(pool->pmd); |
1142 | if (r) | 1160 | if (r) |
1143 | metadata_operation_failed(pool, "dm_pool_commit_metadata", r); | 1161 | metadata_operation_failed(pool, "dm_pool_commit_metadata", r); |
1162 | else | ||
1163 | check_for_space(pool); | ||
1144 | 1164 | ||
1145 | return r; | 1165 | return r; |
1146 | } | 1166 | } |
@@ -1159,8 +1179,6 @@ static void check_low_water_mark(struct pool *pool, dm_block_t free_blocks) | |||
1159 | } | 1179 | } |
1160 | } | 1180 | } |
1161 | 1181 | ||
1162 | static void set_pool_mode(struct pool *pool, enum pool_mode new_mode); | ||
1163 | |||
1164 | static int alloc_data_block(struct thin_c *tc, dm_block_t *result) | 1182 | static int alloc_data_block(struct thin_c *tc, dm_block_t *result) |
1165 | { | 1183 | { |
1166 | int r; | 1184 | int r; |