Skip to content

Commit

Permalink
Fix condition in PFSAgent where DoSetAttr() needs to speculatively re…
Browse files Browse the repository at this point in the history
…ference a fileInode

Unfortunately, the sanity check enforced that fileInode.reference() was only called from DoWrite()
where fileInode.references *WOULD* always be non-zero.

This change switches DoSetAttr() to instead use the referenceFileInode() func to increment the
fileInode.references... possibly from zero. The fact that it will cause a fileInode to be created in
the very small chance it was removed just after DoSetAttr() found it but before the call to
referenceFileInode() is ok... no damage will be done.
  • Loading branch information
edmc-ss committed Aug 14, 2020
1 parent 90f3eae commit 7170246
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pfsagentd/fission.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,14 @@ func (dummy *globalsStruct) DoSetAttr(inHeader *fission.InHeader, setAttrIn *fis
globals.Unlock()

if cachedFileInodeCase {
fileInode.reference()
// Calling referenceFileInode() here even though we "know" fileInode to avoid the
// sanity check otherwise valid where fileInode.references should not be zero.
//
// Note that, to avoid any race ambiguity, we will use the fileInode returned
// from referenceFileInode() moving forward on the off-chance the one we fetched
// from globals.fileInodeMap was removed just after the globals.Unlock() call.

fileInode = referenceFileInode(inode.InodeNumber(inHeader.NodeID))

fileInode.doFlushIfNecessary()
}
Expand Down

0 comments on commit 7170246

Please sign in to comment.