diff options
author | NeilBrown <neilb@suse.com> | 2015-08-03 17:09:57 +1000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-09-29 19:26:13 +0200 |
commit | d7edf5fe979269233c9d20e5101ae004df05070e (patch) | |
tree | 2d5a407920335bc2719be4fb19bbd4b9c0a66c6e /drivers | |
parent | ed8b312450dae5e5a9e5bc022e1261a2e6414984 (diff) | |
download | lwn-d7edf5fe979269233c9d20e5101ae004df05070e.tar.gz lwn-d7edf5fe979269233c9d20e5101ae004df05070e.zip |
md/raid5: don't let shrink_slab shrink too far.
commit 49895bcc7e566ba455eb2996607d6fbd3447ce16 upstream.
I have a report of drop_one_stripe() called from
raid5_cache_scan() apparently finding ->max_nr_stripes == 0.
This should not be allowed.
So add a test to keep max_nr_stripes above min_nr_stripes.
Also use a 'mask' rather than a 'mod' in drop_one_stripe
to ensure 'hash' is valid even if max_nr_stripes does reach zero.
Fixes: edbe83ab4c27 ("md/raid5: allow the stripe_cache to grow and shrink.")
Reported-by: Tomas Papan <tomas.papan@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/raid5.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index b369cbea4e54..23af6772f146 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2245,7 +2245,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) static int drop_one_stripe(struct r5conf *conf) { struct stripe_head *sh; - int hash = (conf->max_nr_stripes - 1) % NR_STRIPE_HASH_LOCKS; + int hash = (conf->max_nr_stripes - 1) & STRIPE_HASH_LOCKS_MASK; spin_lock_irq(conf->hash_locks + hash); sh = get_free_stripe(conf, hash); @@ -6375,7 +6375,8 @@ static unsigned long raid5_cache_scan(struct shrinker *shrink, if (mutex_trylock(&conf->cache_size_mutex)) { ret= 0; - while (ret < sc->nr_to_scan) { + while (ret < sc->nr_to_scan && + conf->max_nr_stripes > conf->min_nr_stripes) { if (drop_one_stripe(conf) == 0) { ret = SHRINK_STOP; break; |