diff --git a/weed/filesys/file.go b/weed/filesys/file.go index 3bffa156e..a2b6660d8 100644 --- a/weed/filesys/file.go +++ b/weed/filesys/file.go @@ -91,6 +91,9 @@ func (file *File) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp func (file *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { glog.V(4).Infof("file %v open %+v", file.fullpath(), req) + if USE_DIRECT_IO { + resp.Flags |= fuse.OpenDirectIO + } handle := file.wfs.AcquireHandle(file, req.Uid, req.Gid) diff --git a/weed/filesys/file_darwin.go b/weed/filesys/file_darwin.go new file mode 100644 index 000000000..b8806cff7 --- /dev/null +++ b/weed/filesys/file_darwin.go @@ -0,0 +1,8 @@ +//+build darwin + +package filesys + +const ( + USE_DIRECT_IO = false +) + diff --git a/weed/filesys/file_other.go b/weed/filesys/file_other.go new file mode 100644 index 000000000..8a8693511 --- /dev/null +++ b/weed/filesys/file_other.go @@ -0,0 +1,7 @@ +//+build !darwin + +package filesys + +const ( + USE_DIRECT_IO = true +) diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go index d5f6cc38e..6225ab968 100644 --- a/weed/filesys/filehandle.go +++ b/weed/filesys/filehandle.go @@ -90,8 +90,9 @@ func (fh *FileHandle) Read(ctx context.Context, req *fuse.ReadRequest, resp *fus glog.Warningf("%s FileHandle Read %d: [%d,%d) size %d totalRead %d", fh.f.fullpath(), fh.handle, req.Offset, req.Offset+int64(req.Size), req.Size, totalRead) totalRead = min(int64(len(buff)), totalRead) } - // resp.Data = buff[:totalRead] - resp.Data = buff + if err == nil { + resp.Data = buff[:totalRead] + } return err }