[PATCH 4/4] netfs: Fix folio_queue ENOMEM in writeback by adding a mempool
Zhou, Yun
yun.zhou at windriver.com
Tue Jul 28 01:36:30 PDT 2026
On 7/27/2026 9:07 PM, David Howells wrote:
> 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.
>
Have you considered splitting this into multiple patches based on
different functionalities?
> @@ -200,12 +205,14 @@ struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq
> mempool_t *mempool = rreq->netfs_ops->subrequest_pool ?: &netfs_subrequest_pool;
> struct kmem_cache *cache = mempool->pool_data;
>
> - for (;;) {
> - subreq = mempool_alloc(rreq->netfs_ops->subrequest_pool ?: &netfs_subrequest_pool,
> - GFP_KERNEL);
> - if (subreq)
> - break;
> - msleep(10);
> + if (rreq->gfp == GFP_KERNEL) {
Direct equality checks are not reliable; using !(rreq->gfp & GFP_NOFS)
for the check is more robust.
> + subreq = mempool->alloc(rreq->gfp, mempool->pool_data);
> + if (!subreq)
> + return ERR_PTR(-ENOMEM);
Since some callers check for success by testing !NULL, we cannot return
ENOMEM.
221 subreq = netfs_alloc_subrequest(rreq);
222 if (!subreq) {
223 ret = -ENOMEM;
224 break;
> + } else {
> + subreq = mempool_alloc(mempool, rreq->gfp);
> + if (!subreq)
> + return NULL;
Redundant check. If it is added to mirror the GFP_KERNEL path above,
returning the same error code would be better for the caller to handle.
Or perhaps this is an intentional design?
More information about the linux-afs
mailing list