Linux Documentation
 help / color / mirror / Atom feed
* [PATCH 0/6] NFS: rework write congestion control
@ 2026-12-04 13:14 Jeff Layton
  2026-12-04 13:14 ` [PATCH 1/6] NFS: add tracepoints for write congestion Jeff Layton
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Jeff Layton @ 2026-12-04 13:14 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker, Benjamin Coddington,
	Jonathan Corbet, Shuah Khan, Randy Dunlap
  Cc: Jan Kara, Jeff Layton, linux-nfs, linux-doc

The NFS client limits the quantity of buffered writeback data that is
in flight to a server. Currently this limit has three problems:

- The client keeps the count in struct nfs_server, one for each
  superblock. Each mount of the same server gets a full
  nfs_congestion_kb budget. All pNFS data servers share one count with
  the MDS. If one data server is slow, writers to the other data
  servers also wait.

- The count increases when a folio starts writeback, before the client
  sends the WRITE. The count is in folios, but the limit is in pages.

- nfs_writepages() checks for congestion one time, at entry, and only
  for WB_SYNC_NONE. A writer that passes this check can then send an
  unlimited quantity of data.

After this series, the client counts the bytes in a WRITE RPC when it
sends the RPC. It charges the WRITE to the nfs_client that receives
it. Thus, mounts of the same server share one limit, and each pNFS
data server has its own limit.

The writepages loop then checks for congestion after each folio, for
all sync modes. If a WRITE went to a congested client, the writer
sends its queued requests and then waits. This wait is safe only
because the count includes only the WRITEs that the client sent
(patch 3). Requests that the writer holds in its queue cannot keep the
count high.

Users can see two changes in behavior:

- nfs_congestion_kb sets a limit for each server, not for each mount.
  With pNFS, the total in flight can be the number of data servers
  multiplied by the limit. The VM dirty limits continue to control the
  total.

- WB_SYNC_ALL writers (fsync, close, sync) also wait for congestion.
  But close() under a write delegation should not wait for congestion
  that other files cause. For this case, the new nfs_flush_nowait()
  starts writeback, stops at congestion, and queues the remaining data
  on a work item.

Results
-------
Client: 80 CPUs, 256GB RAM. Server: knfsd with 64 threads, exporting
XFS on NVMe. Link: 25GbE, 0.16ms RTT. NFSv4.2, wsize=1M. The default
nfs_congestion_kb on these hosts is 256MB. Each number is the mean of
5 runs, for the base kernel ("stock") and with this series:

                                                 stock    series
  fio 4k random write [1]
    throughput                                482MB/s   486MB/s
    max WRITE data in flight                   39.8GB     256MB
    max data under writeback                   42.2GB     9.0GB
  write + fsync, 1 x 16GB                     813MB/s   818MB/s
  write + fsync, 4 x 4GB                      979MB/s   976MB/s

  Link shaped to 2Gbit. A 64GB streaming writer on one mount, and a
  64KiB create/write/fsync/close loop on a second mount of the same
  server:
    files/s                                       3.8      15.8
    OPEN p99                                    405ms     129ms
    fsync p99                                   300ms      84ms
    max data under writeback                     44GB     1.1GB
  With both on the same mount, files/s went from 3.2 to 15.8 and OPEN
  p99 from 459ms to 118ms.

  With a knfsd changed to grant a 1GB space_limit, so that close()
  under a write delegation only starts writeback (patch 6):
    close() of a 1GB file                       3.3ms     1.1ms
    close() of a 4GB file                        13ms     1.0ms
    1GB file closed while a streaming writer
    runs: time until another client reads it     4.4s     0.43s

The costs are small:

- With an unmodified knfsd, which sends a space_limit of 0, close()
  of a large file is 3-5% slower (1GB: 1.18s to 1.24s). Patches 1-3
  alone show the same cost.

- With the 1GB space_limit and no other load, the time from close()
  until another client could read a 1GB file grew by ~20ms (0.37s to
  0.39s).

[1] The fio job from commit 2f1f31042ef0 ("nfs: Block on write
    congestion").

This patchset is a prerequisite for a follow-on patchset that I'll be
sending soon that will rework close() and delegation handling to be more
performant and CTO-friendly. That should help recover any performance
costs that we see from this series.

Please consider this for v7.6!

---
Jeff Layton (6):
      NFS: add tracepoints for write congestion
      NFS: move write congestion state to struct nfs_client
      NFS: charge write congestion at RPC submission, per target client
      NFS: throttle writeback in the writepages loop, for all sync modes
      NFS: document write congestion control and nfs_congestion_kb
      NFS: add nfs_flush_nowait()

 Documentation/admin-guide/nfs/nfs-client.rst |  46 ++++
 fs/nfs/client.c                              |   4 +-
 fs/nfs/internal.h                            |  10 +
 fs/nfs/nfs4file.c                            |   5 +-
 fs/nfs/nfstrace.h                            | 103 +++++++-
 fs/nfs/pagelist.c                            |   8 +
 fs/nfs/write.c                               | 373 ++++++++++++++++++++++++---
 include/linux/nfs_fs.h                       |   2 +
 include/linux/nfs_fs_sb.h                    |  16 +-
 include/linux/nfs_page.h                     |   2 +
 include/linux/nfs_xdr.h                      |   3 +
 11 files changed, 533 insertions(+), 39 deletions(-)
---
base-commit: 3e19991734326332c736e24c9b47b2cffb8f9e42
change-id: 20261204-nfs-write-congestion-9d4a8fabf4df

Best regards,
-- 
Jeff Layton <jlayton@kernel.org>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-12-04 17:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 13:14 [PATCH 0/6] NFS: rework write congestion control Jeff Layton
2026-12-04 13:14 ` [PATCH 1/6] NFS: add tracepoints for write congestion Jeff Layton
2026-12-04 13:14 ` [PATCH 2/6] NFS: move write congestion state to struct nfs_client Jeff Layton
2026-12-04 13:14 ` [PATCH 3/6] NFS: charge write congestion at RPC submission, per target client Jeff Layton
2026-12-04 13:14 ` [PATCH 4/6] NFS: throttle writeback in the writepages loop, for all sync modes Jeff Layton
2026-12-04 13:14 ` [PATCH 5/6] NFS: document write congestion control and nfs_congestion_kb Jeff Layton
2026-12-04 13:14 ` [PATCH 6/6] NFS: add nfs_flush_nowait() Jeff Layton
2026-12-04 17:27   ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox