also writes to local meta cache

before waiting for subscribed meta events
This commit is contained in:
Chris Lu 2020-04-22 15:40:47 -07:00
parent 1a34fd0b44
commit 5d0e1d8d74
4 changed files with 37 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/chrislusf/seaweedfs/weed/util" "github.com/chrislusf/seaweedfs/weed/util"
@ -137,6 +138,11 @@ func (dir *Dir) Create(ctx context.Context, req *fuse.CreateRequest,
} }
return fuse.EIO return fuse.EIO
} }
if dir.wfs.option.AsyncMetaDataCaching {
dir.wfs.metaCache.InsertEntry(context.Background(), filer2.FromPbEntry(request.Directory, request.Entry))
}
return nil return nil
}); err != nil { }); err != nil {
return nil, nil, err return nil, nil, err
@ -184,6 +190,10 @@ func (dir *Dir) Mkdir(ctx context.Context, req *fuse.MkdirRequest) (fs.Node, err
return err return err
} }
if dir.wfs.option.AsyncMetaDataCaching {
dir.wfs.metaCache.InsertEntry(context.Background(), filer2.FromPbEntry(request.Directory, request.Entry))
}
return nil return nil
}) })
@ -320,6 +330,10 @@ func (dir *Dir) removeOneFile(req *fuse.RemoveRequest) error {
return fuse.ENOENT return fuse.ENOENT
} }
if dir.wfs.option.AsyncMetaDataCaching {
dir.wfs.metaCache.DeleteEntry(context.Background(), filePath)
}
return nil return nil
} }
@ -336,6 +350,11 @@ func (dir *Dir) removeFolder(req *fuse.RemoveRequest) error {
glog.V(3).Infof("not found remove %s/%s: %v", dir.FullPath(), req.Name, err) glog.V(3).Infof("not found remove %s/%s: %v", dir.FullPath(), req.Name, err)
return fuse.ENOENT return fuse.ENOENT
} }
if dir.wfs.option.AsyncMetaDataCaching {
dir.wfs.metaCache.DeleteEntry(context.Background(), t)
}
return nil return nil
} }
@ -458,6 +477,10 @@ func (dir *Dir) saveEntry() error {
return fuse.EIO return fuse.EIO
} }
if dir.wfs.option.AsyncMetaDataCaching {
dir.wfs.metaCache.UpdateEntry(context.Background(), filer2.FromPbEntry(request.Directory, request.Entry))
}
return nil return nil
}) })
} }

View file

@ -6,6 +6,7 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/glog" "github.com/chrislusf/seaweedfs/weed/glog"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb" "github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/fuse" "github.com/seaweedfs/fuse"
@ -40,6 +41,11 @@ func (dir *Dir) Symlink(ctx context.Context, req *fuse.SymlinkRequest) (fs.Node,
glog.V(0).Infof("symlink %s/%s: %v", dir.FullPath(), req.NewName, err) glog.V(0).Infof("symlink %s/%s: %v", dir.FullPath(), req.NewName, err)
return fuse.EIO return fuse.EIO
} }
if dir.wfs.option.AsyncMetaDataCaching {
dir.wfs.metaCache.InsertEntry(context.Background(), filer2.FromPbEntry(request.Directory, request.Entry))
}
return nil return nil
}) })

View file

@ -279,6 +279,10 @@ func (file *File) saveEntry() error {
return fuse.EIO return fuse.EIO
} }
if file.wfs.option.AsyncMetaDataCaching {
file.wfs.metaCache.UpdateEntry(context.Background(), filer2.FromPbEntry(request.Directory, request.Entry))
}
return nil return nil
}) })
} }

View file

@ -209,6 +209,10 @@ func (fh *FileHandle) Flush(ctx context.Context, req *fuse.FlushRequest) error {
return fmt.Errorf("fh flush create %s: %v", fh.f.fullpath(), err) return fmt.Errorf("fh flush create %s: %v", fh.f.fullpath(), err)
} }
if fh.f.wfs.option.AsyncMetaDataCaching {
fh.f.wfs.metaCache.InsertEntry(context.Background(), filer2.FromPbEntry(request.Directory, request.Entry))
}
fh.f.wfs.deleteFileChunks(garbages) fh.f.wfs.deleteFileChunks(garbages)
for i, chunk := range garbages { for i, chunk := range garbages {
glog.V(3).Infof("garbage %s chunks %d: %v [%d,%d)", fh.f.fullpath(), i, chunk.FileId, chunk.Offset, chunk.Offset+int64(chunk.Size)) glog.V(3).Infof("garbage %s chunks %d: %v [%d,%d)", fh.f.fullpath(), i, chunk.FileId, chunk.Offset, chunk.Offset+int64(chunk.Size))