I won't apply this version, please send v2 with the changes below.
This series has no cover letter, so the whole list is here; my reply
to 2/2 points to it.
1. Patch 1 message: say what the patch fixes in the kernel, not only
the moved_len user space reads back:
- a retry after -ENOSPC or -EBUSY restarted from orig_blk and
swapped the done part back;
- a short or zero moved_len on error left the page cache of the
swapped blocks in place.
Drop the "It was forgotten ... found this missing element"
paragraph.
2. Patch 1: add Fixes: 1a3d440e7fbc ("fs/ext4: swapext ioctl").
3. Both patches: the tracker URL
https://virtuozzo.atlassian.net/browse/VSTOR-148028 and
"Feature: ext4: swapext ioctl: swap range of blocks between two
files", as the earlier swapext commits have.
4. Patch 2 message: name the case where the estimate falls short and
what the user sees then (the handle aborts, an ext4 error, the fs
goes read-only), and say that the restart relies on patch 1. Drop
"The patch is suggested by Claude. It looks reasonable," and
"I guess"; "warranty" -> "guarantee".
5. Patch 2: one donor extent can now be swapped in two transactions.
Please confirm that csd recovers from a crash between them, and
say it in the message.
6. Patch 2 code comment: "continue from lblk1 + replaced_count" is not
where the caller resumes: lblk1 has already been advanced by
replaced_count at that point.
Separate patches, not needed for this series. I created a task for
each:
1. On ext4 without a journal swap_one_extent() and expose_one_extent()
dereference the fake handle (handle->h_requested_credits) and
oops.
https://virtuozzo.atlassian.net/browse/VSTOR-155599
2. jblocks grows with the number of orig extents; on a fragmented
range it goes above the jbd2 per-handle limit, which WARNs and
fails the ioctl with -ENOSPC. With patch 2 it can be capped.
https://virtuozzo.atlassian.net/browse/VSTOR-155600
3. ext4_ioc_swap_extents() does not call inode_dio_wait() on the two
inodes, unlike ext4_move_extents(), and does not mark the swap
fast-commit ineligible.
https://virtuozzo.atlassian.net/browse/VSTOR-155601
On Tue, 17 Nov 2026 21:24:01 +0800, Alexey Kuznetsov wrote:
> It was forgotten, but did not affect existing user space
> csd, because it aborted on any error of this kind.
> But now we work on better handling of errors, both
> recoverable and not-recoverable and found this missing element.
1. The code does more than this says. Before the patch a retry in
swap_one_extent() started again at orig_blk, so the extents already
swapped were swapped back: without UNWRITE_DONOR the ioctl reported
the full moved_len while that part held the old data, with it the
retry failed with -ENODATA. And truncate_pagecache_range() is sized
by moved_len, so a short one left stale cached pages over swapped
blocks. Mainline fixed the latter for move_extent in 55583e899a53
("ext4: fix double-free of blocks due to wrong extents moved_len").
Thanks.
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel