Commit 39b429e7 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: Add MountOptions.SingleThreaded.

parent a3347006
...@@ -57,9 +57,12 @@ type MountOptions struct { ...@@ -57,9 +57,12 @@ type MountOptions struct {
// This may be useful for NFS. // This may be useful for NFS.
RememberInodes bool RememberInodes bool
// The Name will show up on the output of the mount. Keep this string // The name will show up on the output of the mount. Keep this string
// small. // small.
Name string Name string
// If set, wrap the file system in a single-threaded wrapper.
SingleThreaded bool
} }
// RawFileSystem is an interface close to the FUSE wire protocol. // RawFileSystem is an interface close to the FUSE wire protocol.
......
...@@ -78,6 +78,9 @@ func (ms *Server) RecordLatencies(l LatencyMap) { ...@@ -78,6 +78,9 @@ func (ms *Server) RecordLatencies(l LatencyMap) {
ms.latencies = l ms.latencies = l
} }
// Unmount calls fusermount -u on the mount. This has the effect of
// shutting down the filesystem. After the Server is unmounted, it
// should be discarded.
func (ms *Server) Unmount() (err error) { func (ms *Server) Unmount() (err error) {
if ms.mountPoint == "" { if ms.mountPoint == "" {
return nil return nil
...@@ -112,6 +115,10 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server ...@@ -112,6 +115,10 @@ func NewServer(fs RawFileSystem, mountPoint string, opts *MountOptions) (*Server
} }
} }
o := *opts o := *opts
if o.SingleThreaded {
fs = NewLockingRawFileSystem(fs)
}
if o.Buffers == nil { if o.Buffers == nil {
o.Buffers = defaultBufferPool o.Buffers = defaultBufferPool
} }
......
...@@ -76,7 +76,6 @@ func NewTestCase(t *testing.T) *testCase { ...@@ -76,7 +76,6 @@ func NewTestCase(t *testing.T) *testCase {
pfs = pathfs.NewLoopbackFileSystem(me.orig) pfs = pathfs.NewLoopbackFileSystem(me.orig)
pfs = pathfs.NewLockingFileSystem(pfs) pfs = pathfs.NewLockingFileSystem(pfs)
var rfs fuse.RawFileSystem
me.pathFs = pathfs.NewPathNodeFs(pfs, &pathfs.PathNodeFsOptions{ me.pathFs = pathfs.NewPathNodeFs(pfs, &pathfs.PathNodeFsOptions{
ClientInodes: true}) ClientInodes: true})
me.connector = nodefs.NewFileSystemConnector(me.pathFs, me.connector = nodefs.NewFileSystemConnector(me.pathFs,
...@@ -85,10 +84,9 @@ func NewTestCase(t *testing.T) *testCase { ...@@ -85,10 +84,9 @@ func NewTestCase(t *testing.T) *testCase {
AttrTimeout: testTtl, AttrTimeout: testTtl,
NegativeTimeout: 0.0, NegativeTimeout: 0.0,
}) })
rfs = fuse.NewLockingRawFileSystem(me.connector.RawFS())
me.connector.SetDebug(fuse.VerboseTest()) me.connector.SetDebug(fuse.VerboseTest())
me.state, err = fuse.NewServer(rfs, me.mnt, nil) me.state, err = fuse.NewServer(
me.connector.RawFS(), me.mnt, &fuse.MountOptions{SingleThreaded: true})
if err != nil { if err != nil {
t.Fatal("NewServer:", err) t.Fatal("NewServer:", err)
} }
......
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