Skip to content

Commit 01da9b6

Browse files
committed
fix: directIO read size can exceeds buffer size
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 <shuoranliu@gmail.com>
1 parent 081e9f4 commit 01da9b6

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

mount_linux.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ import (
77
"net"
88
"os"
99
"os/exec"
10+
"strconv"
1011
"syscall"
1112

1213
"golang.org/x/sys/unix"
14+
15+
"github.com/jacobsa/fuse/internal/buffer"
1316
)
1417

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

35+
cfg.Options["max_read"] = strconv.Itoa(buffer.MaxReadSize)
36+
3237
cmd := exec.Command(
3338
"fusermount",
3439
"-o", cfg.toOptionsString(),

0 commit comments

Comments
 (0)