Allow to spawn more than 1 FUSE file descriptor reader goroutine
parent
775aacf12c
commit
e8004f04a5
19
mount.go
19
mount.go
|
@ -20,6 +20,7 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
|
@ -71,6 +72,9 @@ func Mount(
|
|||
if cfgCopy.OpContext == nil {
|
||||
cfgCopy.OpContext = context.Background()
|
||||
}
|
||||
if cfgCopy.ReaderThreads < 1 {
|
||||
cfgCopy.ReaderThreads = 1
|
||||
}
|
||||
|
||||
// Create a Connection object wrapping the device.
|
||||
connection, err := newConnection(
|
||||
|
@ -83,11 +87,16 @@ func Mount(
|
|||
}
|
||||
|
||||
// Serve the connection in the background. When done, set the join status.
|
||||
go func() {
|
||||
server.ServeOps(connection)
|
||||
mfs.joinStatus = connection.close()
|
||||
close(mfs.joinStatusAvailable)
|
||||
}()
|
||||
atomic.AddInt64(&mfs.joinRemaining, int64(cfgCopy.ReaderThreads))
|
||||
for i := 0; i < cfgCopy.ReaderThreads; i++ {
|
||||
go func() {
|
||||
server.ServeOps(connection)
|
||||
if atomic.AddInt64(&mfs.joinRemaining, -1) == 0 {
|
||||
mfs.joinStatus = connection.close()
|
||||
close(mfs.joinStatusAvailable)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Wait for the mount process to complete.
|
||||
if err := <-ready; err != nil {
|
||||
|
|
|
@ -161,6 +161,11 @@ type MountConfig struct {
|
|||
// the data is already in memory when they return it to FUSE.
|
||||
UseVectoredRead bool
|
||||
|
||||
// Number of goroutines (and hopefully threads) to use for reading from
|
||||
// the FUSE file descriptor. You can try to use more than 1 if memory
|
||||
// copying during write operations is a bottleneck for you
|
||||
ReaderThreads int
|
||||
|
||||
// OS X only.
|
||||
//
|
||||
// The name of the mounted volume, as displayed in the Finder. If empty, a
|
||||
|
|
|
@ -23,6 +23,7 @@ type MountedFileSystem struct {
|
|||
|
||||
// The result to return from Join. Not valid until the channel is closed.
|
||||
joinStatus error
|
||||
joinRemaining int64
|
||||
joinStatusAvailable chan struct{}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue