summaryrefslogtreecommitdiff
path: root/drivers/md/raid5.h
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2015-07-06 12:49:23 +1000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-09-29 19:26:13 +0200
commited8b312450dae5e5a9e5bc022e1261a2e6414984 (patch)
treeea904c5d68835a9e5716881d330eb0a4eedf1c12 /drivers/md/raid5.h
parentcd6a4dd89b4cdcc220c255ba5fe29b677d431cbd (diff)
downloadlwn-ed8b312450dae5e5a9e5bc022e1261a2e6414984.tar.gz
lwn-ed8b312450dae5e5a9e5bc022e1261a2e6414984.zip
md/raid5: avoid races when changing cache size.
commit 2d5b569b665ea6d0b15c52529ff06300de81a7ce upstream. 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: edbe83ab4c27 ("md/raid5: allow the stripe_cache to grow and shrink.") Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/md/raid5.h')
-rw-r--r--drivers/md/raid5.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index 896d603ad0da..03472fbbd882 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -482,7 +482,8 @@ struct r5conf {
*/
int active_name;
char cache_name[2][32];
- struct kmem_cache *slab_cache; /* for allocating stripes */
+ struct kmem_cache *slab_cache; /* for allocating stripes */
+ struct mutex cache_size_mutex; /* Protect changes to cache size */
int seq_flush, seq_write;
int quiesce;