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