bcache: check CACHE_SET_IO_DISABLE in allocator code
[ Upstream commit e775339e1a ]
If CACHE_SET_IO_DISABLE of a cache set flag is set by too many I/O
errors, currently allocator routines can still continue allocate
space which may introduce inconsistent metadata state.
This patch checkes CACHE_SET_IO_DISABLE bit in following allocator
routines,
- bch_bucket_alloc()
- __bch_bucket_alloc_set()
Once CACHE_SET_IO_DISABLE is set on cache set, the allocator routines
may reject allocation request earlier to avoid potential inconsistent
metadata.
Signed-off-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
e78d1d2344
commit
57cfb755c3
1 changed files with 9 additions and 0 deletions
|
|
@ -393,6 +393,11 @@ long bch_bucket_alloc(struct cache *ca, unsigned int reserve, bool wait)
|
|||
struct bucket *b;
|
||||
long r;
|
||||
|
||||
|
||||
/* No allocation if CACHE_SET_IO_DISABLE bit is set */
|
||||
if (unlikely(test_bit(CACHE_SET_IO_DISABLE, &ca->set->flags)))
|
||||
return -1;
|
||||
|
||||
/* fastpath */
|
||||
if (fifo_pop(&ca->free[RESERVE_NONE], r) ||
|
||||
fifo_pop(&ca->free[reserve], r))
|
||||
|
|
@ -484,6 +489,10 @@ int __bch_bucket_alloc_set(struct cache_set *c, unsigned int reserve,
|
|||
{
|
||||
int i;
|
||||
|
||||
/* No allocation if CACHE_SET_IO_DISABLE bit is set */
|
||||
if (unlikely(test_bit(CACHE_SET_IO_DISABLE, &c->flags)))
|
||||
return -1;
|
||||
|
||||
lockdep_assert_held(&c->bucket_lock);
|
||||
BUG_ON(!n || n > c->caches_loaded || n > 8);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue