From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D566F3E49EB for ; Wed, 5 Aug 2026 07:38:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785915498; cv=none; b=NwWm4jh/PIH9z4BG19byyzqE9ZSoU5sSMK8khP14YEEat7+T9Ya35GRZ0qV6il2y3X0P2eUUmu9AqqmxH1bIHoQRRzmlBmwhDJRy+5DrWoRp583TGlZRzIPPlrLq/Bd6vlHLaYTJmhw7zuqslNW3++YW6tHVjU3Xxf1RaAGo3yk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785915498; c=relaxed/simple; bh=XI4hTAnrlqQ1zIjV9q/lYkTlrEMba7KvOf/Kq4845i0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZMYarya7Rw8ExCGuhP/DGXYOjrgJTCBrFDLmiFRjL5W6sIpHZAwaeoU0mYKR4DzXnTslxtqjk+vBaQexjxFbslrumAVbasoQGJ2g59mvjlknps0FBkVGji5Tmm6SXfxau7qS7fumdP0NRWKRDGo0BTVeYzWEJNjINNiB1gkhJwE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=MU5tZ4zw; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="MU5tZ4zw" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4957799b92fso309095e9.1 for ; Wed, 05 Aug 2026 00:38:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1785915494; x=1786520294; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=pryAcCweidUP055MOdKbB8yhGrbTMfIHwq/HAZxy2+E=; b=MU5tZ4zwRtumtZIbIuhOgOdEpS4ccUllCq1+3UULWcWI47NPwL4V9872AtFNPYYDyJ IUVD1rIaniRf3nlCO/TjZt1IlQFC3W47TrR+QB+sNrCEWS+g1PXq4Lqzgq8EWhPlUR0E 5qaCtA5mQFTi6dCY3P5HPk5QpkSEfqS/KBQJr4BYvRSdJ4tQoyPeO+tOXSD9Ai2+Zo1n 1lVndnuuW3nsqmKhDdQ4/yCxEM4pveBXnftttw7e3Wb1/2TftZ8TcgIHZQq5z6TysvnZ 8IZQCmebcvurF6cNggcXizJN+iHmGwJLbu7JbxKUZZD+IiVkgL9ivQ4hA/dnRqJS/X7f 1xOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785915494; x=1786520294; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pryAcCweidUP055MOdKbB8yhGrbTMfIHwq/HAZxy2+E=; b=Pp5aOhFGlFpGD1SoIWLTwT+ni7nsGUev6zT2nBaBUwKSjRPB7WZz16M3An6pGcI/9M 5001UgWt0sIrESMOrQH7Nr41xLoS618NKdk7WuEXeVpUCY8/QbHFzFwhDisfaq3gEmBz lHs5xZrWU3OXW1Xbp77uOHIkflfXBI2BwlbuIIOd2jyBkhzpzAaCI+f74bhLceWMWJlk p9hN0dNJLtChyulttIfMrlzTL3vEG5tD15dDBNOYpKd4dJ9H2tiKiIuAOw9Pt0LDOGpT o0I8hfb94uzI4HgoNXOU+gFVHESs3tnjyIb9cx4+439EEzhaR4GIqyiQuQiVrp0DqG6+ JXPQ== X-Forwarded-Encrypted: i=1; AHgh+RqfhaYUy/xPtdYNBV/A9qBQl+CdMGxJej4gMoAK2Jiemlde61W304efmG1nj8LLszb3nc9A9dRHh8aJ77E=@vger.kernel.org X-Gm-Message-State: AOJu0YzJHGBZOrzAJIfqU4MqUwC7NY01eBqd/JT285M58mbfOwB1rWlf YsYBy40Fa3VxHOIU1yHyIi1ef27l6y/0l/H/mU1lkWSrnmVIHFaMqEfiuao+3YnP3C8= X-Gm-Gg: AR+sD10ba5WLKTTuCF+PxZlddA9vFVjTNIVWzoLjit6+m583YzJBJ2jkZkT8bUoA86N sDA2zCn9sv5eJFK2bhFgsUWd5awSvugajcrWBg7y6MW2nAz8yqdc9J1h538c0Wl2OuYBhZDFB2s LyGiW1T3SjWcoNP1lE5R5qbURWbdP8b/nOnaMgwMi93RPI1q1xxGuAJ1CrpTxoDipfM40EHZoqG iE0kag9ap/Ekb+XtXE49YpQ6ygd1xCK60sKe1ZxgSKw+Fklw1Lf0EY82uW4pXhddxd2iX9sSVrt c+YlbPC/5yHwQFta8S0p1Vms6CbGQVUySCopHqnUdB7ZYB/Yz1/GfvVumuk4uyX2P2yFpu9alXK wvve4M+5YcwUQqXotrXIJTfUd3nf7YBvF0qnJ4kn5pHmk7iMlZ8RocukBsOh9xaLtOUopVGR9fs 1dVMGw/HOavjAZlCAH1dDFqGDBJoDQh0A4fLbMWmK8nED9bJLyzADIsYpBzR04ELjs2tEK/8s= X-Received: by 2002:a05:600c:1c22:b0:495:71ff:598d with SMTP id 5b1f17b1804b1-4994edf895dmr18352885e9.1.1785915494092; Wed, 05 Aug 2026 00:38:14 -0700 (PDT) Received: from localhost ([202.127.77.110]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cbe709094fasm892080a12.27.2026.08.05.00.38.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 00:38:13 -0700 (PDT) Date: Wed, 5 Aug 2026 15:38:05 +0800 From: Heming Zhao To: Matthias Goergens 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 Message-ID: References: <20260805070837.3390148-1-matthias.goergens@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260805070837.3390148-1-matthias.goergens@gmail.com> Hello Matthias, Could you share your test case, I want to reproduce the issue and verify the fix. Thanks, Heming 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. > > For an allocator with N groups, that leaves the cache at > > N * cl_cpg - (N - 1) * cl_cpg = cl_cpg > > regardless of N. This happens to be correct when reclaiming from two > groups, but undercounts the clusters from three groups onwards. The > 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 > 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 > --- > 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 >