mbox series

[0/2] fix locking issues with blk-wbt parameters update

Message ID 20250319105518.468941-1-nilay@linux.ibm.com (mailing list archive)
Headers show
Series fix locking issues with blk-wbt parameters update | expand

Message

Nilay Shroff March 19, 2025, 10:53 a.m. UTC
Hi,

This patchset contains two patches.

The first patch fixes a missed release of q->elevator_lock which was
mistakenly omitted in one of the return code path of ioc_qos_write.

The second patch fixes the locdep splat reported due to the incorrect
locking order between q->elevator_lock and q->rq_qos_mutex. The commit 
245618f8e45f ("block: protect wbt_lat_usec using q->elevator_lock") 
introduced q->elevator_lock to protect updates to blk-wbt parameters 
when writing to the sysfs attribute wbt_lat_usec and the cgroup attribute 
io.cost.qos. However, writes to these attributes also acquire q->rq_qos_
mutex, creating a potential circular dependency if the locking order is 
not correctly followed. This patch ensures the correct locking sequence 
to prevent such issues. Unfortunately, blktests currently lacks a test 
case for writes to these attributes, which might have caught this issue 
earlier. I plan to submit a blktest to cover these cases.

Nilay Shroff (2):
  block: release q->elevator_lock in ioc_qos_write
  block: correct locking order for protecting blk-wbt parameters

 block/blk-cgroup.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++
 block/blk-cgroup.h |  2 ++
 block/blk-iocost.c | 17 +++++-----------
 3 files changed, 58 insertions(+), 12 deletions(-)

Comments

Jens Axboe March 19, 2025, 5:35 p.m. UTC | #1
On Wed, 19 Mar 2025 16:23:44 +0530, Nilay Shroff wrote:
> This patchset contains two patches.
> 
> The first patch fixes a missed release of q->elevator_lock which was
> mistakenly omitted in one of the return code path of ioc_qos_write.
> 
> The second patch fixes the locdep splat reported due to the incorrect
> locking order between q->elevator_lock and q->rq_qos_mutex. The commit
> 245618f8e45f ("block: protect wbt_lat_usec using q->elevator_lock")
> introduced q->elevator_lock to protect updates to blk-wbt parameters
> when writing to the sysfs attribute wbt_lat_usec and the cgroup attribute
> io.cost.qos. However, writes to these attributes also acquire q->rq_qos_
> mutex, creating a potential circular dependency if the locking order is
> not correctly followed. This patch ensures the correct locking sequence
> to prevent such issues. Unfortunately, blktests currently lacks a test
> case for writes to these attributes, which might have caught this issue
> earlier. I plan to submit a blktest to cover these cases.
> 
> [...]

Applied, thanks!

[1/2] block: release q->elevator_lock in ioc_qos_write
      commit: 89ed5fa3b5419f04452051fbcb6d3e5b801cdb1b
[2/2] block: correct locking order for protecting blk-wbt parameters
      commit: 9730763f4756e32520cb86778331465e8d063a8f

Best regards,