From 71624858afaa5ceb879c2e81e7c4fd7357879c25 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Fri, 23 Oct 2020 11:31:57 -0700 Subject: [PATCH] avoid reusing cached []byte this logic is just to ensure 100% correct. fuse message, data+message hearder > 512 will not be cached. --- weed/filesys/filehandle.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index e3163117c..a0e994bf9 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -143,6 +143,11 @@ func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *f // write the request to volume servers data := req.Data + if len(data) <= 512 { + // fuse message cacheable size + data = make([]byte, len(req.Data)) + copy(data, req.Data) + } fh.f.entry.Attributes.FileSize = uint64(max(req.Offset+int64(len(data)), int64(fh.f.entry.Attributes.FileSize))) glog.V(4).Infof("%v write [%d,%d) %d", fh.f.fullpath(), req.Offset, req.Offset+int64(len(req.Data)), len(req.Data))