mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
mount: file fsync
fix https://github.com/chrislusf/seaweedfs/issues/2561
This commit is contained in:
parent
19555385f7
commit
cbc055dc2b
|
@ -114,7 +114,9 @@ func (dir *Dir) handleRenameResponse(ctx context.Context, resp *filer_pb.StreamR
|
||||||
if existingHandle, found := dir.wfs.handles[inodeId]; found && existingHandle != nil {
|
if existingHandle, found := dir.wfs.handles[inodeId]; found && existingHandle != nil {
|
||||||
glog.V(4).Infof("opened file handle %s => %s", oldPath, newPath)
|
glog.V(4).Infof("opened file handle %s => %s", oldPath, newPath)
|
||||||
delete(dir.wfs.handles, inodeId)
|
delete(dir.wfs.handles, inodeId)
|
||||||
|
existingHandle.handle = newPath.AsInode()
|
||||||
existingHandle.f.entry.Name = newName
|
existingHandle.f.entry.Name = newName
|
||||||
|
existingHandle.f.id = newPath.AsInode()
|
||||||
dir.wfs.handles[newPath.AsInode()] = existingHandle
|
dir.wfs.handles[newPath.AsInode()] = existingHandle
|
||||||
}
|
}
|
||||||
dir.wfs.handlesLock.Unlock()
|
dir.wfs.handlesLock.Unlock()
|
||||||
|
|
|
@ -248,11 +248,12 @@ func (file *File) Listxattr(ctx context.Context, req *fuse.ListxattrRequest, res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (file *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {
|
func (file *File) Fsync(ctx context.Context, req *fuse.FsyncRequest) error {
|
||||||
// fsync works at OS level
|
|
||||||
// write the file chunks to the filerGrpcAddress
|
// write the file chunks to the filerGrpcAddress
|
||||||
glog.V(4).Infof("%s/%s fsync file %+v", file.dir.FullPath(), file.Name, req)
|
glog.V(4).Infof("%s/%s fsync file %+v", file.dir.FullPath(), file.Name, req)
|
||||||
|
|
||||||
return nil
|
return file.wfs.Fsync(file, req.Header)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (file *File) Forget() {
|
func (file *File) Forget() {
|
||||||
|
|
|
@ -179,6 +179,28 @@ func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32) (fileHandle *FileHand
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (wfs *WFS) Fsync(file *File, header fuse.Header) error {
|
||||||
|
|
||||||
|
inodeId := file.Id()
|
||||||
|
|
||||||
|
wfs.handlesLock.Lock()
|
||||||
|
existingHandle, found := wfs.handles[inodeId]
|
||||||
|
wfs.handlesLock.Unlock()
|
||||||
|
|
||||||
|
if found && existingHandle != nil && existingHandle.f.isOpen > 0 {
|
||||||
|
|
||||||
|
existingHandle.Add(1)
|
||||||
|
defer existingHandle.Done()
|
||||||
|
|
||||||
|
existingHandle.Lock()
|
||||||
|
defer existingHandle.Unlock()
|
||||||
|
|
||||||
|
return existingHandle.doFlush(context.Background(), header)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (wfs *WFS) ReleaseHandle(fullpath util.FullPath, handleId fuse.HandleID) {
|
func (wfs *WFS) ReleaseHandle(fullpath util.FullPath, handleId fuse.HandleID) {
|
||||||
wfs.handlesLock.Lock()
|
wfs.handlesLock.Lock()
|
||||||
defer wfs.handlesLock.Unlock()
|
defer wfs.handlesLock.Unlock()
|
||||||
|
|
Loading…
Reference in a new issue