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
import (
"bytes"
"fmt"
"log"
"unsafe"
)
var _ = log.Printf
func replyString(opcode Opcode, ptr unsafe.Pointer) string {
h := getHandler(opcode)
var val interface{}
......@@ -20,17 +23,15 @@ func replyString(opcode Opcode, ptr unsafe.Pointer) string {
////////////////////////////////////////////////////////////////
func doInit(state *MountState, req *request) {
input := (*InitIn)(req.inData)
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
return
}
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
return
}
......@@ -39,8 +40,10 @@ func doInit(state *MountState, req *request) {
Major: FUSE_KERNEL_VERSION,
Minor: FUSE_KERNEL_MINOR_VERSION,
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,
CongestionThreshold: _BACKGROUND_TASKS * 3 / 4,
MaxBackground: _BACKGROUND_TASKS,
}
req.outData = unsafe.Pointer(out)
......
......@@ -23,6 +23,7 @@ const (
FATTR_ATIME_NOW = (1 << 7)
FATTR_MTIME_NOW = (1 << 8)
FATTR_LOCKOWNER = (1 << 9)
// OpenIn.Flags
FOPEN_DIRECT_IO = (1 << 0)
......@@ -30,14 +31,17 @@ const (
FOPEN_NONSEEKABLE = (1 << 2)
// To be set in InitOut.Flags.
FUSE_ASYNC_READ = (1 << 0)
FUSE_POSIX_LOCKS = (1 << 1)
FUSE_FILE_OPS = (1 << 2)
FUSE_ATOMIC_O_TRUNC = (1 << 3)
FUSE_EXPORT_SUPPORT = (1 << 4)
FUSE_BIG_WRITES = (1 << 5)
FUSE_DONT_MASK = (1 << 6)
CAP_ASYNC_READ = (1 << 0)
CAP_POSIX_LOCKS = (1 << 1)
CAP_FILE_OPS = (1 << 2)
CAP_ATOMIC_O_TRUNC = (1 << 3)
CAP_EXPORT_SUPPORT = (1 << 4)
CAP_BIG_WRITES = (1 << 5)
CAP_DONT_MASK = (1 << 6)
CAP_SPLICE_WRITE = (1 << 7)
CAP_SPLICE_MOVE = (1 << 8)
CAP_SPLICE_READ = (1 << 9)
FUSE_UNKNOWN_INO = 0xffffffff
CUSE_UNRESTRICTED_IOCTL = (1 << 0)
......@@ -61,19 +65,7 @@ const (
FUSE_POLL_SCHEDULE_NOTIFY = (1 << 0)
FUSE_COMPAT_WRITE_IN_SIZE = 24
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
S_IFDIR = syscall.S_IFDIR
......@@ -85,6 +77,11 @@ const (
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
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