Commit aa39477b authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'dm-3.19-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm

Pull device mapper fixes from Mike Snitzer:
 "Thre stable fixes and one fix for a regression introduced during 3.19
  merge:

   - Fix inability to discard used space when the thin-pool target is in
     out-of-data-space mode and also transition the thin-pool back to
     write mode once free space is made available.

   - Fix DM core bio-based end_io bug that prevented proper
     post-processing of the error code returned from the block layer.

   - Fix crash in DM thin-pool due to thin device being added to the
     pool's active_thins list before properly initializing the thin
     device's refcount"

* tag 'dm-3.19-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm:
  dm: fix missed error code if .end_io isn't implemented by target_type
  dm thin: fix crash by initializing thin device's refcount and completion earlier
  dm thin: fix missing out-of-data-space to write mode transition if blocks are released
  dm thin: fix inability to discard blocks when in out-of-data-space mode
parents 48ec833b 5164bece
...@@ -1127,6 +1127,24 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block, ...@@ -1127,6 +1127,24 @@ static void schedule_external_copy(struct thin_c *tc, dm_block_t virt_block,
schedule_zero(tc, virt_block, data_dest, cell, bio); schedule_zero(tc, virt_block, data_dest, cell, bio);
} }
static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
static void check_for_space(struct pool *pool)
{
int r;
dm_block_t nr_free;
if (get_pool_mode(pool) != PM_OUT_OF_DATA_SPACE)
return;
r = dm_pool_get_free_block_count(pool->pmd, &nr_free);
if (r)
return;
if (nr_free)
set_pool_mode(pool, PM_WRITE);
}
/* /*
* A non-zero return indicates read_only or fail_io mode. * A non-zero return indicates read_only or fail_io mode.
* Many callers don't care about the return value. * Many callers don't care about the return value.
...@@ -1141,6 +1159,8 @@ static int commit(struct pool *pool) ...@@ -1141,6 +1159,8 @@ static int commit(struct pool *pool)
r = dm_pool_commit_metadata(pool->pmd); r = dm_pool_commit_metadata(pool->pmd);
if (r) if (r)
metadata_operation_failed(pool, "dm_pool_commit_metadata", r); metadata_operation_failed(pool, "dm_pool_commit_metadata", r);
else
check_for_space(pool);
return r; return r;
} }
...@@ -1159,8 +1179,6 @@ static void check_low_water_mark(struct pool *pool, dm_block_t free_blocks) ...@@ -1159,8 +1179,6 @@ static void check_low_water_mark(struct pool *pool, dm_block_t free_blocks)
} }
} }
static void set_pool_mode(struct pool *pool, enum pool_mode new_mode);
static int alloc_data_block(struct thin_c *tc, dm_block_t *result) static int alloc_data_block(struct thin_c *tc, dm_block_t *result)
{ {
int r; int r;
...@@ -2155,7 +2173,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode) ...@@ -2155,7 +2173,7 @@ static void set_pool_mode(struct pool *pool, enum pool_mode new_mode)
pool->process_cell = process_cell_read_only; pool->process_cell = process_cell_read_only;
pool->process_discard_cell = process_discard_cell; pool->process_discard_cell = process_discard_cell;
pool->process_prepared_mapping = process_prepared_mapping; pool->process_prepared_mapping = process_prepared_mapping;
pool->process_prepared_discard = process_prepared_discard_passdown; pool->process_prepared_discard = process_prepared_discard;
if (!pool->pf.error_if_no_space && no_space_timeout) if (!pool->pf.error_if_no_space && no_space_timeout)
queue_delayed_work(pool->wq, &pool->no_space_timeout, no_space_timeout); 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,6 +3832,8 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
r = -EINVAL; r = -EINVAL;
goto bad; goto bad;
} }
atomic_set(&tc->refcount, 1);
init_completion(&tc->can_destroy);
list_add_tail_rcu(&tc->list, &tc->pool->active_thins); list_add_tail_rcu(&tc->list, &tc->pool->active_thins);
spin_unlock_irqrestore(&tc->pool->lock, flags); spin_unlock_irqrestore(&tc->pool->lock, flags);
/* /*
...@@ -3826,9 +3846,6 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv) ...@@ -3826,9 +3846,6 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)
dm_put(pool_md); dm_put(pool_md);
atomic_set(&tc->refcount, 1);
init_completion(&tc->can_destroy);
return 0; return 0;
bad: bad:
......
...@@ -899,7 +899,7 @@ static void disable_write_same(struct mapped_device *md) ...@@ -899,7 +899,7 @@ static void disable_write_same(struct mapped_device *md)
static void clone_endio(struct bio *bio, int error) static void clone_endio(struct bio *bio, int error)
{ {
int r = 0; int r = error;
struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone); struct dm_target_io *tio = container_of(bio, struct dm_target_io, clone);
struct dm_io *io = tio->io; struct dm_io *io = tio->io;
struct mapped_device *md = tio->io->md; struct mapped_device *md = tio->io->md;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment