Fixed flushfs for writback caching.
commit
b0a4566c53
|
@ -90,6 +90,29 @@ func (fs *flushFS) barAttributes() fuseops.InodeAttributes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LOCKS_REQUIRED(fs.mu)
|
||||||
|
func (fs *flushFS) getAttributes(id fuseops.InodeID) (
|
||||||
|
attrs fuseops.InodeAttributes,
|
||||||
|
err error) {
|
||||||
|
switch id {
|
||||||
|
case fuseops.RootInodeID:
|
||||||
|
attrs = fs.rootAttributes()
|
||||||
|
return
|
||||||
|
|
||||||
|
case fooID:
|
||||||
|
attrs = fs.fooAttributes()
|
||||||
|
return
|
||||||
|
|
||||||
|
case barID:
|
||||||
|
attrs = fs.barAttributes()
|
||||||
|
return
|
||||||
|
|
||||||
|
default:
|
||||||
|
err = fuse.ENOENT
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// FileSystem methods
|
// FileSystem methods
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -134,23 +157,20 @@ func (fs *flushFS) GetInodeAttributes(
|
||||||
fs.mu.Lock()
|
fs.mu.Lock()
|
||||||
defer fs.mu.Unlock()
|
defer fs.mu.Unlock()
|
||||||
|
|
||||||
switch op.Inode {
|
op.Attributes, err = fs.getAttributes(op.Inode)
|
||||||
case fuseops.RootInodeID:
|
|
||||||
op.Attributes = fs.rootAttributes()
|
|
||||||
return
|
return
|
||||||
|
}
|
||||||
|
|
||||||
case fooID:
|
func (fs *flushFS) SetInodeAttributes(
|
||||||
op.Attributes = fs.fooAttributes()
|
ctx context.Context,
|
||||||
return
|
op *fuseops.SetInodeAttributesOp) (err error) {
|
||||||
|
fs.mu.Lock()
|
||||||
|
defer fs.mu.Unlock()
|
||||||
|
|
||||||
case barID:
|
// Ignore any changes and simply return existing attributes.
|
||||||
op.Attributes = fs.barAttributes()
|
op.Attributes, err = fs.getAttributes(op.Inode)
|
||||||
return
|
|
||||||
|
|
||||||
default:
|
|
||||||
err = fuse.ENOENT
|
|
||||||
return
|
return
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *flushFS) OpenFile(
|
func (fs *flushFS) OpenFile(
|
||||||
|
|
|
@ -590,6 +590,8 @@ func (t *NoErrorsTest) Mmap_NoMsync_MunmapBeforeClose() {
|
||||||
syscall.MAP_SHARED)
|
syscall.MAP_SHARED)
|
||||||
|
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
defer syscall.Munmap(data)
|
||||||
|
|
||||||
AssertEq("taco", string(data))
|
AssertEq("taco", string(data))
|
||||||
|
|
||||||
// Modify the contents.
|
// Modify the contents.
|
||||||
|
@ -638,6 +640,8 @@ func (t *NoErrorsTest) Mmap_NoMsync_CloseBeforeMunmap() {
|
||||||
syscall.MAP_SHARED)
|
syscall.MAP_SHARED)
|
||||||
|
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
defer syscall.Munmap(data)
|
||||||
|
|
||||||
AssertEq("taco", string(data))
|
AssertEq("taco", string(data))
|
||||||
|
|
||||||
// Close the file. We should see a flush.
|
// Close the file. We should see a flush.
|
||||||
|
@ -682,6 +686,8 @@ func (t *NoErrorsTest) Mmap_WithMsync_MunmapBeforeClose() {
|
||||||
syscall.MAP_SHARED)
|
syscall.MAP_SHARED)
|
||||||
|
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
defer syscall.Munmap(data)
|
||||||
|
|
||||||
AssertEq("taco", string(data))
|
AssertEq("taco", string(data))
|
||||||
|
|
||||||
// Modify the contents.
|
// Modify the contents.
|
||||||
|
@ -738,6 +744,8 @@ func (t *NoErrorsTest) Mmap_WithMsync_CloseBeforeMunmap() {
|
||||||
syscall.MAP_SHARED)
|
syscall.MAP_SHARED)
|
||||||
|
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
defer syscall.Munmap(data)
|
||||||
|
|
||||||
AssertEq("taco", string(data))
|
AssertEq("taco", string(data))
|
||||||
|
|
||||||
// Close the file. We should see a flush.
|
// Close the file. We should see a flush.
|
||||||
|
@ -941,6 +949,7 @@ func (t *FsyncErrorTest) Msync() {
|
||||||
syscall.MAP_SHARED)
|
syscall.MAP_SHARED)
|
||||||
|
|
||||||
AssertEq(nil, err)
|
AssertEq(nil, err)
|
||||||
|
defer syscall.Munmap(data)
|
||||||
|
|
||||||
// msync the mapping.
|
// msync the mapping.
|
||||||
err = msync(data)
|
err = msync(data)
|
||||||
|
|
Loading…
Reference in New Issue