mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 06:43:09 +00:00
blk-throttle: Take blkcg->lock while traversing blkcg->policy_list
blkcg->policy_list is protected by blkcg->lock. Its not rcu protected list. So even for readers, they need to take blkcg->lock. There are few functions which were reading the list without taking lock. Fix it. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
e060f00bee
commit
a38eb630fa
@ -869,60 +869,86 @@ unsigned int blkcg_get_weight(struct blkio_cgroup *blkcg,
|
|||||||
dev_t dev)
|
dev_t dev)
|
||||||
{
|
{
|
||||||
struct blkio_policy_node *pn;
|
struct blkio_policy_node *pn;
|
||||||
|
unsigned long flags;
|
||||||
|
unsigned int weight;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&blkcg->lock, flags);
|
||||||
|
|
||||||
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_PROP,
|
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_PROP,
|
||||||
BLKIO_PROP_weight_device);
|
BLKIO_PROP_weight_device);
|
||||||
if (pn)
|
if (pn)
|
||||||
return pn->val.weight;
|
weight = pn->val.weight;
|
||||||
else
|
else
|
||||||
return blkcg->weight;
|
weight = blkcg->weight;
|
||||||
|
|
||||||
|
spin_unlock_irqrestore(&blkcg->lock, flags);
|
||||||
|
|
||||||
|
return weight;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(blkcg_get_weight);
|
EXPORT_SYMBOL_GPL(blkcg_get_weight);
|
||||||
|
|
||||||
uint64_t blkcg_get_read_bps(struct blkio_cgroup *blkcg, dev_t dev)
|
uint64_t blkcg_get_read_bps(struct blkio_cgroup *blkcg, dev_t dev)
|
||||||
{
|
{
|
||||||
struct blkio_policy_node *pn;
|
struct blkio_policy_node *pn;
|
||||||
|
unsigned long flags;
|
||||||
|
uint64_t bps = -1;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&blkcg->lock, flags);
|
||||||
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
||||||
BLKIO_THROTL_read_bps_device);
|
BLKIO_THROTL_read_bps_device);
|
||||||
if (pn)
|
if (pn)
|
||||||
return pn->val.bps;
|
bps = pn->val.bps;
|
||||||
else
|
spin_unlock_irqrestore(&blkcg->lock, flags);
|
||||||
return -1;
|
|
||||||
|
return bps;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t blkcg_get_write_bps(struct blkio_cgroup *blkcg, dev_t dev)
|
uint64_t blkcg_get_write_bps(struct blkio_cgroup *blkcg, dev_t dev)
|
||||||
{
|
{
|
||||||
struct blkio_policy_node *pn;
|
struct blkio_policy_node *pn;
|
||||||
|
unsigned long flags;
|
||||||
|
uint64_t bps = -1;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&blkcg->lock, flags);
|
||||||
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
||||||
BLKIO_THROTL_write_bps_device);
|
BLKIO_THROTL_write_bps_device);
|
||||||
if (pn)
|
if (pn)
|
||||||
return pn->val.bps;
|
bps = pn->val.bps;
|
||||||
else
|
spin_unlock_irqrestore(&blkcg->lock, flags);
|
||||||
return -1;
|
|
||||||
|
return bps;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg, dev_t dev)
|
unsigned int blkcg_get_read_iops(struct blkio_cgroup *blkcg, dev_t dev)
|
||||||
{
|
{
|
||||||
struct blkio_policy_node *pn;
|
struct blkio_policy_node *pn;
|
||||||
|
unsigned long flags;
|
||||||
|
unsigned int iops = -1;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&blkcg->lock, flags);
|
||||||
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
||||||
BLKIO_THROTL_read_iops_device);
|
BLKIO_THROTL_read_iops_device);
|
||||||
if (pn)
|
if (pn)
|
||||||
return pn->val.iops;
|
iops = pn->val.iops;
|
||||||
else
|
spin_unlock_irqrestore(&blkcg->lock, flags);
|
||||||
return -1;
|
|
||||||
|
return iops;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg, dev_t dev)
|
unsigned int blkcg_get_write_iops(struct blkio_cgroup *blkcg, dev_t dev)
|
||||||
{
|
{
|
||||||
struct blkio_policy_node *pn;
|
struct blkio_policy_node *pn;
|
||||||
|
unsigned long flags;
|
||||||
|
unsigned int iops = -1;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&blkcg->lock, flags);
|
||||||
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
pn = blkio_policy_search_node(blkcg, dev, BLKIO_POLICY_THROTL,
|
||||||
BLKIO_THROTL_write_iops_device);
|
BLKIO_THROTL_write_iops_device);
|
||||||
if (pn)
|
if (pn)
|
||||||
return pn->val.iops;
|
iops = pn->val.iops;
|
||||||
else
|
spin_unlock_irqrestore(&blkcg->lock, flags);
|
||||||
return -1;
|
|
||||||
|
return iops;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Checks whether user asked for deleting a policy rule */
|
/* Checks whether user asked for deleting a policy rule */
|
||||||
|
Loading…
Reference in New Issue
Block a user