提交 99ba2ae4 编写于 作者: J Joe Thornber 提交者: Mike Snitzer

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: NJoe Thornber <ejt@redhat.com>
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
上级 9c1d4de5
......@@ -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)
{
dm_cblock_t r;
struct mq_policy *mq = to_mq_policy(p);
/* FIXME: lock mutex, not sure we can block here */
return to_cblock(mq->nr_cblocks_allocated);
mutex_lock(&mq->lock);
r = to_cblock(mq->nr_cblocks_allocated);
mutex_unlock(&mq->lock);
return r;
}
static void mq_tick(struct dm_cache_policy *p)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册