Commit 01d1fc58 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Drop mounts map from Inode.

parent 7a452b92
......@@ -106,16 +106,6 @@ func (c *FileSystemConnector) childLookup(out *raw.EntryOut, fsi FsNode) {
}
}
func (c *FileSystemConnector) findMount(parent *Inode, name string) (mount *fileSystemMount) {
parent.treeLock.RLock()
if parent.mounts != nil {
mount = parent.mounts[name]
}
parent.treeLock.RUnlock()
return
}
func (c *FileSystemConnector) toInode(nodeid uint64) *Inode {
if nodeid == raw.FUSE_ROOT_ID {
return c.rootNode
......@@ -287,10 +277,6 @@ func (c *FileSystemConnector) Mount(parent *Inode, name string, nodeFs NodeFileS
node.mount.connector = c
parent.addChild(name, node)
if parent.mounts == nil {
parent.mounts = make(map[string]*fileSystemMount)
}
parent.mounts[name] = node.mountPoint
node.mountPoint.parentInode = parent
if c.Debug {
log.Println("Mount: ", nodeFs, "on subdir", name,
......@@ -335,7 +321,6 @@ func (c *FileSystemConnector) Unmount(node *Inode) Status {
mount.mountInode = nil
mountInode.mountPoint = nil
delete(parentNode.mounts, name)
delete(parentNode.children, name)
mount.fs.OnUnmount()
......
......@@ -46,8 +46,8 @@ type fileSystemMount struct {
// Must called with lock for parent held.
func (m *fileSystemMount) mountName() string {
for k, v := range m.parentInode.mounts {
if m == v {
for k, v := range m.parentInode.children {
if m.mountInode == v {
return k
}
}
......
......@@ -45,11 +45,11 @@ func (c *FileSystemConnector) lookupMountUpdate(out *Attr, mount *fileSystemMoun
}
func (c *FileSystemConnector) internalLookup(out *Attr, parent *Inode, name string, context *Context) (node *Inode, code Status) {
if subMount := c.findMount(parent, name); subMount != nil {
return c.lookupMountUpdate(out, subMount)
child := parent.GetChild(name)
if child != nil && child.mountPoint != nil {
return c.lookupMountUpdate(out, child.mountPoint)
}
child := parent.GetChild(name)
if child != nil {
parent = nil
}
......@@ -259,8 +259,9 @@ func (c *FileSystemConnector) Symlink(out *raw.EntryOut, header *raw.InHeader, p
func (c *FileSystemConnector) Rename(header *raw.InHeader, input *raw.RenameIn, oldName string, newName string) (code Status) {
oldParent := c.toInode(header.NodeId)
isMountPoint := c.findMount(oldParent, oldName) != nil
if isMountPoint {
child := oldParent.GetChild(oldName)
if child.mountPoint != nil {
return EBUSY
}
......
......@@ -39,10 +39,6 @@ type Inode struct {
// All data below is protected by treeLock.
children map[string]*Inode
// Contains directories that function as mounts. The entries
// are duplicated in children.
mounts map[string]*fileSystemMount
// The nodeId is only used to communicate to the kernel. If
// it is zero, it means the kernel does not know about this
// Inode. You should probably never read nodeId, but always
......@@ -224,12 +220,14 @@ func (n *Inode) canUnmount() bool {
func (n *Inode) getMountDirEntries() (out []DirEntry) {
n.treeLock.RLock()
for k := range n.mounts {
for k, v := range n.children {
if v.mountPoint != nil {
out = append(out, DirEntry{
Name: k,
Mode: S_IFDIR,
})
}
}
n.treeLock.RUnlock()
return out
......@@ -257,13 +255,6 @@ func (n *Inode) verify(cur *fileSystemMount) {
log.Panicf("n.mount not set correctly %v %v", n.mount, cur)
}
for name, m := range n.mounts {
if m.mountInode != n.children[name] {
log.Panicf("mountpoint parent mismatch: node:%v name:%v ch:%v",
n.mountPoint, name, n.children)
}
}
for nm, ch := range n.children {
if ch == nil {
log.Panicf("Found nil child: %q", nm)
......
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