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