From: sashiko-bot@kernel.org
To: "Aykut Cıncık" <aykutcincik@ogr.eskisehir.edu.tr>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu
Subject: Re: [PATCH] ext4: discard inode preallocations when indirect block allocation fails
Date: Sat, 21 Nov 2026 13:20:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-227059@kernel.org> (raw)
In-Reply-To: <20261121-ext4-ind-discard-pa-v1-1-ee92928f7797@ogr.eskisehir.edu.tr>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] ext4: inaccurate Fixes trailer in commit message
--
commit 1bfc794f1c8f78c227e6f7f7e5eea7e4e3428226
Author: Aykut Cıncık <aykutcincik@ogr.eskisehir.edu.tr>
> ext4: discard inode preallocations when indirect block allocation fails
>
> When ext4_alloc_branch() or ext4_splice_branch() fails after the data
> blocks have been allocated, the blocks are released with
> ext4_free_blocks(). For an indirect-mapped inode these blocks usually
> come from the inode preallocation (PA), and ext4_mb_use_inode_pa() has
> already subtracted them from pa_free. Freeing them does not return
> them to the PA, so the PA still covers the logical range while pa_free
> no longer accounts for it.
>
> Writeback retries the same logical range after such a failure, for
> example after sb_getblk() returns NULL with -ENOMEM for an indirect
> block that lies beyond the end of a shrunk loop device, and
> ext4_mb_use_preallocated() picks the same PA again. This time pa_free
> is smaller than the requested length and the BUG_ON() in
> ext4_mb_use_inode_pa() fires:
>
> kernel BUG at fs/ext4/mballoc.c:4779!
> RIP: 0010:ext4_mb_use_inode_pa+0x557/0x890
> Call Trace:
> ext4_mb_use_preallocated+0xd96/0x1440
> ext4_mb_new_blocks+0x72d/0x4900
> ext4_ind_map_blocks+0x142c/0x2210
> ext4_map_create_blocks+0x2be/0x5c0
> ext4_map_blocks+0xbb2/0x1480
> ext4_do_writepages+0x1dba/0x3a60
> ext4_writepages+0x370/0x770
> do_writepages+0x288/0x600
> filemap_writeback+0x203/0x290
> file_write_and_wait_range+0xf7/0x170
> ext4_sync_file+0x418/0xdb0
> do_fsync+0xda/0x240
>
> If the BUG_ON() is not reached, the mismatch shows up later as
> "freeing already freed block" and "ext4_mb_release_inode_pa: free N,
> pa_free M" errors when the PA is released.
>
> The extent-mapped path has handled this since mballoc was added by
> discarding the inode PAs before freeing the blocks in
> ext4_ext_map_blocks(). Do the same in both indirect error paths.
>
> An AI coding assistant (Claude Code with Claude Opus) was used to
> analyse the syzbot report, write a reproducer, trace the root cause with
> temporary printk instrumentation, and draft both the fix and this
> changelog. I have reviewed the change and verified it as follows:
> without the fix the reproducer hits the BUG_ON() deterministically in
> QEMU (virtme-ng, KASAN and lockdep enabled); with the fix it ran 3/3
> times without BUG, KASAN or pa_free reports. The ext4 KUnit tests pass,
> and a copy/write/delete workload on a no-extents filesystem leaves
> e2fsck clean.
>
> Reported-by: syzbot+d79019213609e7056a19@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=d79019213609e7056a19
> Fixes: c9de560ded61 ("ext4: Add multi block allocator for ext4")
> Cc: stable@vger.kernel.org
> Signed-off-by: Aykut Cıncık <aykutcincik@ogr.eskisehir.edu.tr>
[Severity: Low]
In commit c9de560ded61 ("ext4: Add multi block allocator for ext4"),
indirect block allocation called ext4_new_blocks() without setting
EXT4_MB_HINT_DATA in ar.flags, so inode preallocations were never created
or used for indirect-mapped files. Should the Fixes: tag point to commit
7061eba75ceb ("ext4: Use inode preallocation with -o noextents") instead,
which enabled EXT4_MB_HINT_DATA on the indirect allocation path?
Fixes: 7061eba75ceb ("ext4: Use inode preallocation with -o noextents")
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261121-ext4-ind-discard-pa-v1-1-ee92928f7797@ogr.eskisehir.edu.tr?part=1
prev parent reply other threads:[~2026-11-21 13:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 13:09 [PATCH] ext4: discard inode preallocations when indirect block allocation fails Aykut Cıncık via B4 Relay
2026-11-21 13:20 ` sashiko-bot [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=sashiko-outbox-227059@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aykutcincik@ogr.eskisehir.edu.tr \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox