[Linux Kernel Bug] WARNING in gfs2_getbuf
From: Jiaming Zhang
Date: Sat Dec 05 2026 - 11:44:20 EST
Hi Linux kernel developers and maintainers,
We are writing to report a warning issue in the GFS2 subsystem,
reproducible on the latest version of Linux (v7.4-rc5, commit
fe6ff8d5d675).
It is triggered by mounting a GFS2 image with MS_LAZYTIME (requiring
CAP_SYS_ADMIN), updating file access times in memory, discarding the
cached inode metadata before closing the files, and reclaiming memory
when free pages are below the threshold. Below is the kernel report:
current->flags & PF_MEMALLOC
WARNING: mm/page_alloc.c:4837 at __alloc_pages_slowpath+0x129f/0x12c0
mm/page_alloc.c:4837, CPU#1: repro.out/9434
Modules linked in:
CPU: 1 UID: 0 PID: 9434 Comm: repro.out Not tainted 7.4.0-rc5 #62 PREEMPT(full)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix,
1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:__alloc_pages_slowpath+0x129f/0x12c0 mm/page_alloc.c:4837
Call Trace:
<TASK>
__alloc_frozen_pages_noprof+0x3f8/0x450 mm/page_alloc.c:5523
alloc_pages_mpol+0x241/0x4a0 mm/mempolicy.c:2520
alloc_frozen_pages_noprof mm/mempolicy.c:2591 [inline]
alloc_pages_noprof+0xb2/0x2b0 mm/mempolicy.c:2611
folio_alloc_noprof+0x1e/0x30 mm/mempolicy.c:2621
filemap_alloc_folio_noprof+0x107/0x450 mm/filemap.c:1017
__filemap_get_folio_mpol+0x3fd/0xf80 mm/filemap.c:2047
__filemap_get_folio include/linux/pagemap.h:758 [inline]
gfs2_getbuf+0x181/0x6d0 fs/gfs2/meta_io.c:145
gfs2_meta_read+0xfc/0x8b0 fs/gfs2/meta_io.c:272
gfs2_meta_buffer+0x11a/0x2f0 fs/gfs2/meta_io.c:460
gfs2_meta_inode_buffer fs/gfs2/meta_io.h:69 [inline]
gfs2_inode_refresh fs/gfs2/glops.c:493 [inline]
inode_go_instantiate+0xe0/0x12b0 fs/gfs2/glops.c:518
gfs2_instantiate+0x163/0x220 fs/gfs2/glock.c:410
gfs2_glock_holder_ready fs/gfs2/glock.c:1221 [inline]
gfs2_glock_wait+0x1ca/0x2a0 fs/gfs2/glock.c:1241
gfs2_glock_nq_init fs/gfs2/glock.h:253 [inline]
gfs2_dirty_inode+0x285/0x550 fs/gfs2/super.c:501
__mark_inode_dirty+0x3a4/0x13c0 fs/fs-writeback.c:2751
mark_inode_dirty_sync include/linux/fs.h:2220 [inline]
sync_lazytime+0x1ac/0x4c0 fs/fs-writeback.c:1782
iput+0x1f9/0xeb0 fs/inode.c:2067
dentry_kill+0x22e/0x9b0 fs/dcache.c:857
shrink_kill fs/dcache.c:1317 [inline]
shrink_dentry_list+0x209/0x310 fs/dcache.c:1334
prune_dcache_sb+0x10e/0x180 fs/dcache.c:1416
super_cache_scan+0x36f/0x4b0 fs/super.c:225
do_shrink_slab+0x6e7/0x1100 mm/shrinker.c:452
shrink_slab_memcg mm/shrinker.c:569 [inline]
shrink_slab+0x7f4/0x1170 mm/shrinker.c:647
shrink_node_memcgs mm/vmscan.c:6447 [inline]
shrink_node+0x2c05/0x60a0 mm/vmscan.c:6489
shrink_zones mm/vmscan.c:6708 [inline]
do_try_to_free_pages+0x519/0x1700 mm/vmscan.c:6770
try_to_free_mem_cgroup_pages+0x30f/0x7e0 mm/vmscan.c:7051
user_proactive_reclaim+0x4f1/0x870 mm/vmscan.c:8188
memory_reclaim+0x1f/0x30 mm/memcontrol.c:5210
cgroup_file_write+0x330/0x8c0 kernel/cgroup/cgroup.c:4426
kernfs_fop_write_iter+0x3af/0x540 fs/kernfs/file.c:345
new_sync_write fs/read_write.c:575 [inline]
vfs_write+0x5d2/0xb40 fs/read_write.c:667
ksys_pwrite64 fs/read_write.c:774 [inline]
__do_sys_pwrite64 fs/read_write.c:782 [inline]
__se_sys_pwrite64 fs/read_write.c:779 [inline]
__x64_sys_pwrite64+0x20a/0x2c0 fs/read_write.c:779
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x17b/0x560 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
Following is the root cause analysis for this issue. Note that the
analysis was performed with the assistance of an LLM, and we have tried
our best to ensure its accuracy.
The warning triggers in __alloc_pages_slowpath() because gfs2_getbuf()
allocates a metadata folio with __GFP_NOFAIL while the calling task is
already running memory reclaim (PF_MEMALLOC set), and low free memory
forces that allocation into the page-allocator slow path.
When a filesystem is mounted with MS_LAZYTIME, timestamp updates only
mark the in-memory inode with I_DIRTY_TIME instead of writing metadata
immediately. Since commit 0ae45f63d4ef ("vfs: add support for a
lazytime mount option"), dropping the last reference to a linked inode
in iput() flushes I_DIRTY_TIME via sync_lazytime().
During memory reclaim, tasks run with PF_MEMALLOC set and shrink cached
dentries via shrink_dentry_list(), which drops their inodes with iput()
and enters gfs2_dirty_inode() under PF_MEMALLOC. To write the updated
inode fields, gfs2_dirty_inode() locks the GFS2 cluster lock (glock),
starts a journal transaction, and reads the inode metadata buffer.
If that metadata folio is not cached in the glock's address space
(because the glock was invalidated or its clean folio was reclaimed
earlier), refreshing the glock or reading the inode buffer calls
gfs2_getbuf() to create the folio, passing __GFP_NOFAIL to
__filemap_get_folio().
A PF_MEMALLOC task cannot enter direct reclaim to free pages for itself,
so a __GFP_NOFAIL request under PF_MEMALLOC can loop indefinitely in
__alloc_pages_slowpath() once memory reserves are exhausted (and
acquiring glocks under PF_MEMALLOC can also deadlock with the
distributed lock manager), triggering the page-allocator warning.
To fix this issue, we can return early from gfs2_dirty_inode() when
called from PF_MEMALLOC memory-reclaim context, matching GFS2's existing
PF_MEMALLOC guards in fs/gfs2/super.c, thus preventing lazytime flushes
during dcache reclaim from acquiring glocks or issue __GFP_NOFAIL
allocations:
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 04bb4cf787d4..3ec6599a36e6 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -497,6 +497,8 @@ static void gfs2_dirty_inode(struct inode *inode, int flags)
if (gfs2_withdrawn(sdp))
return;
+ if (current->flags & PF_MEMALLOC)
+ return;
if (!gfs2_glock_is_locked_by_me(gl)) {
ret = gfs2_glock_nq_init(gl, LM_ST_EXCLUSIVE, 0, &gh);
if (ret) {
The kernel console output, kernel config, and C reproducer are available
on Google Drive:
https://drive.google.com/drive/folders/1IOr668NnwVbrX9ZvE0sxRCQ5U4jjyPH7?usp=sharing
Best regards,
Jiaming Zhang