Commit 23d26623 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Only decrement openWritable if the original file was writable to begin

with.

This fixes premature reaping of the backing store.
parent 531281a7
...@@ -57,10 +57,13 @@ func (me *MemUnionFs) OnMount(conn *fuse.FileSystemConnector) { ...@@ -57,10 +57,13 @@ func (me *MemUnionFs) OnMount(conn *fuse.FileSystemConnector) {
me.connector = conn me.connector = conn
} }
func (me *MemUnionFs) release() { func (me *MemUnionFs) markCloseWrite() {
me.mutex.Lock() me.mutex.Lock()
defer me.mutex.Unlock() defer me.mutex.Unlock()
me.openWritable-- me.openWritable--
if me.openWritable < 0 {
log.Panicf("openWritable Underflow")
}
me.cond.Broadcast() me.cond.Broadcast()
} }
...@@ -436,12 +439,15 @@ func (me *memNodeFile) Release() { ...@@ -436,12 +439,15 @@ func (me *memNodeFile) Release() {
// Must do the subfile release first, as that may flush data // Must do the subfile release first, as that may flush data
// to disk. // to disk.
me.File.Release() me.File.Release()
me.node.fs.release() if me.writable {
me.node.fs.markCloseWrite()
}
} }
func (me *memNodeFile) Flush() fuse.Status { func (me *memNodeFile) Flush() fuse.Status {
code := me.File.Flush() code := me.File.Flush()
if me.writable { if me.writable {
// TODO - should this be in Release?
fi, _ := me.File.GetAttr() fi, _ := me.File.GetAttr()
me.node.mutex.Lock() me.node.mutex.Lock()
......
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