* [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion [not found] <20261201062738.1047159-1-penghuang@google.com> @ 2026-12-01 6:27 ` Peng Huang 2026-12-01 8:40 ` Christoph Hellwig 0 siblings, 1 reply; 3+ messages in thread From: Peng Huang @ 2026-12-01 6:27 UTC (permalink / raw) To: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Juri Lelli, Vincent Guittot Cc: Waiman Long, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak, John Stultz, Suren Baghdasaryan, linux-kernel, linux-mm, Peng Huang, David Sterba, Chris Mason, linux-btrfs 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 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion 2026-12-01 6:27 ` [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion Peng Huang @ 2026-12-01 8:40 ` Christoph Hellwig 2026-12-01 14:43 ` Steven Rostedt 0 siblings, 1 reply; 3+ messages in thread From: Christoph Hellwig @ 2026-12-01 8:40 UTC (permalink / raw) To: Peng Huang Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Juri Lelli, Vincent Guittot, Waiman Long, Dietmar Eggemann, Steven Rostedt, Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak, John Stultz, Suren Baghdasaryan, linux-kernel, linux-mm, David Sterba, Chris Mason, linux-btrfs I only see patch 2 on the btrfs list, so something got really messed up in your patch sending. On Mon, Nov 30, 2026 at 10:27:29PM -0800, Peng Huang wrote: > 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); I don't think this is a good interface (and it looks like you're adding it given no existing in-tree matches). Currently there's a gazillion different things that need to be done for handing off locks and releasing them in other threads including lockdep fake release/acquire annotations, hacks to make it shut off when returning to userspace, etc. Which is sad, as in I/O and file system land the idea of taking a lock and handing it to a different completion path makes perfect sense. But we need a better interface for that, something like a disown just before returning to userspace or the caller, and a "take ownership" called as early as possible from the completion callback. Let's build such a proper highlevel interface and make it all the right things instead of encoding implementation details all over the tree. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion 2026-12-01 8:40 ` Christoph Hellwig @ 2026-12-01 14:43 ` Steven Rostedt 0 siblings, 0 replies; 3+ messages in thread From: Steven Rostedt @ 2026-12-01 14:43 UTC (permalink / raw) To: Christoph Hellwig Cc: Peng Huang, Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Juri Lelli, Vincent Guittot, Waiman Long, Dietmar Eggemann, Ben Segall, Mel Gorman, Valentin Schneider, K Prateek Nayak, John Stultz, Suren Baghdasaryan, linux-kernel, linux-mm, David Sterba, Chris Mason, linux-btrfs On Tue, 1 Dec 2026 00:40:51 -0800 Christoph Hellwig <hch@infradead.org> wrote: > I only see patch 2 on the btrfs list, so something got really messed up > in your patch sending. b4 and lore is your friend ;-) /me ignores anything where I'm blasted with a patch series where I only care about the one patch that affect me. I don't have time to read the rest. If I want to know more, I use b4 and/or lore. It's really simple to use. -- Steve ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-01 14:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261201062738.1047159-1-penghuang@google.com>
2026-12-01 6:27 ` [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion Peng Huang
2026-12-01 8:40 ` Christoph Hellwig
2026-12-01 14:43 ` Steven Rostedt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox