netfs: Fix folio_queue ENOMEM in writeback by adding a mempool
authorDavid Howells <dhowells@redhat.com>
Mon, 27 Jul 2026 13:07:15 +0000 (14:07 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 28 Jul 2026 13:42:31 +0000 (15:42 +0200)
commit1d78d56c43ef3768183e8370e7367b162700e049
tree12fbfb0633826148b5cdcc968db5ae1e44b7249d
parent87eb3d272dcbcbbfe5c1576c10e5dc72810cf1f6
netfs: Fix folio_queue ENOMEM in writeback by adding a mempool

Fix the handling of folio_queue allocation failure in writeback by adding a
mempool and passing in gfp_t flags to the rolling buffer functions that
allocate memory, using the mempool if gfp != GFP_KERNEL.

This is then extended upwards and the gfp to be used for a request is stored
in the netfs_io_request struct and is then used for both requests and
subrequests, eliminating the sleeping loops there.

The failure caused:

    folio != NULL
    WARNING: fs/netfs/write_issue.c:603 at netfs_writepages+0x883/0xa10 fs/netfs/write_issue.c:603, CPU#3: syz.0.17/5919

Fixes: cd0277ed0c18 ("netfs: Use new folio_queue data type and iterator instead of xarray iter")
Reported-by: syzbot+0da43efa72f88bd3a8af@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=0da43efa72f88bd3a8af
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260727130716.1099906-5-dhowells@redhat.com
Tested-by: syzbot+0da43efa72f88bd3a8af@syzkaller.appspotmail.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: Yun Zhou <yun.zhou@windriver.com>
cc: Matthew Wilcox <willy@infradead.org>
cc: Christoph Hellwig <hch@infradead.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
fs/netfs/buffered_read.c
fs/netfs/internal.h
fs/netfs/main.c
fs/netfs/objects.c
fs/netfs/read_pgpriv2.c
fs/netfs/rolling_buffer.c
fs/netfs/write_issue.c
include/linux/netfs.h
include/linux/rolling_buffer.h