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