Commit 3713ef6d authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Some paranoia changes wrt locking.

parent 2d65aab9
...@@ -411,8 +411,10 @@ func (me *FileSystemConnector) considerDropInode(n *inode) { ...@@ -411,8 +411,10 @@ func (me *FileSystemConnector) considerDropInode(n *inode) {
n.mount.treeLock.Lock() n.mount.treeLock.Lock()
defer n.mount.treeLock.Unlock() defer n.mount.treeLock.Unlock()
if n.LookupCount <= 0 && len(n.Children) == 0 && (n.mountPoint == nil || n.mountPoint.unmountPending) && dropInode := n.LookupCount <= 0 && len(n.Children) == 0 &&
n.OpenCount <= 0 { (n.mountPoint == nil || n.mountPoint.unmountPending) &&
n.OpenCount <= 0
if dropInode {
n.setParent(nil) n.setParent(nil)
me.inodeMapMutex.Lock() me.inodeMapMutex.Lock()
...@@ -517,15 +519,11 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Fil ...@@ -517,15 +519,11 @@ func (me *FileSystemConnector) Mount(mountPoint string, fs FileSystem, opts *Fil
} }
if node != me.rootNode { if node != me.rootNode {
node.mount.treeLock.RLock() node.mount.treeLock.Lock()
} defer node.mount.treeLock.Unlock()
hasChildren := len(node.Children) > 0
// don't use defer, as we don't want to hold the lock during
// fs.Mount().
if node != me.rootNode {
node.mount.treeLock.RUnlock()
} }
hasChildren := len(node.Children) > 0
if hasChildren { if hasChildren {
return EBUSY return EBUSY
} }
......
...@@ -391,11 +391,13 @@ func (me *FileSystemConnector) Flush(input *FlushIn) Status { ...@@ -391,11 +391,13 @@ func (me *FileSystemConnector) Flush(input *FlushIn) Status {
// open could have changed things. // open could have changed things.
var path string var path string
var mount *mountData var mount *mountData
b.mount.treeLock.RLock() lock := &b.mount.treeLock
lock.RLock()
if b.inode.Parent != nil { if b.inode.Parent != nil {
path, mount = b.inode.GetPath() path, mount = b.inode.GetPath()
} }
b.mount.treeLock.RUnlock() lock.RUnlock()
if mount != nil { if mount != nil {
code = mount.fs.Flush(path) code = mount.fs.Flush(path)
......
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