From nobody Sat Feb 7 18:15:48 2026 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 D3683266565 for ; Tue, 23 Dec 2025 14:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766498715; cv=none; b=DBiu+CPtUeqkI+KTXR3JNLvdT0YRf70V8dy46X9MgZBs+WcDA0QFhIdWB36t+cr7cc8+Vm4dQkMYVJuuJuykCHZERaAAW5kZTdci+uccav7BsZ5+Yl6uKr/GzEC6KbTpiKBF8orAmzcRYkqaK0l5qgGqMmCo1OwVKZ5EKfkgkws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766498715; c=relaxed/simple; bh=vPU2V50o5jpPnvrbKJzOO+bcSFJqLPqe32WzSG2rqCQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=N9nsJumBkpAzz96Vr8iUzOEGur/onSKz0up3IVCxVUCmP0n01cnQMpvnXtSOy2VuQ3b3fpHrJ624MJ4Ai8zNrpMgHfQGnZ+NbR8Rve098G/zE3IZTIAUSl325N6kdY1nEljpe44817812ZTs0ScLn8X3HJExd2XvzSb5ps5obIM= 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=FqinWUur; arc=none smtp.client-ip=209.85.214.182 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="FqinWUur" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2a110548cdeso70303135ad.0 for ; Tue, 23 Dec 2025 06:05:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1766498713; x=1767103513; 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; bh=TG6EI6RBrBqfcG1Qj/7XoK7r3FMDle9OXgLojBRhNAU=; b=FqinWUuribB64OLc5ysINuAqAFjL/5i0gfp4RmISinSiefKN7yxEtwsu/c4dWcO7Py cN3sYOYrTH4kkz2nmfEnt8CrgJyewUTlG7eiuv5sTP3cP0Qj2nWQfRjy9w03sKY+pHxs PmUZ2J10O5svv8FNbuGpSrjd3iegLW+zDqZ+VukESjruMsasCOknGpzYTXF9idFB7bfL ZqZwqkSCL4KZMjnby25ZQPGufemamemxiwW45G4bTRP6q+yVZoajBJtstg8AFdS+R3Kw FVP8h34jKqePOcGxScav3FSK6VZmJQHOQ+MNv4822sMgxB6x28J7yulaxik0ewAGTjTy 2BYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766498713; x=1767103513; 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; bh=TG6EI6RBrBqfcG1Qj/7XoK7r3FMDle9OXgLojBRhNAU=; b=L7bUpPNBBLBWaSr2LzwDFC9epoOQcu0uu73015/GuYpNwSP58+WuRHdDV7ZhjNPXL1 NQqQ2NXfGr+329JTaZrTSvrq8VjBejSoe8oaYfFCyiy2WfXSeNtLJzpVO+cH7gEzRIJb o1YkmMUbDQm0RYVjvJDGul8CZM8KsldTzpUbagOsaSC49qh3fBwipaHeilQWhKcWOi0m JbMx+lY1YuEcvY1OxPCvzBap7NpK8Z+Jufl2R8wZTuJNDLRbg2qJniBNdP9QkRQ3Ol9t pbX2aNQhLXFHfWeBu+PpLsDA4ggpnNOv8Hfkj1szR+vtxd0TeN4JsKuRI6oyrNJ7eBE2 IJXg== X-Forwarded-Encrypted: i=1; AJvYcCUSeh3/58aLhT1l4ugzE4tYJW1hi5o/nTuqozYIeO/WZ3XqP0MoZ6bh9QrakqKF+89oLoc0J8lVvpb8XRg=@vger.kernel.org X-Gm-Message-State: AOJu0Ywui4zGqJZm+wYkza6lIRu+5Sc5m5xgUktP3yb2YVvlyFXsR+Ux XD55NQNvDI+NBKHSMvIRqVmqMooLPaq2jGXlqUEQO+1A7bYjJnTaK+RhSBTzR4y9 X-Gm-Gg: AY/fxX7WacRbblbUzvuDg/l9bDp1vT+6gta+yqkbwUlwfwv5xWVbjtdtR3iirdQdcF2 XmnyQSmcOWWCkeEC0waKyXpZnaKpXorj81LH0xPL/7UFoVSP2miINrP61ZgjL0aQS9AxN6VRo7B QDH+9Fmq3hzuIH0/S9WH+bYd9cK48+88R6iVjRCwj+yjlr1EGNCvhtvHuNLtbFPU0qklFWP9Qn+ Ai2FIWypXLIZBRE+/Vwya7kW/iZ1udSJ4yc3c1Wm/7TcPxl4hwHq9L8y5xTajKYjJXQfQoMe+vF fUVyBQqNnMFA7FaJyUhI8AxYUvEQ0UG0rpxt0aIApba4STGbKIJVywjXrk/hruE4LPJG05kUxis GPY/wX5ncneZzGaUxiXxJpEvx4Hfahpue4e2uYaeaZ36scXUzWT/crcJICdajj5zYzMxAQuOQmu c8OuDij9C1WO0M X-Google-Smtp-Source: AGHT+IHbyFgKmCkKVy+fWCluUAqW7A5+LdBDsZ00crpOJb71qQWKWZcujxPGz1eDLdPumnLW6UqawQ== X-Received: by 2002:a05:7022:f68e:b0:11a:641f:ba11 with SMTP id a92af1059eb24-121722eaec0mr13661214c88.29.1766498712830; Tue, 23 Dec 2025 06:05:12 -0800 (PST) Received: from pop-os.. ([177.21.140.228]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-121724ddc30sm60661035c88.6.2025.12.23.06.05.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Dec 2025 06:05:12 -0800 (PST) From: Guilherme Giacomo Simoes To: agruenba@redhat.com Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, Guilherme Giacomo Simoes Subject: [PATCH] gfs2: do not evict glocks with populated address spaces Date: Tue, 23 Dec 2025 11:05:06 -0300 Message-Id: <20251223140506.568643-1-trintaeoitogc@gmail.com> X-Mailer: git-send-email 2.34.1 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" Metadata glocks may have associated address spaces used as caches. Avoid reclaiming such glocks under memory pressure while their mappings are still populated or their state is not unlocked, as this can lead to invalid page cache state and GLOCK_BUG_ON(). Signed-off-by: Guilherme Giacomo Simoes --- fs/gfs2/glock.h | 30 ++++++++++++++++++++++++++++++ fs/gfs2/super.c | 3 +++ 2 files changed, 33 insertions(+) diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 55d5985f32a0..12f57461f687 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -305,4 +305,34 @@ static inline bool glock_needs_demote(struct gfs2_gloc= k *gl) test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags)); } =20 +/* + * gfs2_glock_not_evictable - check if a glock is not evictable + * @gl: The glock to check + * + * Glocks which do not represent normal filesystem inodes (e.g. statfs, qu= ota, rindex) + * may have associated address spaces used as metadata caches. These glock= s must not + * be reclaimed under memory pressure while their mappings are still popul= ated or their + * state is not unlocked. + */ + +static inline bool gfs2_glock_not_evictable(struct gfs2_glock *gl) +{ + if (gl->gl_name.ln_type =3D=3D LM_TYPE_INODE) + return false; + + if (gl->gl_ops->go_flags & GLOF_ASPACE) { + struct gfs2_glock_aspace *gla; + + gla =3D container_of(gl, struct gfs2_glock_aspace, glock); + + if (!mapping_empty(&gla->mapping)) + return true; + } + + if (gl->gl_state !=3D LM_ST_UNLOCKED) + return true; + + return false; +} + #endif /* __GLOCK_DOT_H__ */ diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f6cd907b3ec6..86544cdafe53 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -1164,6 +1164,9 @@ static int gfs2_show_options(struct seq_file *s, stru= ct dentry *root) =20 static void gfs2_glock_put_eventually(struct gfs2_glock *gl) { + if (gfs2_glock_not_evictable(gl)) + return; + if (current->flags & PF_MEMALLOC) gfs2_glock_put_async(gl); else --=20 2.34.1