diff options
| -rw-r--r-- | drivers/md/dm-thin.c | 29 | ||||
| -rw-r--r-- | drivers/md/dm.c | 2 | ||||
| -rw-r--r-- | mm/memory.c | 4 |
3 files changed, 26 insertions, 9 deletions
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 8735543eacdb..493478989dbd 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; |
| @@ -2155,7 +2173,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode) | |||
| 2155 | pool->process_cell = process_cell_read_only; | 2173 | pool->process_cell = process_cell_read_only; |
| 2156 | pool->process_discard_cell = process_discard_cell; | 2174 | pool->process_discard_cell = process_discard_cell; |
| 2157 | pool->process_prepared_mapping = process_prepared_mapping; | 2175 | pool->process_prepared_mapping = process_prepared_mapping; |
| 2158 | pool->process_prepared_discard = process_prepared_discard_passdown; | 2176 | pool->process_prepared_discard = process_prepared_discard; |
| 2159 | 2177 | ||
| 2160 | if (!pool->pf.error_if_no_space && no_space_timeout) | 2178 | if (!pool->pf.error_if_no_space && no_space_timeout) |
| 2161 | queue_delayed_work(pool->wq, &pool->no_space_timeout, no_space_timeout); | 2179 | queue_delayed_work(pool->wq, &pool->no_space_timeout, no_space_timeout); |
| @@ -3814,6 +3832,8 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
| 3814 | r = -EINVAL; | 3832 | r = -EINVAL; |
| 3815 | goto bad; | 3833 | goto bad; |
| 3816 | } | 3834 | } |
| 3835 | atomic_set(&tc->refcount, 1); | ||
| 3836 | init_completion(&tc->can_destroy); | ||
| 3817 | list_add_tail_rcu(&tc->list, &tc->pool->active_thins); | 3837 | list_add_tail_rcu(&tc->list, &tc->pool->active_thins); |
| 3818 | spin_unlock_irqrestore(&tc->pool->lock, flags); | 3838 | spin_unlock_irqrestore(&tc->pool->lock, flags); |
| 3819 | /* | 3839 | /* |
| @@ -3826,9 +3846,6 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) | |||
| 3826 | 3846 | ||
| 3827 | dm_put(pool_md); | 3847 | dm_put(pool_md); |
| 3828 | 3848 | ||
| 3829 | atomic_set(&tc->refcount, 1); | ||
| 3830 | init_completion(&tc->can_destroy); | ||
| 3831 | |||
| 3832 | return 0; | 3849 | return 0; |
| 3833 | 3850 | ||
| 3834 | bad: | 3851 | bad: |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 4c06585bf165..b98cd9d84435 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -899,7 +899,7 @@ static void disable_write_same(struct mapped_device *md) | |||
| 899 | 899 | ||
| 900 | static void clone_endio(struct bio *bio, int error) | 900 | static void clone_endio(struct bio *bio, int error) |
| 901 | { | 901 | { |
| 902 | int r = 0; | 902 | int r = error; |
| 903 | struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); | 903 | struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); |
| 904 | struct dm_io *io = tio->io; | 904 | struct dm_io *io = tio->io; |
| 905 | struct mapped_device *md = tio->io->md; | 905 | struct mapped_device *md = tio->io->md; |
diff --git a/mm/memory.c b/mm/memory.c index 649e7d440bd7..ca920d1fd314 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -2378,12 +2378,12 @@ void unmap_mapping_range(struct address_space *mapping, | |||
| 2378 | details.last_index = ULONG_MAX; | 2378 | details.last_index = ULONG_MAX; |
| 2379 | 2379 | ||
| 2380 | 2380 | ||
| 2381 | i_mmap_lock_read(mapping); | 2381 | i_mmap_lock_write(mapping); |
| 2382 | if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap))) | 2382 | if (unlikely(!RB_EMPTY_ROOT(&mapping->i_mmap))) |
| 2383 | unmap_mapping_range_tree(&mapping->i_mmap, &details); | 2383 | unmap_mapping_range_tree(&mapping->i_mmap, &details); |
| 2384 | if (unlikely(!list_empty(&mapping->i_mmap_nonlinear))) | 2384 | if (unlikely(!list_empty(&mapping->i_mmap_nonlinear))) |
| 2385 | unmap_mapping_range_list(&mapping->i_mmap_nonlinear, &details); | 2385 | unmap_mapping_range_list(&mapping->i_mmap_nonlinear, &details); |
| 2386 | i_mmap_unlock_read(mapping); | 2386 | i_mmap_unlock_write(mapping); |
| 2387 | } | 2387 | } |
| 2388 | EXPORT_SYMBOL(unmap_mapping_range); | 2388 | EXPORT_SYMBOL(unmap_mapping_range); |
| 2389 | 2389 | ||
