From 3aeee3d748712d4c1afa5eacd4f12939f8173afa Mon Sep 17 00:00:00 2001 From: chrislu Date: Mon, 7 Mar 2022 14:01:24 -0800 Subject: [PATCH] ensure releasing file handle --- weed/mount/filehandle.go | 4 ++++ weed/mount/filehandle_map.go | 2 ++ weed/mount/page_writer/upload_pipeline.go | 3 +++ 3 files changed, 9 insertions(+) diff --git a/weed/mount/filehandle.go b/weed/mount/filehandle.go index 770e89a10..86fbabfa7 100644 --- a/weed/mount/filehandle.go +++ b/weed/mount/filehandle.go @@ -88,6 +88,10 @@ func (fh *FileHandle) addChunks(chunks []*filer_pb.FileChunk) { fh.chunkAddLock.Unlock() } +func (fh *FileHandle) Release() { + fh.dirtyPages.Destroy() +} + func lessThan(a, b *filer_pb.FileChunk) bool { if a.Mtime == b.Mtime { return a.Fid.FileKey < b.Fid.FileKey diff --git a/weed/mount/filehandle_map.go b/weed/mount/filehandle_map.go index 80cfd02c7..a8af391af 100644 --- a/weed/mount/filehandle_map.go +++ b/weed/mount/filehandle_map.go @@ -61,6 +61,7 @@ func (i *FileHandleToInode) ReleaseByInode(inode uint64) { if fh.counter <= 0 { delete(i.inode2fh, inode) delete(i.fh2inode, fh.fh) + fh.Release() } } } @@ -77,6 +78,7 @@ func (i *FileHandleToInode) ReleaseByHandle(fh FileHandleId) { if fhHandle.counter <= 0 { delete(i.inode2fh, inode) delete(i.fh2inode, fhHandle.fh) + fhHandle.Release() } } diff --git a/weed/mount/page_writer/upload_pipeline.go b/weed/mount/page_writer/upload_pipeline.go index e439f39a3..3ed966de4 100644 --- a/weed/mount/page_writer/upload_pipeline.go +++ b/weed/mount/page_writer/upload_pipeline.go @@ -179,4 +179,7 @@ func (up *UploadPipeline) moveToSealed(memChunk PageChunk, logicChunkIndex Logic } func (up *UploadPipeline) Shutdown() { + for logicChunkIndex, sealedChunk := range up.sealedChunks { + sealedChunk.FreeReference(fmt.Sprintf("%s uploadpipeline shutdown chunk %d", up.filepath, logicChunkIndex)) + } }