From: sashiko-bot@kernel.org
To: "Theodore Ts'o" <tytso@mit.edu>,
"Ext4 Developers List" <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 25/27] ext4: add KUnit tests for fs/ext4/move_extent.c
Date: Thu, 12 Nov 2026 04:36:36 +0000 [thread overview]
Message-ID: <sashiko-outbox-210368@kernel.org> (raw)
In-Reply-To: <20261112040638.1576836-26-tytso@mit.edu>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ext4: 64KB page failure in test_mext_check_adjust_range()
- [Medium] ext4: sub-folio dirty buffer -EBUSY in move_extent-test.c on
>4KB pages
--
commit abdff1b8eb818ad1bc77ee7f502a090b450df395
Author: Theodore Ts'o <tytso@mit.edu>
ext4: add KUnit tests for fs/ext4/move_extent.c
This commit adds a KUnit test suite covering lock ordering, validity and
range checks, and extent swapping in fs/ext4/move_extent.c.
> diff --git a/fs/ext4/move_extent-test.c b/fs/ext4/move_extent-test.c
> new file mode 100644
> index 0000000000000..e29a392eeebe3
> --- /dev/null
> +++ b/fs/ext4/move_extent-test.c
[ ... ]
> +static void test_mext_check_adjust_range(struct kunit *test)
> +{
> + struct mext_test_ctx *ctx = mext_setup_ctx(test);
> + struct inode *orig = ctx->orig_inode;
> + struct inode *donor = ctx->donor_inode;
> + __u64 len;
> + int ret;
> +
> + /* Sub-page block alignment check when blocksize (1024) < PAGE_SIZE */
> + orig->i_blkbits = 10;
> + donor->i_blkbits = 10;
> + i_size_write(orig, 32 * 1024);
> + i_size_write(donor, 32 * 1024);
> +
> + len = 4;
> + ret = ext4_mext_check_adjust_range_test(orig, donor, 1, 2, &len);
> + KUNIT_EXPECT_EQ(test, ret, -EINVAL);
> +
> + len = 4;
> + ret = ext4_mext_check_adjust_range_test(orig, donor, 1,
> + 1 + (PAGE_SIZE >> 10), &len);
> + KUNIT_EXPECT_EQ(test, ret, 0);
> + KUNIT_EXPECT_EQ(test, len, 4ULL);
[Severity: Medium]
Does this sub-page alignment check fail on kernels with 64KB pages?
With i_blkbits set to 10 and i_size set to 32KB, donor_eof is 32 blocks,
while donor_start = 1 + (PAGE_SIZE >> 10) evaluates to 65 when PAGE_SIZE
is 65536. mext_check_adjust_range() sees donor_eof <= donor_start, clamps
*len to 0, and returns -EINVAL instead of 0. Sizing orig and donor
relative to PAGE_SIZE (for example, max_t(loff_t, 32 * 1024, 4 * PAGE_SIZE))
would avoid this.
[ ... ]
> +static void test_move_extents_written_copy_data_and_split(struct kunit *test)
> +{
> + struct mext_test_ctx *ctx = mext_setup_ctx(test);
> + struct inode *orig = ctx->orig_inode;
> + struct inode *donor = ctx->donor_inode;
> + ext4_lblk_t lblk;
> + __u64 moved_len = 0;
> + int ret;
> +
> + /*
> + * orig: [0, 6) written -> pblk 400..405, uptodate folios pre-filled
> + * donor: [1, 2) written -> pblk 501, [2, 3) hole,
> + * [3, 5) unwritten -> pblk 503..504
> + *
> + * Moving [1, 5) exercises MEXT_COPY_DATA, left/right extent splits on
> + * orig, donor hole skipping at lblk 2, written preservation on orig,
> + * mark_unwritten=1 on donor, and page cache data preservation.
> + */
> + i_size_write(orig, 6 * MEXT_TEST_BLK_SIZE);
> + EXT4_I(orig)->i_disksize = 6 * MEXT_TEST_BLK_SIZE;
> + i_size_write(donor, 6 * MEXT_TEST_BLK_SIZE);
> + EXT4_I(donor)->i_disksize = 6 * MEXT_TEST_BLK_SIZE;
> +
> + mext_insert_extent(test, orig, 0, 6, 400, false);
> + mext_insert_extent(test, donor, 1, 1, 501, false);
> + mext_insert_extent(test, donor, 3, 2, 503, true);
> +
> + for (lblk = 0; lblk < 6; lblk++)
> + mext_populate_folio_block(test, orig, lblk, 0xA0 + lblk);
> +
> + ret = ext4_move_extents(&ctx->orig_file, &ctx->donor_file, 1, 1, 4,
> + &moved_len);
> + KUNIT_EXPECT_EQ(test, ret, 0);
> + KUNIT_EXPECT_EQ(test, moved_len, 3ULL);
[Severity: Medium]
Does ext4_move_extents() fail with -EBUSY here when PAGE_SIZE > 4096?
With a 4KB block size on 16KB or 64KB page kernels, logical blocks 1 and 3
share folio 0 in orig->i_mapping. Moving lblk 1 via MEXT_COPY_DATA calls
mext_folio_mkwrite() -> block_commit_write(), which attaches buffer_heads
to orig's folio 0 and marks lblk 1's buffer dirty. After skipping the
donor hole at lblk 2, mext_move_extent() tries to move lblk 3..4 in the
same folio and calls filemap_release_folio(folio[0], 0) ->
ext4_release_folio() -> try_to_free_buffers(), which refuses to drop the
dirty buffer from lblk 1 and aborts the move with -EBUSY and moved_len = 1.
Similarly, in test_move_extents_unwritten_orig_and_ebusy(), moving
lblk 0..1 leaves dirty buffers on orig's folio 0 when PAGE_SIZE >= 16384,
so the subsequent move of lblk 2 fails filemap_release_folio() on orig
before reaching the PG_checked donor_folio under test.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261112040638.1576836-1-tytso@mit.edu?part=25
next prev parent reply other threads:[~2026-11-12 4:36 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 4:06 [PATCH 00/27] ext4: add lots of KUnit tests! Theodore Ts'o
2026-11-12 4:06 ` [PATCH 01/27] ext4: add KUinit tests for fs/ext4/extents_status.c Theodore Ts'o
2026-11-12 4:18 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 02/27] ext4: add KUnit tests for fs/ext4/extents.c Theodore Ts'o
2026-11-12 4:28 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 03/27] ext4: add KUnit tests for ext4_ext_split() leaf and index splitting Theodore Ts'o
2026-11-12 4:15 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 04/27] ext4: add KUnit tests for fs/ext4/xattr.c Theodore Ts'o
2026-11-12 4:26 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 05/27] ext4: add KUnit tests for fs/ext4/namei.c Theodore Ts'o
2026-11-12 4:21 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 06/27] ext4: expand KUnit tests for fs/ext4/mballoc.c Theodore Ts'o
2026-11-12 4:26 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 07/27] ext4: add KUnit tests for fs/ext4/inline.c Theodore Ts'o
2026-11-12 4:29 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 08/27] ext4: zero s_fc_replay_state in ext4_fc_replay_cleanup() Theodore Ts'o
2026-11-12 4:16 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 09/27] ext4: add KUnit tests for fs/ext4/fast_commit.c Theodore Ts'o
2026-11-12 4:28 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 10/27] ext4: expand KUnit tests for fs/ext4/inode.c Theodore Ts'o
2026-11-12 4:36 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 11/27] ext4: add KUnit tests for fs/ext4/ialloc.c Theodore Ts'o
2026-11-12 4:25 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 12/27] ext4: add KUnit tests for fs/ext4/balloc.c Theodore Ts'o
2026-11-12 4:16 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 13/27] ext4: add KUnit tests for fs/ext4/orphan.c Theodore Ts'o
2026-11-12 4:18 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 14/27] ext4: add KUnit tests for fs/ext4/block_validity.c Theodore Ts'o
2026-11-12 4:21 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 15/27] ext4: check multi-block overlap on left traversal in add_system_zone() Theodore Ts'o
2026-11-12 4:10 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 16/27] ext4: enable full feature coverage in fs/ext4/.kunitconfig Theodore Ts'o
2026-11-12 4:24 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 17/27] ext4: add KUnit tests for fs/ext4/super.c Theodore Ts'o
2026-11-12 4:27 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 18/27] ext4: add KUnit tests for fs/ext4/sysfs.c Theodore Ts'o
2026-11-12 4:32 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 19/27] ext4: add KUnit tests for fs/ext4/ioctl.c Theodore Ts'o
2026-11-12 4:35 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 20/27] ext4: add KUnit tests for fs/ext4/resize.c Theodore Ts'o
2026-11-12 4:34 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 21/27] ext4: add KUnit tests for fs/ext4/migrate.c Theodore Ts'o
2026-11-12 4:37 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 22/27] ext4: add KUnit tests for fs/ext4/indirect.c Theodore Ts'o
2026-11-12 4:46 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 23/27] ext4: expand KUnit tests in fs/ext4/extents-test.c for file range operations Theodore Ts'o
2026-11-12 4:34 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 24/27] ext4: add KUnit tests for fs/ext4/fsmap.c Theodore Ts'o
2026-11-12 4:30 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 25/27] ext4: add KUnit tests for fs/ext4/move_extent.c Theodore Ts'o
2026-11-12 4:36 ` sashiko-bot [this message]
2026-11-12 4:06 ` [PATCH 26/27] ext4: add KUnit tests for fs/ext4/mmp.c Theodore Ts'o
2026-11-12 4:29 ` sashiko-bot
2026-11-12 4:06 ` [PATCH 27/27] ext4: add KUnit tests for fs/ext4/dir.c Theodore Ts'o
2026-11-12 4:41 ` sashiko-bot
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=sashiko-outbox-210368@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.