From nobody Fri Oct 2 08:28:23 2026 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 6082F3E1CED for ; Wed, 5 Aug 2026 07:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785913725; cv=none; b=BKz2z6z0DBDu93Cn3R+1pN6xr7xZJFevT0gng6B6jSZeQswTW6g7eJZpd7MWCwgEFp5RHpqjQ2pWnssHr/5AIbmUd74R1v/qEySrjyiBo94zcqfN9xibuOa74/3sG2HPhNpwT9lodSpj8DN2mASu9GDPtRhh7ahJj7HVyhP3o5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785913725; c=relaxed/simple; bh=7HiAf+EpVjkitp9J9mLgx1LeCBjQIRcocIrQjiEIkm0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=raKmtLO0YQrfyiYNUAVtUWKyUPV3n/NlefsCJnvZxBpRmxdjVEORJSUtWx2VgMcnBaSzZID35z2TGcekenoy1wWw93H4suaX/zs4VLpfVNGU8m1Zu15IZhNyi5DxpohERWNrwfObv8kj9vh4Xm2q88BDqZqgyJAi1lyHOhQQ30w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iZ0vZ1hx; arc=none smtp.client-ip=209.85.216.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iZ0vZ1hx" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-383b4a3755fso633804a91.3 for ; Wed, 05 Aug 2026 00:08:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785913723; x=1786518523; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=g/DUUT6RMx4jLkGvR4e26W85aURX7BHuSfTbyD0AJW0=; b=iZ0vZ1hxqyo5FIUeI3oN19XuFcfDYOuPw8jzXZyKVGa4yeo75GjOh6PWgxPhLD+d/+ funQsQYBZtrW4aPzyPX0hGwGllL2zByw4tyBn45gTeQ2dFa1vC8mFb9L+KqHBPiWR6NK ZTTp7kiSRqHJNdQJe53zKla9KKGHlNx+j9fC8y6VD7tVJULaMGmOdS1eb/AUNTdDtPFD s8VqklQ+fa9VUHY34Rd+KHCrmYCtyemYE0B0a8kYmx5kY5P4nty9YONMi9sJsNVdmJEe t86ZZq70Itu+dYRx2QyvfpTSEcEcbZIoKi/X8K+39T+qgruIa66QXJzjn0+/H03Wwwcg oQ5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785913723; x=1786518523; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=g/DUUT6RMx4jLkGvR4e26W85aURX7BHuSfTbyD0AJW0=; b=pa7NaboiJK/H1OUjTwbklobLXvg+qXmFjgmJJZEcUVhqe1wYfPh/yAX3U6R/jwMCyS IpxYuxCmtXpuqFBB8SkSVCHG5pQzfBZtpCQ4mq/+YNxr3u6geErVChgMTFd78sbXF9ou JmLmbYKQbJrcY+l3ayXtLoMjbdCGtN8Dr8RCDQjVlia/m5g7+dbmr7Ui7KKYbCyQ+aOE lw06xqAxl4Y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3bb5 with SMTP id 98e67ed59e1d1-3903c63373emr5263359a91.21.1785913722666; Wed, 05 Aug 2026 00:08:42 -0700 (PDT) Received: from spider.bream-herring.ts.net ([103.252.203.158]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3903927dddbsm2136523a91.9.2026.08.05.00.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 00:08:42 -0700 (PDT) From: Matthias Goergens To: ocfs2-devel@lists.linux.dev Cc: mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, heming.zhao@suse.com, glass.su@suse.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Matthias Goergens Subject: [PATCH] ocfs2: fix cached cluster count after suballocator reclaim Date: Wed, 5 Aug 2026 15:08:37 +0800 Message-ID: <20260805070837.3390148-1-matthias.goergens@gmail.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 =3D 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 =3D cpu_to_le32(tmp_used - le16_to_cpu(cl->cl_cpg)); =20 spin_lock(&OCFS2_I(alloc_inode)->ip_lock); - OCFS2_I(alloc_inode)->ip_clusters -=3D le32_to_cpu(fe->i_clusters); + OCFS2_I(alloc_inode)->ip_clusters =3D le32_to_cpu(fe->i_clusters); fe->i_size =3D 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); --=20 2.55.0