Re: [RFC PATCH v2 2/6] btrfs: untrack i_rwsem before io_uring encoded read completion
From: Christoph Hellwig
Date: Tue Dec 01 2026 - 03:41:02 EST
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.