aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Thornber <ejt@redhat.com>2013-10-21 06:44:57 -0400
committerMike Snitzer <snitzer@redhat.com>2013-11-09 17:54:34 -0500
commit99ba2ae4cd876bbcedb01d94c1a7952ce171418e (patch)
treee150c06aff63538e6c64ff29a88f6afdb9d9fe20
parent9c1d4de56066e4d6abc66ec188faafd7b303fb08 (diff)
dm cache policy mq: protect residency method with existing mutex
It is safe to use a mutex in mq_residency() at this point since it is only called from ioctl context. But future-proof mq_residency() by using might_sleep() to catch new contexts that cannot sleep. Signed-off-by: Joe Thornber <ejt@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-cache-policy-mq.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/md/dm-cache-policy-mq.c b/drivers/md/dm-cache-policy-mq.c
index 4296155090b2..db490f74c7f8 100644
--- a/drivers/md/dm-cache-policy-mq.c
+++ b/drivers/md/dm-cache-policy-mq.c
@@ -1001,10 +1001,14 @@ static void mq_force_mapping(struct dm_cache_policy *p,
1001 1001
1002static dm_cblock_t mq_residency(struct dm_cache_policy *p) 1002static dm_cblock_t mq_residency(struct dm_cache_policy *p)
1003{ 1003{
1004 dm_cblock_t r;
1004 struct mq_policy *mq = to_mq_policy(p); 1005 struct mq_policy *mq = to_mq_policy(p);
1005 1006
1006 /* FIXME: lock mutex, not sure we can block here */ 1007 mutex_lock(&mq->lock);
1007 return to_cblock(mq->nr_cblocks_allocated); 1008 r = to_cblock(mq->nr_cblocks_allocated);
1009 mutex_unlock(&mq->lock);
1010
1011 return r;
1008} 1012}
1009 1013
1010static void mq_tick(struct dm_cache_policy *p) 1014static void mq_tick(struct dm_cache_policy *p)