[RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion
From: Peng Huang
Date: Tue Dec 01 2026 - 01:27:53 EST
btrfs_uring_encoded_read() takes the inode lock shared through
btrfs_encoded_read() in the submitting task, but
btrfs_uring_read_finished() may release it from another task once the
reads complete. With CONFIG_RWSEM_SCHED_BOOST the submitter's
held-lock slot would then outlive the lock.
Call rwsem_boost_untrack() in btrfs_uring_read_extent() before
submitting the reads. If submission fails, the caller's own unlock
simply finds no slot.
Signed-off-by: Peng Huang <penghuang@xxxxxxxxxx>
---
fs/btrfs/ioctl.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 6ba883db107b..073450a6df95 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4725,6 +4725,13 @@ static int btrfs_uring_read_extent(struct kiocb *iocb, struct iov_iter *iter,
priv->lockend = lockend;
priv->err = 0;
+ /*
+ * Once the reads are queued, btrfs_uring_read_finished() may
+ * unlock i_rwsem from another task, so stop tracking it as held
+ * by this one. On error the caller's unlock finds no record.
+ */
+ rwsem_boost_untrack(&inode->vfs_inode.i_rwsem);
+
ret = btrfs_encoded_read_regular_fill_pages(inode, disk_bytenr,
disk_io_size, pages, priv);
if (ret && ret != -EIOCBQUEUED)
--
2.56.1.839.g22a8290db9-goog