forked from StarfishStorage/goofys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoofys.patch
66 lines (61 loc) · 1.76 KB
/
goofys.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
diff --git a/internal/goofys.go b/internal/goofys.go
index 8ff0955..fb9cf20 100644
--- a/internal/goofys.go
+++ b/internal/goofys.go
@@ -683,7 +683,11 @@ func (fs *Goofys) insertInode(parent *Inode, inode *Inode) {
if inode.Id != 0 {
panic(fmt.Sprintf("inode id is set: %v %v", *inode.Name, inode.Id))
}
- inode.Id = fs.allocateInodeId()
+ // inode.Id = fs.allocateInodeId()
+ inode.Id = fuseops.InodeID(makeInodeID(*inode.FullName()))
+ fuseLog.Debugf("new inode %d", inode.Id)
+
+
addInode = true
}
parent.insertChildUnlocked(inode)
diff --git a/internal/handles.go b/internal/handles.go
index cffa7de..a798d8a 100644
--- a/internal/handles.go
+++ b/internal/handles.go
@@ -15,7 +15,7 @@
package internal
import (
- "fmt"
+ //"fmt"
"net/url"
"os"
"sort"
@@ -246,7 +246,11 @@ func (inode *Inode) DeRef(n uint64) (stale bool) {
inode.logFuse("DeRef", n, inode.refcnt)
if inode.refcnt < n {
- panic(fmt.Sprintf("deref %v from %v", n, inode.refcnt))
+ inode.logFuse("Double DeRef race: (-%d from %d)", n, inode.refcnt)
+ inode.refcnt = 0
+ stale = true
+ return
+ // panic(fmt.Sprintf("deref %v from %v", n, inode.refcnt))
}
inode.refcnt -= n
diff --git a/internal/utils.go b/internal/utils.go
index 1a36b1d..fd8ace2 100644
--- a/internal/utils.go
+++ b/internal/utils.go
@@ -21,6 +21,7 @@ import (
"github.com/jacobsa/fuse"
"github.com/shirou/gopsutil/process"
+ "hash/fnv"
)
var TIME_MAX = time.Unix(1<<63-62135596801, 999999999)
@@ -176,3 +177,10 @@ func GetTgid(pid uint32) (tgid *int32, err error) {
}
return &tgidVal, nil
}
+
+// use hash of name as inode modulo 2^63
+func makeInodeID(path string) uint64 {
+ hash := fnv.New64a()
+ hash.Write([]byte(path))
+ return hash.Sum64()
+}