From: Heming Zhao <heming.zhao@suse.com>
To: Matthias Goergens <matthias.goergens@gmail.com>
Cc: ocfs2-devel@lists.linux.dev, mark@fasheh.com, jlbec@evilplan.org,
joseph.qi@linux.alibaba.com, glass.su@suse.com,
akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ocfs2: fix cached cluster count after suballocator reclaim
Date: Wed, 5 Aug 2026 16:49:19 +0800 [thread overview]
Message-ID: <anL1pYKZK8UqYwsI@p15> (raw)
In-Reply-To: <20260805070837.3390148-1-matthias.goergens@gmail.com>
The code looks good to me. However, the commit log needs some revision.
On Wed, Aug 05, 2026 at 03:08:37PM +0800, Matthias Goergens wrote:
> When reclaiming a suballocator block group, first reduce the on-disk
> cluster count by cl_cpg. The current code then subtracts that new count
> from the old cached count.
The current code then sbtracts that new count (fe->i_clusters) from the old
cached count (OCFS2_I(alloc_inode)->ip_clusters).
>
> For an allocator with N groups, that leaves the cache at
For an allocator with N block groups, that leaves the cache at
>
> N * cl_cpg - (N - 1) * cl_cpg = cl_cpg
N * cl_cpg - (N * cl_cpg - cl_cpg) = cl_cpg
i.e.:
->ip_clusters -= (fe->i_clusters - cl->cl_cgp)
=> ->ip_clusters equal to cl_cpg
>
> regardless of N. This happens to be correct when reclaiming from two
> groups, but undercounts the clusters from three groups onwards. The
s/groups/block groups/
> incorrect cache value is also used immediately to update i_blocks.
>
> Assign the updated on-disk count to the cache, matching the allocation and
> inode refresh paths.
>
> In a QEMU test using a clean 256 MiB OCFS2 image and a 10,000-file
> create/delete workload, the first buggy reclaim left the on-disk and cached
create/delete workload, the first buggy reclaim left the on-disk (fe->i_cluster)
and cached (->ip_clusters)
Thanks,
Heming
> counts at 2048 and 512 clusters respectively; later reclaims underflowed
> the cache. With this change, the cache matched the on-disk count across
> all four reclaims: 2048, 1536, 1024, and 512 clusters.
>
> Fixes: 4a54331616b3 ("ocfs2: give ocfs2 the ability to reclaim suballocator free bg")
> Cc: stable@vger.kernel.org
> Signed-off-by: Matthias Goergens <matthias.goergens@gmail.com>
> ---
> fs/ocfs2/suballoc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
> index a4a2b87a45fe3..20c3aec6b9873 100644
> --- a/fs/ocfs2/suballoc.c
> +++ b/fs/ocfs2/suballoc.c
> @@ -2759,7 +2759,7 @@ static int _ocfs2_reclaim_suballoc_to_main(handle_t *handle,
> fe->i_clusters = cpu_to_le32(tmp_used - le16_to_cpu(cl->cl_cpg));
>
> spin_lock(&OCFS2_I(alloc_inode)->ip_lock);
> - OCFS2_I(alloc_inode)->ip_clusters -= le32_to_cpu(fe->i_clusters);
> + OCFS2_I(alloc_inode)->ip_clusters = le32_to_cpu(fe->i_clusters);
> fe->i_size = cpu_to_le64(ocfs2_clusters_to_bytes(alloc_inode->i_sb,
> le32_to_cpu(fe->i_clusters)));
> spin_unlock(&OCFS2_I(alloc_inode)->ip_lock);
> --
> 2.55.0
>
next prev parent reply other threads:[~2026-08-05 8:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 7:08 [PATCH] ocfs2: fix cached cluster count after suballocator reclaim Matthias Goergens
2026-08-05 7:38 ` Heming Zhao
2026-08-05 7:56 ` Matthias Goergens
2026-08-05 8:49 ` Heming Zhao [this message]
2026-08-05 11:39 ` [PATCH v2] " Matthias Goergens
2026-08-05 12:20 ` Joseph Qi
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=anL1pYKZK8UqYwsI@p15 \
--to=heming.zhao@suse.com \
--cc=akpm@linux-foundation.org \
--cc=glass.su@suse.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=matthias.goergens@gmail.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=stable@vger.kernel.org \
/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