aboutsummaryrefslogtreecommitdiff
path: root/weed/mount/inode_to_path.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-02-27 23:13:49 -0800
committerchrislu <chris.lu@gmail.com>2022-02-27 23:13:49 -0800
commit63a9d8f01d0e2fc487dc242a5dcb9649f92d963c (patch)
tree4d45aa015d4c2747b02c5d5ed8fe67ce73b3b2c8 /weed/mount/inode_to_path.go
parentde77d00c81152681b5a5c649b123989d2093dcc6 (diff)
downloadseaweedfs-63a9d8f01d0e2fc487dc242a5dcb9649f92d963c.tar.xz
seaweedfs-63a9d8f01d0e2fc487dc242a5dcb9649f92d963c.zip
ensure inodes are not duplicating unless hardlinked
Diffstat (limited to 'weed/mount/inode_to_path.go')
-rw-r--r--weed/mount/inode_to_path.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/weed/mount/inode_to_path.go b/weed/mount/inode_to_path.go
index 1e914dccd..91934a4a8 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