diff options
| -rw-r--r-- | weed/command/volume.go | 2 | ||||
| -rw-r--r-- | weed/mount/inode_to_path.go | 24 | ||||
| -rw-r--r-- | weed/mount/weedfs_dir_lookup.go | 2 | ||||
| -rw-r--r-- | weed/mount/weedfs_dir_mkrm.go | 2 | ||||
| -rw-r--r-- | weed/mount/weedfs_dir_read.go | 4 | ||||
| -rw-r--r-- | weed/mount/weedfs_file_mkrm.go | 6 | ||||
| -rw-r--r-- | weed/mount/weedfs_file_sync.go | 3 | ||||
| -rw-r--r-- | weed/mount/weedfs_forget.go | 1 | ||||
| -rw-r--r-- | weed/mount/weedfs_link.go | 2 | ||||
| -rw-r--r-- | weed/replication/repl_util/replication_util.go | 2 |
10 files changed, 34 insertions, 14 deletions
diff --git a/weed/command/volume.go b/weed/command/volume.go index 20935bf16..df67bf447 100644 --- a/weed/command/volume.go +++ b/weed/command/volume.go @@ -94,7 +94,7 @@ func init() { v.pprof = cmdVolume.Flag.Bool("pprof", false, "enable pprof http handlers. precludes --memprofile and --cpuprofile") v.metricsHttpPort = cmdVolume.Flag.Int("metricsPort", 0, "Prometheus metrics listen port") v.idxFolder = cmdVolume.Flag.String("dir.idx", "", "directory to store .idx files") - v.enableTcp = cmdVolume.Flag.Bool("tcp", false, "<exprimental> enable tcp port") + v.enableTcp = cmdVolume.Flag.Bool("tcp", false, "<experimental> enable tcp port") } var cmdVolume = &Command{ diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go index 1e914dccd..1e2126b74 100644 --- a/weed/mount/inode_to_path.go +++ b/weed/mount/inode_to_path.go @@ -31,18 +31,20 @@ func NewInodeToPath() *InodeToPath { return t } -func (i *InodeToPath) Lookup(path util.FullPath, mode os.FileMode, isCreate bool, possibleInode uint64, isLookup bool) uint64 { +func (i *InodeToPath) Lookup(path util.FullPath, mode os.FileMode, isHardlink bool, possibleInode uint64, isLookup bool) uint64 { i.Lock() defer i.Unlock() inode, found := i.path2inode[path] if !found { if possibleInode == 0 { inode = path.AsInode(mode) + } else { + inode = possibleInode + } + if !isHardlink { for _, found := i.inode2path[inode]; found; inode++ { _, found = i.inode2path[inode] } - } else { - inode = possibleInode } } i.path2inode[path] = inode @@ -62,6 +64,19 @@ func (i *InodeToPath) Lookup(path util.FullPath, mode os.FileMode, isCreate bool return inode } +func (i *InodeToPath) AllocateInode(path util.FullPath, mode os.FileMode) uint64 { + if path == "/" { + return 1 + } + i.Lock() + defer i.Unlock() + inode := path.AsInode(mode) + for _, found := i.inode2path[inode]; found; inode++ { + _, found = i.inode2path[inode] + } + return inode +} + func (i *InodeToPath) GetInode(path util.FullPath) uint64 { if path == "/" { return 1 @@ -172,7 +187,8 @@ func (i *InodeToPath) Forget(inode, nlookup uint64, onForgetDir func(dir util.Fu } i.Unlock() if found { - if path.isDirectory && onForgetDir != nil { + if path.isDirectory && path.nlookup <= 0 && onForgetDir != nil { + path.isChildrenCached = false onForgetDir(path.FullPath) } } diff --git a/weed/mount/weedfs_dir_lookup.go b/weed/mount/weedfs_dir_lookup.go index d7e6d8a30..7f2821a94 100644 --- a/weed/mount/weedfs_dir_lookup.go +++ b/weed/mount/weedfs_dir_lookup.go @@ -53,7 +53,7 @@ func (wfs *WFS) Lookup(cancel <-chan struct{}, header *fuse.InHeader, name strin return fuse.ENOENT } - inode := wfs.inodeToPath.Lookup(fullFilePath, localEntry.Mode, false, localEntry.Inode, true) + inode := wfs.inodeToPath.Lookup(fullFilePath, localEntry.Mode, len(localEntry.HardLinkId) > 0, localEntry.Inode, true) if fh, found := wfs.fhmap.FindFileHandle(inode); found { glog.V(4).Infof("lookup opened file %s size %d", dirPath.Child(localEntry.Name()), filer.FileSize(fh.entry)) diff --git a/weed/mount/weedfs_dir_mkrm.go b/weed/mount/weedfs_dir_mkrm.go index 9cf968baf..b23245555 100644 --- a/weed/mount/weedfs_dir_mkrm.go +++ b/weed/mount/weedfs_dir_mkrm.go @@ -74,7 +74,7 @@ func (wfs *WFS) Mkdir(cancel <-chan struct{}, in *fuse.MkdirIn, name string, out return fuse.EIO } - inode := wfs.inodeToPath.Lookup(entryFullPath, os.ModeDir, true, 0, true) + inode := wfs.inodeToPath.Lookup(entryFullPath, os.ModeDir, false, 0, true) wfs.outputPbEntry(out, inode, newEntry) diff --git a/weed/mount/weedfs_dir_read.go b/weed/mount/weedfs_dir_read.go index 4862167dc..f7cbae7f7 100644 --- a/weed/mount/weedfs_dir_read.go +++ b/weed/mount/weedfs_dir_read.go @@ -162,14 +162,14 @@ func (wfs *WFS) doReadDirectory(input *fuse.ReadIn, out *fuse.DirEntryList, isPl dirEntry.Name = entry.Name() dirEntry.Mode = toSyscallMode(entry.Mode) if !isPlusMode { - inode := wfs.inodeToPath.Lookup(dirPath.Child(dirEntry.Name), entry.Mode, false, entry.Inode, false) + inode := wfs.inodeToPath.Lookup(dirPath.Child(dirEntry.Name), entry.Mode, len(entry.HardLinkId) > 0, entry.Inode, false) dirEntry.Ino = inode if !out.AddDirEntry(dirEntry) { isEarlyTerminated = true return false } } else { - inode := wfs.inodeToPath.Lookup(dirPath.Child(dirEntry.Name), entry.Mode, false, entry.Inode, true) + inode := wfs.inodeToPath.Lookup(dirPath.Child(dirEntry.Name), entry.Mode, len(entry.HardLinkId) > 0, entry.Inode, true) dirEntry.Ino = inode entryOut := out.AddDirLookupEntry(dirEntry) if entryOut == nil { diff --git a/weed/mount/weedfs_file_mkrm.go b/weed/mount/weedfs_file_mkrm.go index b679d8178..52e15bc53 100644 --- a/weed/mount/weedfs_file_mkrm.go +++ b/weed/mount/weedfs_file_mkrm.go @@ -46,6 +46,7 @@ func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out entryFullPath := dirFullPath.Child(name) fileMode := toOsFileMode(in.Mode) + inode := wfs.inodeToPath.AllocateInode(entryFullPath, fileMode) newEntry := &filer_pb.Entry{ Name: name, @@ -60,7 +61,7 @@ func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out Replication: wfs.option.Replication, TtlSec: wfs.option.TtlSec, Rdev: in.Rdev, - Inode: entryFullPath.AsInode(fileMode), + Inode: inode, }, } @@ -94,7 +95,8 @@ func (wfs *WFS) Mknod(cancel <-chan struct{}, in *fuse.MknodIn, name string, out return fuse.EIO } - inode := wfs.inodeToPath.Lookup(entryFullPath, newEntry.FileMode(), true, 0, true) + // this is to increase nlookup counter + inode = wfs.inodeToPath.Lookup(entryFullPath, fileMode, false, inode, true) wfs.outputPbEntry(out, inode, newEntry) diff --git a/weed/mount/weedfs_file_sync.go b/weed/mount/weedfs_file_sync.go index 8fb7c73b4..4c6dda6eb 100644 --- a/weed/mount/weedfs_file_sync.go +++ b/weed/mount/weedfs_file_sync.go @@ -96,7 +96,7 @@ func (wfs *WFS) Fsync(cancel <-chan struct{}, in *fuse.FsyncIn) (code fuse.Statu func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status { // flush works at fh level fileFullPath := fh.FullPath() - dir, _ := fileFullPath.DirAndName() + dir, name := fileFullPath.DirAndName() // send the data to the OS glog.V(4).Infof("doFlush %s fh %d", fileFullPath, fh.handle) @@ -115,6 +115,7 @@ func (wfs *WFS) doFlush(fh *FileHandle, uid, gid uint32) fuse.Status { if entry == nil { return nil } + entry.Name = name // this flush may be just after a rename operation if entry.Attributes != nil { entry.Attributes.Mime = fh.contentType diff --git a/weed/mount/weedfs_forget.go b/weed/mount/weedfs_forget.go index 62946b216..4212adeb6 100644 --- a/weed/mount/weedfs_forget.go +++ b/weed/mount/weedfs_forget.go @@ -65,4 +65,5 @@ func (wfs *WFS) Forget(nodeid, nlookup uint64) { wfs.inodeToPath.Forget(nodeid, nlookup, func(dir util.FullPath) { wfs.metaCache.DeleteFolderChildren(context.Background(), dir) }) + wfs.fhmap.ReleaseByInode(nodeid) } diff --git a/weed/mount/weedfs_link.go b/weed/mount/weedfs_link.go index 99d19cf4d..9468b1fb1 100644 --- a/weed/mount/weedfs_link.go +++ b/weed/mount/weedfs_link.go @@ -97,7 +97,7 @@ func (wfs *WFS) Link(cancel <-chan struct{}, in *fuse.LinkIn, name string, out * return fuse.EIO } - inode := wfs.inodeToPath.Lookup(newEntryPath, oldEntry.FileMode(), false, oldEntry.Attributes.Inode, true) + inode := wfs.inodeToPath.Lookup(newEntryPath, oldEntry.FileMode(), true, oldEntry.Attributes.Inode, true) wfs.outputPbEntry(out, inode, request.Entry) diff --git a/weed/replication/repl_util/replication_util.go b/weed/replication/repl_util/replication_util.go index 519a9a201..f135e6210 100644 --- a/weed/replication/repl_util/replication_util.go +++ b/weed/replication/repl_util/replication_util.go @@ -20,7 +20,7 @@ func CopyFromChunkViews(chunkViews []*filer.ChunkView, filerSource *source.Filer var shouldRetry bool for _, fileUrl := range fileUrls { - shouldRetry, err = util.ReadUrlAsStream(fileUrl, nil, false, chunk.IsFullChunk(), chunk.Offset, int(chunk.Size), func(data []byte) { + shouldRetry, err = util.ReadUrlAsStream(fileUrl, chunk.CipherKey, chunk.IsGzipped, chunk.IsFullChunk(), chunk.Offset, int(chunk.Size), func(data []byte) { writeErr = writeFunc(data) }) if err != nil { |
