Browse Source

mount: use direct_io to avoid OS page cache

fix https://github.com/chrislusf/seaweedfs/issues/1752
pull/1759/head
Chris Lu 4 years ago
parent
commit
20ef3bb8d4
  1. 3
      weed/filesys/file.go
  2. 8
      weed/filesys/file_darwin.go
  3. 7
      weed/filesys/file_other.go
  4. 5
      weed/filesys/filehandle.go

3
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)

8
weed/filesys/file_darwin.go

@ -0,0 +1,8 @@
//+build darwin
package filesys
const (
USE_DIRECT_IO = false
)

7
weed/filesys/file_other.go

@ -0,0 +1,7 @@
//+build !darwin
package filesys
const (
USE_DIRECT_IO = true
)

5
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
}

Loading…
Cancel
Save