Gaspare Iengo
7 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with
29 additions and
6 deletions
-
weed/mount/inode_to_path.go
-
weed/mount/weedfs.go
-
weed/mount/weedfs_file_sync.go
|
|
@ -114,9 +114,9 @@ func (i *InodeToPath) AllocateInode(path util.FullPath, unixTime int64) uint64 { |
|
|
|
return inode |
|
|
|
} |
|
|
|
|
|
|
|
func (i *InodeToPath) GetInode(path util.FullPath) uint64 { |
|
|
|
func (i *InodeToPath) GetInode(path util.FullPath) (uint64, bool) { |
|
|
|
if path == "/" { |
|
|
|
return 1 |
|
|
|
return 1, true |
|
|
|
} |
|
|
|
i.Lock() |
|
|
|
defer i.Unlock() |
|
|
@ -125,7 +125,7 @@ func (i *InodeToPath) GetInode(path util.FullPath) uint64 { |
|
|
|
// glog.Fatalf("GetInode unknown inode for %s", path)
|
|
|
|
// this could be the parent for mount point
|
|
|
|
} |
|
|
|
return inode |
|
|
|
return inode, found |
|
|
|
} |
|
|
|
|
|
|
|
func (i *InodeToPath) GetPath(inode uint64) (util.FullPath, fuse.Status) { |
|
|
|
|
|
@ -105,6 +105,29 @@ func NewSeaweedFileSystem(option *Option) *WFS { |
|
|
|
}, func(path util.FullPath) bool { |
|
|
|
return wfs.inodeToPath.IsChildrenCached(path) |
|
|
|
}, func(filePath util.FullPath, entry *filer_pb.Entry) { |
|
|
|
// Find inode if it is not a deleted path
|
|
|
|
if inode, inode_found := wfs.inodeToPath.GetInode(filePath); inode_found { |
|
|
|
// Find open file handle
|
|
|
|
if fh, fh_found := wfs.fhmap.FindFileHandle(inode); fh_found { |
|
|
|
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("invalidateFunc", fh.fh, util.ExclusiveLock) |
|
|
|
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock) |
|
|
|
|
|
|
|
fh.entryLock.Lock() |
|
|
|
defer fh.entryLock.Unlock() |
|
|
|
|
|
|
|
// Recreate dirty pages
|
|
|
|
fh.dirtyPages.Destroy() |
|
|
|
fh.dirtyPages = newPageWriter(fh, wfs.option.ChunkSizeLimit) |
|
|
|
|
|
|
|
// Update handle entry
|
|
|
|
newentry, status := wfs.maybeLoadEntry(filePath) |
|
|
|
if status == fuse.OK { |
|
|
|
if fh.GetEntry() != newentry { |
|
|
|
fh.SetEntry(newentry) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
grace.OnInterrupt(func() { |
|
|
|
wfs.metaCache.Shutdown() |
|
|
|
|
|
@ -104,9 +104,6 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("doFlush", fh.fh, util.ExclusiveLock) |
|
|
|
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock) |
|
|
|
|
|
|
|
if !fh.dirtyMetadata { |
|
|
|
return fuse.OK |
|
|
|
} |
|
|
@ -115,6 +112,9 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status { |
|
|
|
return fuse.Status(syscall.ENOSPC) |
|
|
|
} |
|
|
|
|
|
|
|
fhActiveLock := fh.wfs.fhLockTable.AcquireLock("doFlush", fh.fh, util.ExclusiveLock) |
|
|
|
defer fh.wfs.fhLockTable.ReleaseLock(fh.fh, fhActiveLock) |
|
|
|
|
|
|
|
err := wfs.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error { |
|
|
|
fh.entryLock.Lock() |
|
|
|
defer fh.entryLock.Unlock() |
|
|
|