Skip to content

nfs3: set eof on a READ that ends at or past the end of the file - #186

Merged
kofemann merged 1 commit into
dCache:masterfrom
rafaelhutter:nfs3-read-eof-past-end
Nov 7, 2026
Merged

kofemann merged 1 commit into
dCache:masterfrom
rafaelhutter:nfs3-read-eof-past-end

Conversation

@rafaelhutter

Copy link
Copy Markdown
Contributor

Motivation

NFSPROC3_READ_3 sets eof only when offset + count == size. A READ that starts past the end of the file returns 0 bytes with eof=false. RFC 1813 (READ3resok) says that such a read is at eof.

A client that still holds an older, larger size for an open file repeats that READ forever. We see this with the Windows NFS client: it reads up to the size that it cached at open, gets 0 bytes and no eof, and asks again. The mount then hangs.

Modification

Set eof when offset + count >= size.

Result

A READ at or past the end of the file reports eof. The new NfsServerV3READ_3Test covers a read before the end (no eof), a read up to the end (eof) and a read past the end (eof). Without this change, the past-the-end test fails.

NFSv4 is not affected, because OperationREAD gets eof from VirtualFileSystem.read.

Target: master

Motivation:
NFSPROC3_READ_3 sets eof only when offset + count is exactly the file
size. A READ that starts past the end returns 0 bytes with eof=false,
although RFC 1813 says such a read is at eof. A client that still holds
a larger, older size (Windows NFS client) then repeats that READ
forever.

Modification:
Set eof when offset + count is equal to or greater than the size.

Result:
A READ at or past the end of the file reports eof.

Target: master
Signed-off-by: Rafael Hutter <r.hutter@moovit.de>
@kofemann

kofemann commented Nov 7, 2026

Copy link
Copy Markdown
Member

@rafaelhutter Thank you for the contribution.

@kofemann
kofemann merged commit c231be5 into dCache:master Nov 7, 2026
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