mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
* mount: read an open file's extended attributes under its entry lock getxattr and listxattr on an open file read the Extended map of the handle's live entry with no lock, while setxattr and removexattr change that map in place. Go ends the process on a concurrent map read and write, so weed mount exits with "fatal error: concurrent map read and map write" (GetXAttr) or "concurrent map iteration and map write" (ListXAttr), and every file open on the mount returns ENOTCONN. The kernel asks for security.capability on each write(), so a program that writes a file while another process sets or removes its attributes reaches this. The entry's own lock, LockedEntry.RWMutex, is the one every other writer of the handle's entry takes: truncate to zero, the metadata merges of a flush, SetEntry and the acknowledged-attribute retention. setxattr and removexattr changed the map under the handle lock and entryLock only. They now also take the entry lock, in the documented order after those two, and re-read the handle's entry under it, as SetAttr does, in case SetEntry swapped it. GetXAttr and ListXAttr read the handle's current entry under the entry's read lock and copy what they return before releasing it. The read lock is a leaf: it waits for no other lock and does not wait for the handle lock, so a getxattr is not held up by a write in progress. TestXAttrReadsAgainstSetAndRemoveOnOpenFile and TestXAttrReadsAgainstTruncateToZeroOnOpenFile abort the test binary with the fatal errors above without the change, and all three race tests report data races under -race. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mount: remove the attributes the xattr race test sets The writer of TestXAttrReadsAgainstSetAndRemoveOnOpenFile set even keys and removed odd ones, so every RemoveXAttr found no key and returned ENOATTR before deleting anything. Each name is now set and then removed, and both calls must succeed. With RemoveXAttr's entry lock taken out, -race reports its delete against GetXAttr's read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>