Skip to content

fix(fs): keep other nodes' changes when setattr writes an inode - #102

Merged
mattmattox merged 1 commit into
mainfrom
fix/setattr-under-lock
Nov 13, 2026
Merged

mattmattox merged 1 commit into
mainfrom
fix/setattr-under-lock

Conversation

@mattmattox

Copy link
Copy Markdown
Contributor

Found while checking whether #84 fixed the root create write-back (it did).

  • chmod/chown/utimes on a directory wrote back a stale inode, losing another node's concurrent create or mkdir (link count, mtime). It now uses updateInodeLocked.
  • File setattr lost another node's append inside an allocated block: the size changed but the extents didn't, so the stale-extent check missed it. It now writes only if the inode's generation is unchanged (Table.WriteIfUnchanged) and retries otherwise. It can't hold the inode lock across a truncate, which allocates tree blocks.
On .68 fix reverted this PR
TestDirSetattrKeepsOtherNodesMkdir fails 3/3 passes 5/5
TestFileSetattrKeepsOtherNodesSize fails 3/3 passes 5/5
make lint; unit tests; -race on inode and goclusterfs clean; pass; pass

Integration tests weren't run locally: another session held the .68 host lock.

🤖 Generated with Claude Code

chmod, chown and utimes on a directory read and wrote its inode without
the cluster lock, so a create or mkdir on another node in between lost
its link count and mtime. They now hold the inode lock from read to
write.

File setattr had the same gap: an append inside an allocated block on
another node changes the size but not the extents, so the stale-extent
check let setattr write the old size back. It now writes only if the
inode's generation is unchanged since its read, and retries otherwise.
It cannot hold the inode lock across a truncate, which allocates tree
blocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattmattox
mattmattox merged commit 34500f1 into main Nov 13, 2026
13 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