From: Qiliang Yuan <realwujing@gmail.com>
To: yi.zhang@huaweicloud.com
Cc: tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz,
ritesh.list@gmail.com, ojaswin@linux.ibm.com,
libaokun@linux.alibaba.com, linux-ext4@vger.kernel.org,
linux-kernel@vger.kernel.org, yzjaurora@gmail.com
Subject: Re: [PATCH] ext4: fix quota accounting WARN in bigalloc punch hole
Date: Sat, 30 May 2026 15:47:03 +0800 [thread overview]
Message-ID: <20260530074703.74091-1-realwujing@gmail.com> (raw)
In-Reply-To: <9cf8569a-4f79-400b-ad80-197decec4b15@huaweicloud.com>
On 5/29/2026 6:37 PM, Zhang Yi wrote:
> On 5/29/2026 4:34 PM, Qiliang Yuan wrote:
>> Thanks for the review! Let me explain the issue with your specific
>> example.
>
> Thanks for the explanation, some comments below.
>
>> ext4_remove_blocks() sees that block 0's cluster has a pending
>> reservation → calls ext4_rereserve_cluster() → dquot_reclaim_block()
>> tries to move 16KB from dqb_curspace to dqb_rsvspace. But
>> dqb_curspace may already be insufficient (depending on whether
>> other allocs/frees have happened), triggering:
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> How exactly did it happen? All data cluster allocations are precisely
> calculated. In addition, the current example cannot reproduce the issue
> you encountered.
>
>> The key point is: pending from __revise_pending() indicates clusters
>> that *still contain delayed blocks outside the newly inserted extent*.
>> These clusters' quota reservations must be preserved — get_rsvd()
>
> Whether to reserve a quota is determined not by whether there are
> delalloc extents left, but by whether there are only pure delalloc
> extents in this cluster range.
You are right about the simple case — I missed the ext4_clu_alloc_state()
logic in ext4_insert_delayed_blocks(). When a cluster already has
allocated blocks, subsequent delalloc within that cluster does not
increase rsvspace, so releasing rsvspace after DIO allocation is
correct there.
However, the syzkaller reproducer's scenario is more complex. It uses
three operations:
1. DIO write at sub-block-aligned offset 0x6400 with RWF_DSYNC
(pwritev2, 0x140000 bytes at offset 0x6400)
2. Delalloc single-byte write at offset 0x8080c61 (far away cluster)
3. PUNCH_HOLE from offset 0x7f covering 0x8000c61 bytes
The DIO and delalloc are in different, distant clusters. The
sub-block-aligned DIO may cause it to fall through a different
code path — possibly zeroing or partial writeback within the cluster
boundary.
I'll instrument a kernel to trace the exact rsvspace/curspace
transitions and get back with concrete numbers showing where the
mismatch occurs. This should settle whether the root cause is
in resv_used += pending or something else.
Thanks for the detailed review!
--
Qiliang Yuan
prev parent reply other threads:[~2026-05-30 7:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 10:21 [PATCH] ext4: fix quota accounting WARN in bigalloc punch hole Qiliang Yuan
2026-05-29 7:32 ` Zhang Yi
2026-05-29 8:34 ` Qiliang Yuan
2026-05-29 10:37 ` Zhang Yi
2026-05-30 7:47 ` Qiliang Yuan [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=20260530074703.74091-1-realwujing@gmail.com \
--to=realwujing@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@huaweicloud.com \
--cc=yzjaurora@gmail.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