Commit 6d16202b authored by Mike Snitzer's avatar Mike Snitzer

dm thin: eliminate the no_free_space flag

The pool's error_if_no_space flag can easily serve the same purpose that
no_free_space did, namely: control whether handle_unserviceable_bio()
will error a bio or requeue it.

This is cleaner since error_if_no_space is established when the pool's
features are processed during table load.  So it avoids managing the
no_free_space flag by taking the pool's spinlock.
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
parent 787a996c
...@@ -165,7 +165,6 @@ struct pool { ...@@ -165,7 +165,6 @@ struct pool {
struct pool_features pf; struct pool_features pf;
bool low_water_triggered:1; /* A dm event has been sent */ bool low_water_triggered:1; /* A dm event has been sent */
bool no_free_space:1; /* bios will be requeued if set */
struct dm_bio_prison *prison; struct dm_bio_prison *prison;
struct dm_kcopyd_client *copier; struct dm_kcopyd_client *copier;
...@@ -991,10 +990,10 @@ static void handle_unserviceable_bio(struct pool *pool, struct bio *bio) ...@@ -991,10 +990,10 @@ static void handle_unserviceable_bio(struct pool *pool, struct bio *bio)
*/ */
WARN_ON_ONCE(get_pool_mode(pool) != PM_READ_ONLY); WARN_ON_ONCE(get_pool_mode(pool) != PM_READ_ONLY);
if (pool->no_free_space) if (pool->pf.error_if_no_space)
retry_on_resume(bio);
else
bio_io_error(bio); bio_io_error(bio);
else
retry_on_resume(bio);
} }
static void retry_bios_on_resume(struct pool *pool, struct dm_bio_prison_cell *cell) static void retry_bios_on_resume(struct pool *pool, struct dm_bio_prison_cell *cell)
...@@ -1437,18 +1436,6 @@ static void set_pool_mode(struct pool *pool, enum pool_mode mode) ...@@ -1437,18 +1436,6 @@ static void set_pool_mode(struct pool *pool, enum pool_mode mode)
} }
} }
static void set_no_free_space(struct pool *pool)
{
unsigned long flags;
if (pool->pf.error_if_no_space)
return;
spin_lock_irqsave(&pool->lock, flags);
pool->no_free_space = true;
spin_unlock_irqrestore(&pool->lock, flags);
}
/* /*
* Rather than calling set_pool_mode directly, use these which describe the * Rather than calling set_pool_mode directly, use these which describe the
* reason for mode degradation. * reason for mode degradation.
...@@ -1457,7 +1444,6 @@ static void out_of_data_space(struct pool *pool) ...@@ -1457,7 +1444,6 @@ static void out_of_data_space(struct pool *pool)
{ {
DMERR_LIMIT("%s: no free data space available.", DMERR_LIMIT("%s: no free data space available.",
dm_device_name(pool->pool_md)); dm_device_name(pool->pool_md));
set_no_free_space(pool);
set_pool_mode(pool, PM_READ_ONLY); set_pool_mode(pool, PM_READ_ONLY);
} }
...@@ -1470,11 +1456,9 @@ static void metadata_operation_failed(struct pool *pool, const char *op, int r) ...@@ -1470,11 +1456,9 @@ static void metadata_operation_failed(struct pool *pool, const char *op, int r)
if (r == -ENOSPC && if (r == -ENOSPC &&
!dm_pool_get_free_metadata_block_count(pool->pmd, &free_blocks) && !dm_pool_get_free_metadata_block_count(pool->pmd, &free_blocks) &&
!free_blocks) { !free_blocks)
DMERR_LIMIT("%s: no free metadata space available.", DMERR_LIMIT("%s: no free metadata space available.",
dm_device_name(pool->pool_md)); dm_device_name(pool->pool_md));
set_no_free_space(pool);
}
set_pool_mode(pool, PM_READ_ONLY); set_pool_mode(pool, PM_READ_ONLY);
} }
...@@ -1819,7 +1803,6 @@ static struct pool *pool_create(struct mapped_device *pool_md, ...@@ -1819,7 +1803,6 @@ static struct pool *pool_create(struct mapped_device *pool_md,
INIT_LIST_HEAD(&pool->prepared_mappings); INIT_LIST_HEAD(&pool->prepared_mappings);
INIT_LIST_HEAD(&pool->prepared_discards); INIT_LIST_HEAD(&pool->prepared_discards);
pool->low_water_triggered = false; pool->low_water_triggered = false;
pool->no_free_space = false;
bio_list_init(&pool->retry_on_resume_list); bio_list_init(&pool->retry_on_resume_list);
pool->shared_read_ds = dm_deferred_set_create(); pool->shared_read_ds = dm_deferred_set_create();
...@@ -2346,7 +2329,6 @@ static void pool_resume(struct dm_target *ti) ...@@ -2346,7 +2329,6 @@ static void pool_resume(struct dm_target *ti)
spin_lock_irqsave(&pool->lock, flags); spin_lock_irqsave(&pool->lock, flags);
pool->low_water_triggered = false; pool->low_water_triggered = false;
pool->no_free_space = false;
__requeue_bios(pool); __requeue_bios(pool);
spin_unlock_irqrestore(&pool->lock, flags); spin_unlock_irqrestore(&pool->lock, flags);
......
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