Skip to content

Commit

Permalink
fix: directIO read size can exceed buffer size
Browse files Browse the repository at this point in the history
Since the package uses a fixed-size memory pool for out messages,
it is important to tell fuse kernel module what the maximum read size is.
Otherwise, a large read will cause a panic.

Right now, max readahead size can only affect buffered read. The kernel
might still send a large directIO read in spite of the max readahead size.
We need to specify "max_read" option during mount.

Signed-off-by: Shuoran Liu <[email protected]>
  • Loading branch information
shuoranliu committed Oct 21, 2019
1 parent 081e9f4 commit 1f74c2f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mount_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import (
"net"
"os"
"os/exec"
"strconv"
"syscall"

"golang.org/x/sys/unix"

"github.com/jacobsa/fuse/internal/buffer"
)

func fusermount(dir string, cfg *MountConfig) (*os.File, error) {
Expand All @@ -29,6 +32,11 @@ func fusermount(dir string, cfg *MountConfig) (*os.File, error) {
// Start fusermount, passing it a buffer in which to write stderr.
var stderr bytes.Buffer

if cfg.Options == nil {
cfg.Options = make(map[string]string)
}
cfg.Options["max_read"] = strconv.Itoa(buffer.MaxReadSize)

cmd := exec.Command(
"fusermount",
"-o", cfg.toOptionsString(),
Expand Down

0 comments on commit 1f74c2f

Please sign in to comment.