Commit b6256e6f authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Also set CongestionThreshold and MaxBackground. Drop some FUSE_ prefixes.

parent 4d2a634b
...@@ -3,9 +3,12 @@ package fuse ...@@ -3,9 +3,12 @@ package fuse
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"log"
"unsafe" "unsafe"
) )
var _ = log.Printf
func replyString(opcode Opcode, ptr unsafe.Pointer) string { func replyString(opcode Opcode, ptr unsafe.Pointer) string {
h := getHandler(opcode) h := getHandler(opcode)
var val interface{} var val interface{}
...@@ -20,17 +23,15 @@ func replyString(opcode Opcode, ptr unsafe.Pointer) string { ...@@ -20,17 +23,15 @@ func replyString(opcode Opcode, ptr unsafe.Pointer) string {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
func doInit(state *MountState, req *request) { func doInit(state *MountState, req *request) {
input := (*InitIn)(req.inData) input := (*InitIn)(req.inData)
if input.Major != FUSE_KERNEL_VERSION { if input.Major != FUSE_KERNEL_VERSION {
fmt.Printf("Major versions does not match. Given %d, want %d\n", input.Major, FUSE_KERNEL_VERSION) log.Printf("Major versions does not match. Given %d, want %d\n", input.Major, FUSE_KERNEL_VERSION)
req.status = EIO req.status = EIO
return return
} }
if input.Minor < FUSE_KERNEL_MINOR_VERSION { if input.Minor < FUSE_KERNEL_MINOR_VERSION {
fmt.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, FUSE_KERNEL_MINOR_VERSION) log.Printf("Minor version is less than we support. Given %d, want at least %d\n", input.Minor, FUSE_KERNEL_MINOR_VERSION)
req.status = EIO req.status = EIO
return return
} }
...@@ -39,8 +40,10 @@ func doInit(state *MountState, req *request) { ...@@ -39,8 +40,10 @@ func doInit(state *MountState, req *request) {
Major: FUSE_KERNEL_VERSION, Major: FUSE_KERNEL_VERSION,
Minor: FUSE_KERNEL_MINOR_VERSION, Minor: FUSE_KERNEL_MINOR_VERSION,
MaxReadAhead: input.MaxReadAhead, MaxReadAhead: input.MaxReadAhead,
Flags: FUSE_ASYNC_READ | FUSE_POSIX_LOCKS | FUSE_BIG_WRITES, Flags: CAP_ASYNC_READ | CAP_POSIX_LOCKS | CAP_BIG_WRITES,
MaxWrite: maxRead, MaxWrite: maxRead,
CongestionThreshold: _BACKGROUND_TASKS * 3 / 4,
MaxBackground: _BACKGROUND_TASKS,
} }
req.outData = unsafe.Pointer(out) req.outData = unsafe.Pointer(out)
......
...@@ -23,6 +23,7 @@ const ( ...@@ -23,6 +23,7 @@ const (
FATTR_ATIME_NOW = (1 << 7) FATTR_ATIME_NOW = (1 << 7)
FATTR_MTIME_NOW = (1 << 8) FATTR_MTIME_NOW = (1 << 8)
FATTR_LOCKOWNER = (1 << 9) FATTR_LOCKOWNER = (1 << 9)
// OpenIn.Flags // OpenIn.Flags
FOPEN_DIRECT_IO = (1 << 0) FOPEN_DIRECT_IO = (1 << 0)
...@@ -30,14 +31,17 @@ const ( ...@@ -30,14 +31,17 @@ const (
FOPEN_NONSEEKABLE = (1 << 2) FOPEN_NONSEEKABLE = (1 << 2)
// To be set in InitOut.Flags. // To be set in InitOut.Flags.
FUSE_ASYNC_READ = (1 << 0) CAP_ASYNC_READ = (1 << 0)
FUSE_POSIX_LOCKS = (1 << 1) CAP_POSIX_LOCKS = (1 << 1)
FUSE_FILE_OPS = (1 << 2) CAP_FILE_OPS = (1 << 2)
FUSE_ATOMIC_O_TRUNC = (1 << 3) CAP_ATOMIC_O_TRUNC = (1 << 3)
FUSE_EXPORT_SUPPORT = (1 << 4) CAP_EXPORT_SUPPORT = (1 << 4)
FUSE_BIG_WRITES = (1 << 5) CAP_BIG_WRITES = (1 << 5)
FUSE_DONT_MASK = (1 << 6) CAP_DONT_MASK = (1 << 6)
CAP_SPLICE_WRITE = (1 << 7)
CAP_SPLICE_MOVE = (1 << 8)
CAP_SPLICE_READ = (1 << 9)
FUSE_UNKNOWN_INO = 0xffffffff FUSE_UNKNOWN_INO = 0xffffffff
CUSE_UNRESTRICTED_IOCTL = (1 << 0) CUSE_UNRESTRICTED_IOCTL = (1 << 0)
...@@ -61,19 +65,7 @@ const ( ...@@ -61,19 +65,7 @@ const (
FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0) FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0)
FUSE_COMPAT_WRITE_IN_SIZE = 24
FUSE_MIN_READ_BUFFER = 8192 FUSE_MIN_READ_BUFFER = 8192
FUSE_COMPAT_ENTRY_OUT_SIZE = 120
FUSE_COMPAT_ATTR_OUT_SIZE = 96
FUSE_COMPAT_MKNOD_IN_SIZE = 8
FUSE_COMPAT_STATFS_SIZE = 48
CUSE_INIT_INFO_MAX = 4096 CUSE_INIT_INFO_MAX = 4096
S_IFDIR = syscall.S_IFDIR S_IFDIR = syscall.S_IFDIR
...@@ -85,6 +77,11 @@ const ( ...@@ -85,6 +77,11 @@ const (
O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC) O_ANYWRITE = uint32(os.O_WRONLY | os.O_RDWR | os.O_APPEND | os.O_CREATE | os.O_TRUNC)
) )
const (
// TODO - we should read this from /sys/fs/fuse/ , dynamically.
_BACKGROUND_TASKS = 12
)
type Status int32 type Status int32
const ( const (
......
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