diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-01-26 02:50:50 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-01-26 02:50:53 -0800 |
| commit | 3a1d3d3413c5fc6a49c138ed5024f2b907f63d37 (patch) | |
| tree | 387c4e7e4e559942d9bd1d4cfeee1d23599e209f /weed/filesys | |
| parent | c41961d5cccf4a4b49e5968e0da283c6fb1f47c3 (diff) | |
| download | seaweedfs-3a1d3d3413c5fc6a49c138ed5024f2b907f63d37.tar.xz seaweedfs-3a1d3d3413c5fc6a49c138ed5024f2b907f63d37.zip | |
mount: properly invalidate kernel node cache entry
fix https://github.com/chrislusf/seaweedfs/issues/1752
Diffstat (limited to 'weed/filesys')
| -rw-r--r-- | weed/filesys/dir.go | 16 | ||||
| -rw-r--r-- | weed/filesys/file.go | 7 | ||||
| -rw-r--r-- | weed/filesys/file_darwin.go | 8 | ||||
| -rw-r--r-- | weed/filesys/file_other.go | 7 | ||||
| -rw-r--r-- | weed/filesys/wfs.go | 14 |
5 files changed, 23 insertions, 29 deletions
diff --git a/weed/filesys/dir.go b/weed/filesys/dir.go index 3d0a00a8b..e3d0057db 100644 --- a/weed/filesys/dir.go +++ b/weed/filesys/dir.go @@ -58,7 +58,7 @@ func (dir *Dir) Attr(ctx context.Context, attr *fuse.Attr) error { return err } - attr.Inode = util.FullPath(dir.FullPath()).AsInode() + // attr.Inode = util.FullPath(dir.FullPath()).AsInode() attr.Mode = os.FileMode(dir.entry.Attributes.FileMode) | os.ModeDir attr.Mtime = time.Unix(dir.entry.Attributes.Mtime, 0) attr.Crtime = time.Unix(dir.entry.Attributes.Crtime, 0) @@ -82,8 +82,8 @@ func (dir *Dir) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp *f } func (dir *Dir) setRootDirAttributes(attr *fuse.Attr) { - attr.Inode = 1 // filer2.FullPath(dir.Path).AsInode() - attr.Valid = time.Hour + // attr.Inode = 1 // filer2.FullPath(dir.Path).AsInode() + attr.Valid = time.Second attr.Uid = dir.wfs.option.MountUid attr.Gid = dir.wfs.option.MountGid attr.Mode = dir.wfs.option.MountMode @@ -91,7 +91,7 @@ func (dir *Dir) setRootDirAttributes(attr *fuse.Attr) { attr.Ctime = dir.wfs.option.MountCtime attr.Mtime = dir.wfs.option.MountMtime attr.Atime = dir.wfs.option.MountMtime - attr.BlockSize = 1024 * 1024 + attr.BlockSize = blockSize } func (dir *Dir) Fsync(ctx context.Context, req *fuse.FsyncRequest) error { @@ -285,7 +285,7 @@ func (dir *Dir) Lookup(ctx context.Context, req *fuse.LookupRequest, resp *fuse. } // resp.EntryValid = time.Second - resp.Attr.Inode = fullFilePath.AsInode() + // resp.Attr.Inode = fullFilePath.AsInode() resp.Attr.Valid = time.Second resp.Attr.Mtime = time.Unix(entry.Attributes.Mtime, 0) resp.Attr.Crtime = time.Unix(entry.Attributes.Crtime, 0) @@ -308,13 +308,11 @@ func (dir *Dir) ReadDirAll(ctx context.Context) (ret []fuse.Dirent, err error) { glog.V(4).Infof("dir ReadDirAll %s", dir.FullPath()) processEachEntryFn := func(entry *filer_pb.Entry, isLast bool) error { - fullpath := util.NewFullPath(dir.FullPath(), entry.Name) - inode := fullpath.AsInode() if entry.IsDirectory { - dirent := fuse.Dirent{Inode: inode, Name: entry.Name, Type: fuse.DT_Dir} + dirent := fuse.Dirent{Name: entry.Name, Type: fuse.DT_Dir} ret = append(ret, dirent) } else { - dirent := fuse.Dirent{Inode: inode, Name: entry.Name, Type: findFileType(uint16(entry.Attributes.FileMode))} + dirent := fuse.Dirent{Name: entry.Name, Type: findFileType(uint16(entry.Attributes.FileMode))} ret = append(ret, dirent) } return nil diff --git a/weed/filesys/file.go b/weed/filesys/file.go index a8d6dac29..a210c5152 100644 --- a/weed/filesys/file.go +++ b/weed/filesys/file.go @@ -45,7 +45,7 @@ func (file *File) fullpath() util.FullPath { func (file *File) Attr(ctx context.Context, attr *fuse.Attr) (err error) { - glog.V(4).Infof("file Attr %s, open:%v, existing attr: %+v", file.fullpath(), file.isOpen, attr) + glog.V(4).Infof("file Attr %s, open:%v existing:%v", file.fullpath(), file.isOpen, attr) entry := file.entry if file.isOpen <= 0 || entry == nil { @@ -54,7 +54,7 @@ func (file *File) Attr(ctx context.Context, attr *fuse.Attr) (err error) { } } - attr.Inode = file.fullpath().AsInode() + // attr.Inode = file.fullpath().AsInode() attr.Valid = time.Second attr.Mode = os.FileMode(entry.Attributes.FileMode) attr.Size = filer.FileSize(entry) @@ -91,9 +91,6 @@ func (file *File) Getxattr(ctx context.Context, req *fuse.GetxattrRequest, resp func (file *File) Open(ctx context.Context, req *fuse.OpenRequest, resp *fuse.OpenResponse) (fs.Handle, error) { glog.V(4).Infof("file %v open %+v", file.fullpath(), req) - if USE_DIRECT_IO { - resp.Flags |= fuse.OpenDirectIO - } handle := file.wfs.AcquireHandle(file, req.Uid, req.Gid) diff --git a/weed/filesys/file_darwin.go b/weed/filesys/file_darwin.go deleted file mode 100644 index b8806cff7..000000000 --- a/weed/filesys/file_darwin.go +++ /dev/null @@ -1,8 +0,0 @@ -//+build darwin - -package filesys - -const ( - USE_DIRECT_IO = false -) - diff --git a/weed/filesys/file_other.go b/weed/filesys/file_other.go deleted file mode 100644 index 8a8693511..000000000 --- a/weed/filesys/file_other.go +++ /dev/null @@ -1,7 +0,0 @@ -//+build !darwin - -package filesys - -const ( - USE_DIRECT_IO = true -) diff --git a/weed/filesys/wfs.go b/weed/filesys/wfs.go index 6cfadcc18..108e23c85 100644 --- a/weed/filesys/wfs.go +++ b/weed/filesys/wfs.go @@ -76,6 +76,7 @@ type WFS struct { // throttle writers concurrentWriters *util.LimitedConcurrentExecutor + Server *fs.Server } type statsCache struct { filer_pb.StatisticsResponse @@ -104,9 +105,22 @@ func NewSeaweedFileSystem(option *Option) *WFS { fsNode := wfs.fsNodeCache.GetFsNode(filePath) if fsNode != nil { if file, ok := fsNode.(*File); ok { + if err := wfs.Server.InvalidateNodeData(file); err != nil { + glog.V(4).Infof("InvalidateNodeData %s : %v", filePath, err) + } file.clearEntry() } } + dir, name := filePath.DirAndName() + parent := wfs.root + if dir != "/" { + parent = wfs.fsNodeCache.GetFsNode(util.FullPath(dir)) + } + if parent != nil { + if err := wfs.Server.InvalidateEntry(parent, name); err != nil { + glog.V(4).Infof("InvalidateEntry %s : %v", filePath, err) + } + } }) startTime := time.Now() go meta_cache.SubscribeMetaEvents(wfs.metaCache, wfs.signature, wfs, wfs.option.FilerMountRootPath, startTime.UnixNano()) |
