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>
This commit is contained in:
Joe Thornber 2013-10-21 11:44:57 +01:00 коммит произвёл Mike Snitzer
Родитель 9c1d4de560
Коммит 99ba2ae4cd
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@ -1001,10 +1001,14 @@ static void mq_force_mapping(struct dm_cache_policy *p,
static dm_cblock_t mq_residency(struct dm_cache_policy *p) static dm_cblock_t mq_residency(struct dm_cache_policy *p)
{ {
dm_cblock_t r;
struct mq_policy *mq = to_mq_policy(p); struct mq_policy *mq = to_mq_policy(p);
/* FIXME: lock mutex, not sure we can block here */ mutex_lock(&mq->lock);
return to_cblock(mq->nr_cblocks_allocated); r = to_cblock(mq->nr_cblocks_allocated);
mutex_unlock(&mq->lock);
return r;
} }
static void mq_tick(struct dm_cache_policy *p) static void mq_tick(struct dm_cache_policy *p)