From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.169 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796060510; b=otBl6YutEITj5tnQWZHV/CVHMy3Chooo0UmxUUEldeTI2Bejm1DxuiduNm9twLLBSxLM LmfeYFrNIev88zigyJpcrG4oNCFyDVxZe1Hv741irrW1ViKJP9VvRYJEqXgnzorBZBvLj uTPgUfWRIR31XW/5w5j1zf4g2gbMv8eHZC/EnTf1JvE5J6KPJZZHQafROIBolEDRjSqSd pGhInQRIl9ujf3T9H7cO3jFE065+H1J3dj+c783GhidF8hi9pW/5GiLhnAlO0gP+DlcKN DLgV6cbXWL/RW7dlhusgcDKSsLXifJkTEHQoySZCZ1FSzzHOTBEnwng4PTcwDnlnhiw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796060510; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=f6h62TE+23AsrhhG79hNJOuY0MhEwQSnuEDAUDvbTpw=; b=zYeRZaIJUjeJEjkdapQ2JUsi94etzy/d3Isv8yZ1pUtSNmBEHw/doYqhSExfp1Pnenwf +1Wq0MwcUMKHYmFqVNT2ERI7kQL9Cs0Hf/3j/sMlC1tSC3QUiSeSyYL07R+qv4gMMItPb 2ExTyMieZxnUn/SVeISh2sCnzs6BUwsSyY/PbZVLp3NwIdEci9amN/ieuxMQFgQR4sDtm RBNYhGi0b37BbCtnD0HUyd88pwor83EQ3OqXMRrH4hAgjWjMk6jpC8ouuHhyNaEypgYFs jOZ5ZsKmkz22lxgXfDj2MIBXQiMLxDy7fk/ubqDtQivpJWe6ovnT5bNNAtTKdJ+81Tw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oABu1p08; arc=none smtp.remote-ip=209.85.210.169 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A51D8606A325 for ; Mon, 30 Nov 2026 17:41:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A51D8606A325 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.a=rsa-sha256 header.s=20260707 header.b=oABu1p08 Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-8a070755c8cso5109945b3a.0 for ; Mon, 30 Nov 2026 09:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796060509; x=1796665309; 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=f6h62TE+23AsrhhG79hNJOuY0MhEwQSnuEDAUDvbTpw=; b=oABu1p08o6/m0CQUXS4ou8kPQ7v5mxSwJ2tP7v9gwl+vdllXdRXbXiTsR+jiSmDfOQ 25fPoYIFbzSyYuUPSBxkynhCILPvaevQ6souk0hVtQpcDjz+I8LjygmPwND4k4j/kaeO S3n+oQsBDtr28V3lO8ItyCS+dgJhEwzzNPFKGChtWdYU8ygqjeb7mKDk6lzzlj+Tv1To fa62XkmHGG4mgWFsAdT+WCaye0pZYTG2jZmEESt0aDjrcpgsALVjHVFUfHM/hEPUjNqO 2h62YnJR2+c7f/b7KymFcvTSxp/K2F1l5i15xZAdyPlWF6cBg+fr6RoV8gAXWPZdwWwY ubDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796060509; x=1796665309; 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=f6h62TE+23AsrhhG79hNJOuY0MhEwQSnuEDAUDvbTpw=; b=Z74sOWdmm3qvOj27NaPNp9LtuN889oY+z7r5Ios5rReWe101bwq1Jn+YllxS4h5d6x mEyWSmIkcjRJ20uas4MDgkDT7l3onCP9owjKurCoABlvAtPNOmprZNV+80aY0ngIqQkS 2gnse+ahTC8xl8yPt437SOYztQbxDHnm5KdE9FNo4vLa7R9mvS4/QMeEdIOojhNsVN8C uF7uymwh1u9OCM3arkgT/11XcYog4YKIqVVczqNss5G8UK9+QTlmbhS2go5uPGhiVWHY OxOt9LBps3L+z3LxtuPr/RhFJd7YXVJuJari/uPvWRXXWSBYscyoS3zR4g6CvkyswZZl n0/Q== X-Forwarded-Encrypted: i=1; AL+hErFdA+ivhp+yDz7ysywl+MECzE6UT7hXfTQPyash6v4UKuqJ0p2VJqZ3bHkgR0+IAAUty5etrRzAy6+S8us=@vger.kernel.org X-Gm-Message-State: APuU4Z8pDXnk9xY/U/txo9kgPPe0XoMKh8m+FKzhSdOjfaQaItH4c397 1R1n6aMeaXWLJ7u5ddOLQsBWneP0a3rffrj4pUBP9k2NlUvvi3yNhOq7 X-Gm-Gg: AZFdTZdmpxseq9NMDf9Ob996D7a6rmwxlP2TXjJUpQg/f5ADulmjHLSN3d3VlUgK/8Y Kkap/lj/vUUHHpoGosi1oQ9EamYYIsvJSabDVlg1i+vUNlO33okMwISfIph/A9T9oBtNSKjYhpM fIZ/UHvCvoS6KsN6oB7eVmEQfJ0LAhbAUgcfo46wEHx7AeqzO53j1Rc9jlr6COl3GgXmr0IL6Zd WZL7ADCIWlnReUOCvez6uuJRv4PpxfOO93X3dXdTvD+oxo1GvzigfFDGahgMNKP9yQ/YyYNlEu0 AJ6wpdaCvbSQ+9SS5eNjyFDypSR6dNGj35G4i8oTGU1GJdtGaTDyX0kNdFlaqOxyx84hpse8HiN IrVwdln+zsksqMP9M+u8qc+eMwsROEAnuGbVKbHUS9OweEzyggNp2GosxlXv8rw95CEbBEQd7ol jQu01UyeMHvCMSAXjZCE9S+kkSf3vUMl8HBXh34J+MHck9e2xiscq3jayMXhq2TsN17IgyMMfV8 4pMY6mKAe4pZgrPLYHSk/e/GGpCUrWARLpok1y65NZB0uu83wBqHLOnC717lA7B47LKYj7Y3NvY H7DZswZtK1p3rz2qctwk0y4ytLtEHMP3qh0e+XQt9OH4 X-Received: by 2002:a05:6a20:c70e:b0:3f1:456d:c018 with SMTP id adf61e73a8af0-4014b56458dmr35112680637.17.1796060508829; Mon, 30 Nov 2026 09:41:48 -0800 (PST) Received: from localhost.localdomain ([61.255.248.240]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-cde6d03adafsm18846484a12.23.2026.11.30.09.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 09:41:48 -0800 (PST) From: Song jeonghak To: Andreas Gruenbacher Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, Song jeonghak , syzbot+70f4e455dee59ab40c80@syzkaller.appspotmail.com, Zheng Zheng , stable@vger.kernel.org Subject: [PATCH] gfs2: stop the slow statfs walk after one pass over the rgrps Date: Tue, 1 Dec 2026 02:39:35 +0900 Message-ID: <20261130173935.226991-1-thdwjdgkr123@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit gfs2_statfs_slow() stops queueing glock requests once gfs2_rgrpd_get_next() returns NULL. Since the resource groups were moved into an rbtree, gfs2_rgrpd_get_next() wraps around to the first resource group instead, so with two or more of them the walk can request the first resource group's glock again while still holding it: gfs2: fsid=vda.0: original: statfs_by_dentry+0x8a/0xe0 gfs2: fsid=vda.0: new: statfs_by_dentry+0x8a/0xe0 kernel BUG at fs/gfs2/glock.c:1490! This path is used when mounting with statfs_quantum=0 or after setting tune/statfs_slow in sysfs. Remember the first resource group and stop when the walk returns to it, as set_rgrp_preferences() already does. Tested in QEMU with lock_nolock filesystems: before the change, one statfs() after mounting with statfs_quantum=0 hit the BUG with 2, 9 and 63 resource groups and did not return with 64, 65 and 96; after it, statfs() returns the same values as with the default mount. Claude (Anthropic) was used to help with code analysis, testing and review. The fix was written by the submitter. Fixes: 7c9ca621137c ("GFS2: Use rbtree for resource groups and clean up bitmap buffer ref count scheme") Reported-by: syzbot+70f4e455dee59ab40c80@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=70f4e455dee59ab40c80 Reported-by: Zheng Zheng Closes: https://lore.kernel.org/all/CAO-4RZ2nS7ToE6rJxbTJM7CXHVY84YL4zqysFZA7=UzYg3SB0g@mail.gmail.com/ Cc: stable@vger.kernel.org Signed-off-by: Song jeonghak --- Testing details: next-20261126 with lockdep in QEMU, lock_nolock filesystems made with mkfs.gfs2 3.5.1 (-r 32), statfs() after mount. before after 2 rgrps, statfs_quantum=0 BUG (3 of 3) ok (3 of 3) 9 rgrps, statfs_quantum=0 BUG (3 of 3) ok (3 of 3) 9 rgrps, tune/statfs_slow=1 BUG (3 of 3) ok (3 of 3) 9 rgrps, remount,statfs_quantum=0 BUG ok 63 rgrps, statfs_quantum=0 BUG ok 64, 65 and 96 rgrps, statfs_quantum=0 no return ok in ~78 s 1 rgrp (rindex edited by hand) ok ok default mount ok ok The BUG stops at 63 resource groups: with 64 or more, the first pass fills all 64 holder slots, and the first holder is released just before the walk requests it again, so statfs() keeps going instead. After the change, the values from the slow path match those from the default mount, also after creating and deleting files and writing 40 MiB. No lockdep or other warnings were seen. Not tested with lock_dlm. Zheng, your report mentions that the reproducer depends on earlier state; on next-20261126 a mount with statfs_quantum=0 (or writing 1 to tune/statfs_slow) followed by one statfs() was enough. fs/gfs2/super.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 77a1f0a28e04..f1f687c43a99 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -884,6 +884,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host { struct gfs2_rgrpd *rgd_next; struct gfs2_holder *gha, *gh; + struct gfs2_rgrpd *rgd_first; unsigned int slots = 64; unsigned int x; int done; @@ -897,6 +898,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host gfs2_holder_mark_uninitialized(gha + x); rgd_next = gfs2_rgrpd_get_first(sdp); + rgd_first = rgd_next; for (;;) { done = 1; @@ -928,6 +930,9 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host GL_ASYNC, gh); rgd_next = gfs2_rgrpd_get_next(rgd_next); + /* gfs2_rgrpd_get_next() wraps around */ + if (rgd_next == rgd_first) + rgd_next = NULL; done = 0; } -- 2.43.0