]> git.baikalelectronics.ru Git - kernel.git/commit
md/raid5: avoid races when changing cache size.
authorNeilBrown <neilb@suse.com>
Mon, 6 Jul 2015 02:49:23 +0000 (12:49 +1000)
committerNeilBrown <neilb@suse.com>
Wed, 22 Jul 2015 04:04:15 +0000 (14:04 +1000)
commit651b8dbc17fc633480f625980663d9bb8d8d2492
treebb24462863afe67677dcb5102495d9dc2c094f5a
parent7f19d0cfcb43f013033ceb2ba31f7a07b1ab1a9f
md/raid5: avoid races when changing cache size.

Cache size can grow or shrink due to various pressures at
any time.  So when we resize the cache as part of a 'grow'
operation (i.e. change the size to allow more devices) we need
to blocks that automatic growing/shrinking.

So introduce a mutex.  auto grow/shrink uses mutex_trylock()
and just doesn't bother if there is a blockage.
Resizing the whole cache holds the mutex to ensure that
the correct number of new stripes is allocated.

This bug can result in some stripes not being freed when an
array is stopped.  This leads to the kmem_cache not being
freed and a subsequent array can try to use the same kmem_cache
and get confused.

Fixes: db7042eb4271 ("md/raid5: allow the stripe_cache to grow and shrink.")
Cc: stable@vger.kernel.org (4.1 - please delay until 2 weeks after release of 4.2)
Signed-off-by: NeilBrown <neilb@suse.com>
drivers/md/raid5.c
drivers/md/raid5.h