SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
make a copy of request data
Chris Lu006f78b70b45
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.goindex 18544a7f11..ea53ed4c0b 100644--- a/weed/filesys/filehandle.go+++ b/weed/filesys/filehandle.go@@ -114,21 +114,23 @@ func (fh *FileHandle) readFromChunks(buff []byte, offset int64) (int64, error) {func (fh *FileHandle) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.WriteResponse) error {// write the request to volume servers+ data := make([]byte, len(req.Data))+ copy(data, req.Data)- fh.f.entry.Attributes.FileSize = uint64(max(req.Offset+int64(len(req.Data)), int64(fh.f.entry.Attributes.FileSize)))+ fh.f.entry.Attributes.FileSize = uint64(max(req.Offset+int64(len(data)), int64(fh.f.entry.Attributes.FileSize)))// glog.V(0).Infof("%v write [%d,%d)", fh.f.fullpath(), req.Offset, req.Offset+int64(len(req.Data)))- chunks, err := fh.dirtyPages.AddPage(req.Offset, req.Data)+ chunks, err := fh.dirtyPages.AddPage(req.Offset, data)if err != nil {- glog.Errorf("%v write fh %d: [%d,%d): %v", fh.f.fullpath(), fh.handle, req.Offset, req.Offset+int64(len(req.Data)), err)+ glog.Errorf("%v write fh %d: [%d,%d): %v", fh.f.fullpath(), fh.handle, req.Offset, req.Offset+int64(len(data)), err)return fuse.EIO}- resp.Size = len(req.Data)+ resp.Size = len(data)if req.Offset == 0 {// detect mime type- detectedMIME := mimetype.Detect(req.Data)+ detectedMIME := mimetype.Detect(data)fh.contentType = detectedMIME.String()if ext := path.Ext(fh.f.Name); ext != detectedMIME.Extension() {fh.contentType = mime.TypeByExtension(ext)@@ -159,6 +161,8 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err}fh.f.entryViewCache = nilfh.f.reader = nil+ fh.dirtyPages = nil+ fh.f = nilreturn nil}