Commit 4e84bba2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Drop obsolete pre-GetAttr increment of lookupCount.

parent 3eef97bb
......@@ -89,11 +89,10 @@ func (me *FileSystemConnector) createChild(parent *Inode, name string, fi *os.Fi
} else {
parent.addChild(name, child)
}
me.lookupUpdate(child)
out = parent.mount.fileInfoToEntry(fi)
out.Ino = child.nodeId
out.NodeId = child.nodeId
out.Ino = me.lookupUpdate(child)
out.NodeId = out.Ino
return out
}
......@@ -115,12 +114,13 @@ func (me *FileSystemConnector) toInode(nodeid uint64) *Inode {
return i
}
// Must run in treeLock.
func (me *FileSystemConnector) lookupUpdate(node *Inode) {
// Must run in treeLock. Returns the nodeId.
func (me *FileSystemConnector) lookupUpdate(node *Inode) uint64 {
if node.lookupCount == 0 {
node.nodeId = me.inodeMap.Register(&node.handled, node)
}
node.lookupCount += 1
return node.nodeId
}
// Must run outside treeLock.
......
......@@ -32,9 +32,8 @@ func (me *FileSystemConnector) lookupMountUpdate(mount *fileSystemMount) (out *E
mount.treeLock.Lock()
defer mount.treeLock.Unlock()
me.lookupUpdate(mount.mountInode)
out = mount.fileInfoToEntry(fi)
out.NodeId = mount.mountInode.nodeId
out.NodeId = me.lookupUpdate(mount.mountInode)
out.Ino = out.NodeId
// We don't do NFS.
out.Generation = 1
......@@ -67,8 +66,6 @@ func (me *FileSystemConnector) preLookup(parent *Inode, name string) (lookupNode
child := parent.children[name]
if child != nil {
// Make sure the child doesn't die inbetween.
me.lookupUpdate(child)
return nil, child
}
......@@ -85,10 +82,6 @@ func (me *FileSystemConnector) postLookup(fi *os.FileInfo, fsNode FsNode, code S
}
if !code.Ok() {
if attrNode != nil {
me.forgetUpdate(attrNode, 1)
}
if code == ENOENT && mount.options.NegativeTimeout > 0.0 {
return mount.negativeEntry(), OK
}
......@@ -96,6 +89,7 @@ func (me *FileSystemConnector) postLookup(fi *os.FileInfo, fsNode FsNode, code S
}
if attrNode != nil {
me.lookupUpdate(attrNode)
out = attrNode.mount.fileInfoToEntry(fi)
out.Generation = 1
out.NodeId = attrNode.nodeId
......
......@@ -42,7 +42,8 @@ type Inode struct {
// The nodeId is only used to communicate to the kernel. If
// it is zero, it means the kernel does not know about this
// Inode. nodeIds are chosen by FileSystemConnector.inodeMap.
// Inode. You should probably never read nodeId, but always
// do lookupUpdate() on the node instead.
nodeId uint64
// lookupCount registers how often the kernel got this inode
......
......@@ -78,6 +78,12 @@ func TestMultiZipFs(t *testing.T) {
t.Errorf("expected %v got %v", zipFile, val)
}
fi, err = os.Lstat(mountPoint + "/zipmount")
CheckSuccess(err)
if !fi.IsDirectory() {
t.Fatal("expect directory for /zipmount, got %v", fi)
}
// Check that zipfs itself works.
fi, err = os.Stat(mountPoint + "/zipmount/subdir")
CheckSuccess(err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment