mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refresh cached file entry from sync metadata updates
This commit is contained in:
parent
46cb692d83
commit
10a4a628e9
|
@ -253,7 +253,7 @@ func (file *File) Forget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (file *File) maybeLoadEntry(ctx context.Context) error {
|
func (file *File) maybeLoadEntry(ctx context.Context) error {
|
||||||
if (file.entry == nil || len(file.entry.HardLinkId) != 0) && file.isOpen <= 0 {
|
if (len(file.entry.HardLinkId) != 0) && file.isOpen <= 0 {
|
||||||
entry, err := file.wfs.maybeLoadEntry(file.dir.FullPath(), file.Name)
|
entry, err := file.wfs.maybeLoadEntry(file.dir.FullPath(), file.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(3).Infof("maybeLoadEntry file %s/%s: %v", file.dir.FullPath(), file.Name, err)
|
glog.V(3).Infof("maybeLoadEntry file %s/%s: %v", file.dir.FullPath(), file.Name, err)
|
||||||
|
|
|
@ -70,6 +70,7 @@ func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath uti
|
||||||
// skip the unnecessary deletion
|
// skip the unnecessary deletion
|
||||||
// leave the update to the following InsertEntry operation
|
// leave the update to the following InsertEntry operation
|
||||||
} else {
|
} else {
|
||||||
|
glog.V(3).Infof("DeleteEntry %s/%s", oldPath,oldPath.Name())
|
||||||
if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil {
|
if err := mc.localStore.DeleteEntry(ctx, oldPath); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -82,6 +83,7 @@ func (mc *MetaCache) AtomicUpdateEntryFromFiler(ctx context.Context, oldPath uti
|
||||||
if newEntry != nil {
|
if newEntry != nil {
|
||||||
newDir, _ := newEntry.DirAndName()
|
newDir, _ := newEntry.DirAndName()
|
||||||
if mc.visitedBoundary.HasVisited(util.FullPath(newDir)) {
|
if mc.visitedBoundary.HasVisited(util.FullPath(newDir)) {
|
||||||
|
glog.V(3).Infof("InsertEntry %s/%s", newDir,newEntry.Name())
|
||||||
if err := mc.localStore.InsertEntry(ctx, newEntry); err != nil {
|
if err := mc.localStore.InsertEntry(ctx, newEntry); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,11 +119,13 @@ func (wfs *WFS) AcquireHandle(file *File, uid, gid uint32) (fileHandle *FileHand
|
||||||
defer wfs.handlesLock.Unlock()
|
defer wfs.handlesLock.Unlock()
|
||||||
|
|
||||||
inodeId := file.fullpath().AsInode()
|
inodeId := file.fullpath().AsInode()
|
||||||
|
if file.isOpen > 0 {
|
||||||
existingHandle, found := wfs.handles[inodeId]
|
existingHandle, found := wfs.handles[inodeId]
|
||||||
if found && existingHandle != nil {
|
if found && existingHandle != nil {
|
||||||
file.isOpen++
|
file.isOpen++
|
||||||
return existingHandle
|
return existingHandle
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fileHandle = newFileHandle(file, uid, gid)
|
fileHandle = newFileHandle(file, uid, gid)
|
||||||
file.maybeLoadEntry(context.Background())
|
file.maybeLoadEntry(context.Background())
|
||||||
|
|
Loading…
Reference in a new issue