]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
NFS: Charge unstable writes by request size, not folio size
authorBenjamin Coddington <ben.coddington@hammerspace.com>
Tue, 7 Jul 2026 15:07:16 +0000 (11:07 -0400)
committerAnna Schumaker <anna.schumaker@hammerspace.com>
Wed, 8 Jul 2026 18:43:40 +0000 (14:43 -0400)
commit27934d02cbeb8a957dd11c985a579e58d30c5270
tree9a31096c55882489cbba80bbed6c30c298b07627
parent5140f099ecd8a2f2808b7f7b720ee1bad8468974
NFS: Charge unstable writes by request size, not folio size

nfs_folio_mark_unstable() and nfs_folio_clear_commit() charge and
uncharge NR_WRITEBACK/WB_WRITEBACK by folio_nr_pages(folio) once per
*request* added to or removed from a commit list. This is correct only
when a folio has a single associated request. When pg_test splits a
folio into N sub-folio requests (e.g. pNFS flexfiles striping with a
stripe unit smaller than the folio size, or plain wsize-limited
splitting), each of the N requests independently charges the whole
folio's page count, inflating the accounting by a factor of N per
folio. With large folios and small stripe units this reaches multiple
orders of magnitude: a 2 MiB folio split into 512 4 KiB requests can
charge up to 512x its real size, pushing global dirty+writeback
accounting past the system's dirty threshold and forcing every
buffered writer on the host into the hard-throttle path, including
unrelated in-kernel NFS server threads sharing the box.

Charge each request only for the pages it actually covers.

Fixes: 0c493b5cf16e ("NFS: Convert buffered writes to use folios")
Cc: stable@vger.kernel.org
Signed-off-by: Benjamin Coddington <bcodding@hammerspace.com>
Assisted-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Anna Schumaker <anna.schumaker@hammerspace.com>
fs/nfs/internal.h
fs/nfs/pnfs_nfs.c
fs/nfs/write.c