Skip to content

nfsd: never wait for a layout break with an nfsd thread held in COPY - #31

Merged
mxsrc merged 1 commit into
pnfs-minimalfrom
fix/copy-file-range-layout-break
Nov 2, 2026
Merged

mxsrc merged 1 commit into
pnfs-minimalfrom
fix/copy-file-range-layout-break

Conversation

@mxsrc

@mxsrc mxsrc commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

What

nfsd_copy_file_range (fs/nfsd/vfs.c) is missing the non-blocking layout-break
guard that commit 3448b03 (nfsd: never wait for a layout break with an nfsd thread held) added to nfsd_setattr, nfsd4_vfs_fallocate, and
nfsd_vfs_write. A server-side COPY into a file that still carries another
client's pNFS write layout breaks that layout the same way a write does, and
the filesystem waits for it with the calling thread held.

For a synchronous COPY this reproduces the bug 3448b03 fixed, bounded by
nfsd's layout-recall timeout. For an asynchronous COPY it does not: the copy
runs in its own kthread (nfsd4_do_async_copy), so nothing times it out, the
kthread never reaches nfsd4_send_cb_offload, and the client's
handle_async_copy waits for CB_OFFLOAD that never arrives. The wait is
uninterruptible, so the thread and its OS thread leak permanently, and every
later operation on the same mount blocks behind it.

First seen as an S3 CompleteMultipartUpload that never returned: the
gateway's join of two uploaded parts is a copy_file_range against the
destination object's file, which still carried the write layout its own
preceding writes had taken out on it. Every pNFS ReadWriteMany consumer is
exposed; an ordinary cp between two files on the same mount reaches the
same code path.

Fix

nfsd_copy_file_range now calls break_layout(file_inode(dst), false) before
the copy, like the other three sites. nfsd4_do_copy already turns a
negative return into an NFS4 error for both the synchronous and the
asynchronous caller, so no further plumbing is needed.

Verification

Not yet run against a booted guest. This patch is written against this
repository's local Linux 6.14 reference tree as a stand-in for the actual
6.18.55 base, since that source was not available to build or boot against
while preparing this. break_layout(inode, bool wait) is not defined by any
patch in this series — it must already exist in the 6.18.55 base, since
3448b03 calls it with the same signature — so this patch only adds a fourth
call site in the same idiom, but the context around it should be checked
against the real source before merging, and the hang reproduction (cp
between two files on a pNFS RWX mount while the destination holds an open
write layout) should be run against a built guest once the test deployment
for this is ready.

Full investigation: pnfs-copy-offload-hang.md in simplyblock-operator
(branch copy-file-range).

…n COPY

A COPY into a file that still carries another client's pNFS write layout
breaks that layout the same way an ordinary write does, and XFS waits for
it with the calling thread held. Commit 3448b03 (pnfs-common: nfsd never
waits for a layout break with a thread held) fixed this for nfsd_setattr,
nfsd4_vfs_fallocate, and nfsd_vfs_write, but never reached
nfsd_copy_file_range, which has the identical hazard.

A synchronous COPY merely reproduces the bug 3448b03 fixed, bounded by
nfsd's own layout-recall timeout. An asynchronous COPY does not: it runs in
its own kthread rather than an nfsd thread, so the wait never times out,
the kthread never reaches nfsd4_send_cb_offload, and the client's wait for
CB_OFFLOAD in handle_async_copy never ends -- an uninterruptible wait that
leaks the thread and its OS thread permanently.

First seen as an S3 CompleteMultipartUpload that never returned: the join
of two uploaded parts is a copy_file_range against the destination
object's file, which still carried the write layout the gateway's own
preceding writes had taken out on it. Every pNFS ReadWriteMany consumer is
equally exposed, since an ordinary cp between two files on the same pNFS
mount reaches the same copy_file_range.

nfsd_copy_file_range now starts the break without waiting, like 3448b03's
other three sites, and returns the error instead of blocking.
nfsd4_do_copy already turns a negative return into an NFS4 error for both
the synchronous and the asynchronous caller, so no further plumbing is
needed.
@mxsrc
mxsrc requested a review from noctarius November 2, 2026 13:01
@mxsrc
mxsrc merged commit 16e6390 into pnfs-minimal Nov 2, 2026
1 check passed
@mxsrc
mxsrc deleted the fix/copy-file-range-layout-break branch November 2, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants