From: Peng Huang <penghuang@google.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Boqun Feng <boqun@kernel.org>, Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>
Cc: Waiman Long <longman@redhat.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
John Stultz <jstultz@google.com>,
Suren Baghdasaryan <surenb@google.com>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Peng Huang <penghuang@google.com>,
David Sterba <dsterba@suse.com>, Chris Mason <mason@kernel.org>,
linux-btrfs@vger.kernel.org
Subject: [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion
Date: Mon, 30 Nov 2026 22:27:29 -0800 [thread overview]
Message-ID: <20261201062738.1047159-3-penghuang@google.com> (raw)
In-Reply-To: <20261201062738.1047159-1-penghuang@google.com>
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@google.com>
---
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
next parent reply other threads:[~2026-12-01 6:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261201062738.1047159-1-penghuang@google.com>
2026-12-01 6:27 ` Peng Huang [this message]
2026-12-01 8:40 ` [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261201062738.1047159-3-penghuang@google.com \
--to=penghuang@google.com \
--cc=boqun@kernel.org \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=dsterba@suse.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=longman@redhat.com \
--cc=mason@kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=surenb@google.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox