Commit 4cc77e52 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add MaxBackground as tunable setting in fuse.MountOptions.

parent f980c761
...@@ -98,6 +98,9 @@ type FileSystemOptions struct { ...@@ -98,6 +98,9 @@ type FileSystemOptions struct {
type MountOptions struct { type MountOptions struct {
AllowOther bool AllowOther bool
// Default is _DEFAULT_BACKGROUND_TASKS, 12.
MaxBackground int
} }
// DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation. // DefaultFileSystem implements a FileSystem that returns ENOSYS for every operation.
......
...@@ -33,6 +33,7 @@ type MountState struct { ...@@ -33,6 +33,7 @@ type MountState struct {
*LatencyMap *LatencyMap
opts *MountOptions
kernelSettings InitIn kernelSettings InitIn
} }
...@@ -46,9 +47,15 @@ func (me *MountState) MountPoint() string { ...@@ -46,9 +47,15 @@ func (me *MountState) MountPoint() string {
// Mount filesystem on mountPoint. // Mount filesystem on mountPoint.
func (me *MountState) Mount(mountPoint string, opts *MountOptions) os.Error { func (me *MountState) Mount(mountPoint string, opts *MountOptions) os.Error {
if opts == nil {
opts = &MountOptions{
MaxBackground: _DEFAULT_BACKGROUND_TASKS,
}
}
me.opts = opts
optStr := "" optStr := ""
if opts != nil && opts.AllowOther { if opts.AllowOther {
optStr = "allow_other" optStr = "allow_other"
} }
...@@ -150,7 +157,7 @@ func (me *MountState) Loop(threaded bool) { ...@@ -150,7 +157,7 @@ func (me *MountState) Loop(threaded bool) {
// This means that the request once read does not need to be // This means that the request once read does not need to be
// assigned to another thread, so it avoids a context switch. // assigned to another thread, so it avoids a context switch.
if threaded { if threaded {
for i := 0; i < _BACKGROUND_TASKS; i++ { for i := 0; i < me.opts.MaxBackground-1; i++ {
go me.loop() go me.loop()
} }
} }
......
...@@ -84,8 +84,8 @@ func doInit(state *MountState, req *request) { ...@@ -84,8 +84,8 @@ func doInit(state *MountState, req *request) {
MaxReadAhead: input.MaxReadAhead, MaxReadAhead: input.MaxReadAhead,
Flags: state.kernelSettings.Flags, Flags: state.kernelSettings.Flags,
MaxWrite: maxRead, MaxWrite: maxRead,
CongestionThreshold: _BACKGROUND_TASKS * 3 / 4, CongestionThreshold: uint16(state.opts.MaxBackground * 3 / 4),
MaxBackground: _BACKGROUND_TASKS, MaxBackground: uint16(state.opts.MaxBackground),
} }
req.outData = unsafe.Pointer(out) req.outData = unsafe.Pointer(out)
......
...@@ -35,8 +35,7 @@ const ( ...@@ -35,8 +35,7 @@ const (
) )
const ( const (
// TODO - we should read this from /sys/fs/fuse/ , dynamically. _DEFAULT_BACKGROUND_TASKS = 12
_BACKGROUND_TASKS = 12
) )
type Status int32 type Status int32
......
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