Commit de23b1ed authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

nodefs: run OnMount outside of the parent treelock.

This lets you Mount multiple nodes in parallel.
parent 88b9481d
...@@ -252,12 +252,22 @@ func (c *FileSystemConnector) mountRoot(opts *Options) { ...@@ -252,12 +252,22 @@ func (c *FileSystemConnector) mountRoot(opts *Options) {
// It returns ENOENT if the directory containing the mount point does // It returns ENOENT if the directory containing the mount point does
// not exist, and EBUSY if the intended mount point already exists. // not exist, and EBUSY if the intended mount point already exists.
func (c *FileSystemConnector) Mount(parent *Inode, name string, root Node, opts *Options) fuse.Status { func (c *FileSystemConnector) Mount(parent *Inode, name string, root Node, opts *Options) fuse.Status {
node, code := c.lockMount(parent, name, root, opts)
if !code.Ok() {
return code
}
node.Node().OnMount(c)
return code
}
func (c *FileSystemConnector) lockMount(parent *Inode, name string, root Node, opts *Options) (*Inode, fuse.Status) {
defer c.verify() defer c.verify()
parent.mount.treeLock.Lock() parent.mount.treeLock.Lock()
defer parent.mount.treeLock.Unlock() defer parent.mount.treeLock.Unlock()
node := parent.children[name] node := parent.children[name]
if node != nil { if node != nil {
return fuse.EBUSY return nil, fuse.EBUSY
} }
node = newInode(true, root) node = newInode(true, root)
...@@ -274,8 +284,7 @@ func (c *FileSystemConnector) Mount(parent *Inode, name string, root Node, opts ...@@ -274,8 +284,7 @@ func (c *FileSystemConnector) Mount(parent *Inode, name string, root Node, opts
log.Printf("Mount %T on subdir %s, parent %d", node, log.Printf("Mount %T on subdir %s, parent %d", node,
name, c.inodeMap.Handle(&parent.handled)) name, c.inodeMap.Handle(&parent.handled))
} }
node.Node().OnMount(c) return node, fuse.OK
return fuse.OK
} }
// Unmount() tries to unmount the given inode. It returns EINVAL if the // Unmount() tries to unmount the given inode. It returns EINVAL if the
......
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