From bd5e5ff220b404f5976a5222977ed92f621c1301 Mon Sep 17 00:00:00 2001 From: Ed McClanahan Date: Fri, 21 Feb 2020 15:13:40 -0800 Subject: [PATCH] Fix attr's returns when doing `truncate --size` to extend a file --- pfsagentd/fission.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pfsagentd/fission.go b/pfsagentd/fission.go index 2a0542f09..be146d738 100644 --- a/pfsagentd/fission.go +++ b/pfsagentd/fission.go @@ -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 @@ -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 { @@ -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 } @@ -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,