Skip to content

Commit

Permalink
Fix attr's returns when doing truncate --size to extend a file
Browse files Browse the repository at this point in the history
  • Loading branch information
Ed McClanahan committed Feb 21, 2020
1 parent bd2b76e commit bd5e5ff
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pfsagentd/fission.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ func (dummy *globalsStruct) DoSetAttr(inHeader *fission.InHeader, setAttrIn *fis
chownRequest *jrpcfs.ChownRequest
chunkedPutContext *chunkedPutContextStruct
chunkedPutContextElement *list.Element
chunkedPutContextLast *chunkedPutContextStruct
err error
fileInode *fileInodeStruct
getStatReply *jrpcfs.StatStruct
Expand Down Expand Up @@ -459,6 +460,8 @@ func (dummy *globalsStruct) DoSetAttr(inHeader *fission.InHeader, setAttrIn *fis

pruneExtentMap(fileInode.extentMap, setAttrIn.Size)

chunkedPutContextLast = nil

chunkedPutContextElement = fileInode.chunkedPutList.Front()

for nil != chunkedPutContextElement {
Expand All @@ -467,6 +470,8 @@ func (dummy *globalsStruct) DoSetAttr(inHeader *fission.InHeader, setAttrIn *fis
logFatalf("chunkedPutContextElement.Value.(*chunkedPutContextStruct) returned !ok")
}

chunkedPutContextLast = chunkedPutContext

if chunkedPutContext.fileSize > setAttrIn.Size {
chunkedPutContext.fileSize = setAttrIn.Size
}
Expand All @@ -476,6 +481,16 @@ func (dummy *globalsStruct) DoSetAttr(inHeader *fission.InHeader, setAttrIn *fis
chunkedPutContextElement = chunkedPutContextElement.Next()
}

if nil == chunkedPutContextLast {
if fileInode.extentMapFileSize < setAttrIn.Size {
fileInode.extentMapFileSize = setAttrIn.Size
}
} else {
if chunkedPutContext.fileSize < setAttrIn.Size {
chunkedPutContext.fileSize = setAttrIn.Size
}
}

resizeRequest = &jrpcfs.ResizeRequest{
InodeHandle: jrpcfs.InodeHandle{
MountID: globals.mountID,
Expand Down

0 comments on commit bd5e5ff

Please sign in to comment.