Skip to content
This repository has been archived by the owner on Feb 12, 2019. It is now read-only.

Commit

Permalink
libfuse: on macOS, delete a moved node from the nodes cache
Browse files Browse the repository at this point in the history
Otherwise, the kernel might still treat it as having the old parent
ID.

This shouldn't mess up any kernel caching or libkbfs garbage
collection, since if the original node for the moved node is still in
use, bazil.org would hold a reference to it.

But it's definitely a little weird that the same node might have two
inodes pointing into it.  We should remove this once the osxfuse issue
is fixed.

Issue: #1881
Issue: KBFS-3576
Issue: macfuse/macfuse#553
  • Loading branch information
strib committed Nov 6, 2018
1 parent 4dcbacd commit 72e913e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
17 changes: 17 additions & 0 deletions libfuse/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"math"
"os"
"runtime"
"strings"
"sync"
"syscall"
Expand Down Expand Up @@ -731,6 +732,22 @@ func (d *Dir) Rename(ctx context.Context, req *fuse.RenameRequest,

switch e := err.(type) {
case nil:
// Because of https://github.com/osxfuse/osxfuse/issues/553, a
// node that's moved to a different directory needs to get a
// new Node object (and inode) on the next lookup. The
// easiest way to do that is to remove the moved node from
// this folder's local cache. See KBFS-3576.
if runtime.GOOS == "darwin" &&
d.node.GetID() != realNewDir.node.GetID() {
movedNode, _, err := d.folder.fs.config.KBFSOps().Lookup(
ctx, realNewDir.node, req.NewName)
if err == nil {
d.folder.nodesMu.Lock()
delete(d.folder.nodes, movedNode.GetID())
d.folder.nodesMu.Unlock()
}
}

return nil
case libkbfs.RenameAcrossDirsError:
var execPathErr error
Expand Down
3 changes: 2 additions & 1 deletion libfuse/mount_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3931,7 +3931,8 @@ func TestInodes(t *testing.T) {
syncFilename(t, p2)

inode2 := getInode(p2)
if inode != inode2 {
if runtime.GOOS != "darwin" && inode != inode2 {
// (See KBFS-3576 for the darwin restriction here.)
t.Fatalf("Inode changed after rename: %d vs %d", inode, inode2)
}

Expand Down

0 comments on commit 72e913e

Please sign in to comment.