From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Alexey Kuznetsov <kuznet@virtuozzo.com>
Cc: azaitsev@virtuozzo.com, devel@openvz.org, kui.liu@virtuozzo.com
Subject: Re: [Devel] [PATCH hci-8.1 1/2] fs/ext4: rectify behaviour of swapext ioctl on error
Date: Tue, 17 Nov 2026 15:00:00 +0100 [thread overview]
Message-ID: <179492400071.138826.5468175470996454760.b4-review@b4> (raw)
In-Reply-To: <avxVcSRzTpDkZmFN@mops2>
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
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
prev parent reply other threads:[~2026-11-17 14:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 13:24 Alexey Kuznetsov
2026-11-17 13:25 ` [Devel] [PATCH hci-8.1 2/2] fs/ext4: ensure ext4 transaction credits while swapext Alexey Kuznetsov
2026-11-17 14:00 ` Konstantin Khorenko
2026-11-17 14:00 ` Konstantin Khorenko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179492400071.138826.5468175470996454760.b4-review@b4 \
--to=khorenko@virtuozzo.com \
--cc=azaitsev@virtuozzo.com \
--cc=devel@openvz.org \
--cc=kui.liu@virtuozzo.com \
--cc=kuznet@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox