[PATCH v3 0/5] btrfs: fix io_uring encoded IO cleanup
Yang Xiuwei <[email protected]>
| Newsgroups | org.kernel.vger.linux-btrfs,org.kernel.vger.io-uring |
|---|---|
| Message-ID | <[email protected]> |
Hi, Fixes for the io_uring ENCODED_READ / ENCODED_WRITE cleanup paths. 1. Always return -EIOCBQUEUED after endio so the caller and btrfs_uring_read_finished() do not both clean up. Link: https://lore.kernel.org/linux-btrfs/[email protected]/ 2. btrfs_uring_read_extent() failure skipped kfree(data->iov). 3. Unlock inode/extent in the caller on read-extent failure. 4. Do not stash encoded data in the cmd PDU across -EAGAIN. 5. Drop the unused REISSUE restore. v2 also exported __import_iovec() and passed IO_URING_F_COMPAT. That is not a bug with the current io_uring thread setup: create_io_thread() copies TS_COMPAT, so import_iovec() already sees compat iovecs. Passing the flag explicitly would still be a cleanup, but this series does not take it. Testing: - xfstests btrfs/333 passed. - kmemleak after dropping the ring on NONBLOCK encoded write/read: unreferenced object (size 512): comm "btrfs_uring_eag" __kmalloc_cache_noprof+0x38f/0x4a0 btrfs_uring_encoded_write+0x78d/0x1790 [btrfs] btrfs_uring_cmd+0x142/0x1d0 [btrfs] io_uring_cmd+0x296/0x5e0 unreferenced object (size 512): comm "btrfs_uring_eag" __kmalloc_cache_noprof+0x38f/0x4a0 btrfs_uring_encoded_read+0x89a/0x12b0 [btrfs] btrfs_uring_cmd+0x173/0x1d0 [btrfs] io_uring_cmd+0x296/0x5e0 After 4/5 the same repro is clean. Changes in v3: - Drop the __import_iovec / IO_URING_F_COMPAT patches. - 3/5: drop a leftover goto out_fail from v2. 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 v2: https://lore.kernel.org/linux-btrfs/[email protected]/ v1: https://lore.kernel.org/linux-btrfs/[email protected]/ Yang Xiuwei (5): btrfs: always return -EIOCBQUEUED after btrfs_uring_read_extent_endio btrfs: free iov when btrfs_uring_read_extent fails 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 | 39 ++++++++++++++------------------------- 2 files changed, 17 insertions(+), 29 deletions(-) -- 2.25.1