aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-08-19 01:27:10 -0700
committerChris Lu <chris.lu@gmail.com>2020-08-19 01:27:10 -0700
commit839634097f680ccbd1bfc3cfa7889fa2c71aec7e (patch)
tree79b16f30188f72fe5e0c8d72cd91270222157dc2
parentc27e18aa6a1c17190816d95876e45093646d477a (diff)
downloadseaweedfs-839634097f680ccbd1bfc3cfa7889fa2c71aec7e.tar.xz
seaweedfs-839634097f680ccbd1bfc3cfa7889fa2c71aec7e.zip
also do flush on release
-rw-r--r--weed/filesys/filehandle.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/weed/filesys/filehandle.go b/weed/filesys/filehandle.go
index fa31cd81b..9186eddbb 100644
--- a/weed/filesys/filehandle.go
+++ b/weed/filesys/filehandle.go
@@ -165,6 +165,7 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err
fh.f.isOpen--
if fh.f.isOpen <= 0 {
+ fh.doFlush(ctx, req.Header)
fh.dirtyPages.releaseResource()
fh.f.wfs.ReleaseHandle(fh.f.fullpath(), fuse.HandleID(fh.handle))
fh.f.entryViewCache = nil
@@ -175,9 +176,13 @@ func (fh *FileHandle) Release(ctx context.Context, req *fuse.ReleaseRequest) err
}
func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
+ return fh.doFlush(ctx, req.Header)
+}
+
+func (fh *FileHandle) doFlush(ctx context.Context, header fuse.Header) error {
// fflush works at fh level
// send the data to the OS
- glog.V(5).Infof("Flush %s fh %d %v", fh.f.fullpath(), fh.handle, req)
+ glog.V(4).Infof("doFlush %s fh %d %v", fh.f.fullpath(), fh.handle, header)
chunks, err := fh.dirtyPages.FlushToStorage()
if err != nil {
@@ -199,10 +204,10 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
if fh.f.entry.Attributes != nil {
fh.f.entry.Attributes.Mime = fh.contentType
if fh.f.entry.Attributes.Uid == 0 {
- fh.f.entry.Attributes.Uid = req.Uid
+ fh.f.entry.Attributes.Uid = header.Uid
}
if fh.f.entry.Attributes.Gid == 0 {
- fh.f.entry.Attributes.Gid = req.Gid
+ fh.f.entry.Attributes.Gid = header.Gid
}
if fh.f.entry.Attributes.Crtime == 0 {
fh.f.entry.Attributes.Crtime = time.Now().Unix()