Skip to content

fix(fs): open a stale file node as ESTALE, and let O_CREAT open a name made since the lookup - #159

Merged
mattmattox merged 3 commits into
mainfrom
fix/open-errors
Nov 16, 2026
Merged

mattmattox merged 3 commits into
mainfrom
fix/open-errors

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Two of the history checker's findings (#156), fixed before the unlink-while-open fix lands.

  • EISDIR from open. A file node can outlive its inode when another caller unlinks the file, or when the slot goes to a new inode. File.Open mapped that to EISDIR (a freed inode has mode 0), and Getattr returned the freed inode's attributes. Both now return ESTALE, on which Linux redoes the lookup once with revalidation. Getattr still answers for a file that has links 0 but is in use, because fstat of a descriptor needs that once unlinked-while-open files are kept.
  • EEXIST from open(O_CREAT) without O_EXCL. The kernel sends CREATE when its lookup found no name. If another node or thread made the name in between, the create failed with EEXIST. It now opens the file it finds, honoring O_TRUNC.
On .68 main d7f5420 this PR
TestStaleFileNodeOpensAsStale fails (EISDIR; getattr OK on a freed inode) passes
TestCreateWithoutExclOpensTheFileItFinds fails (EEXIST) passes
lint; unit; -race goclusterfs; integration -short clean; pass; pass; 127/0/14

🤖 Generated with Claude Code

mattmattox and others added 3 commits November 16, 2026 11:13
…e made since the lookup

A file node can outlive its inode when another caller unlinks the file or
the slot goes to a new inode. File.Open mapped that to EISDIR and
Getattr returned the freed inode's attributes. Both now return ESTALE,
on which the kernel looks the name up again.

The kernel sends CREATE when its lookup found no name. If another node or
thread made the name in between, the create failed with EEXIST even
without O_EXCL. It now opens the file it finds, honoring O_TRUNC.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eeds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	tests/test-manifest.yaml
@mattmattox
mattmattox merged commit 1414f66 into main Nov 16, 2026
17 checks passed
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.

1 participant