[PATCH v2 0/7] btrfs: fix io_uring encoded IO cleanup and compat

Yang Xiuwei <[email protected]> Thu, 6 Aug 2026 16:50:34 +0800
Newsgroups gmane.linux.file-systems,gmane.comp.file-systems.btrfs,gmane.linux.kernel.io-uring,gmane.linux.block
Message-ID <[email protected]>
Fixes for the io_uring ENCODED_READ / ENCODED_WRITE paths:

1. Fast bio completion could call endio and still return a negative
   errno, so the caller and btrfs_uring_read_finished() both cleaned
   up.  Always return -EIOCBQUEUED after endio.

   Link: https://lore.kernel.org/linux-btrfs/[email protected]/

2. btrfs_uring_read_extent() failure skipped kfree(data->iov).

3. SQPOLL / io-wq leave in_compat_syscall() false; export
   __import_iovec() and pass IO_URING_F_COMPAT for the iovec import.

4. Unlock inode/extent in the caller on read-extent failure, including
   the pages alloc -ENOMEM path.

5. Do not leave btrfs_uring_encoded_data in the cmd PDU across
   -EAGAIN (leak on cancel); drop the unused REISSUE restore.

v1: https://lore.kernel.org/linux-btrfs/[email protected]/

Changes in v2:
- unlock in the caller (Qu Wenruo)
- address further error-path issues raised on the v1 review
- export __import_iovec(); use IO_URING_F_COMPAT
- no PDU stash across -EAGAIN; drop REISSUE helpers

Testing: xfstests btrfs/333 passed.

Yang Xiuwei (7):
  btrfs: always return -EIOCBQUEUED after btrfs_uring_read_extent_endio
  btrfs: free iov when btrfs_uring_read_extent fails
  iov_iter: export __import_iovec
  btrfs: use IO_URING_F_COMPAT for uring encoded iovec import
  btrfs: unlock inode and extent in caller when uring read extent fails
  btrfs: don't stash uring encoded data across -EAGAIN
  btrfs: drop unused uring encoded IO REISSUE stash helpers

 fs/btrfs/inode.c |  7 +++---
 fs/btrfs/ioctl.c | 67 ++++++++++++++++++++++++++------------------------------
 lib/iov_iter.c   |  1 +
 3 files changed, 35 insertions(+), 40 deletions(-)

-- 
2.25.1