Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable directmountstrict mode for fuse #156

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions pkg/filesystem/virtual/configuration/fuse_mount_enabled.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/buildbarn/bb-remote-execution/pkg/filesystem/virtual"
"github.com/buildbarn/bb-remote-execution/pkg/filesystem/virtual/fuse"
virtualpb "github.com/buildbarn/bb-remote-execution/pkg/proto/configuration/filesystem/virtual"
"github.com/buildbarn/bb-storage/pkg/clock"
"github.com/buildbarn/bb-storage/pkg/filesystem"
"github.com/buildbarn/bb-storage/pkg/program"
Expand Down Expand Up @@ -45,6 +46,35 @@ func (m *fuseMount) Expose(terminationGroup program.Group, rootDirectory virtual
// Launch the FUSE server.
removeStaleMounts(m.mountPath)
deterministicTimestamp := uint64(filesystem.DeterministicFileModificationTimestamp.Unix())
mountOptions := &go_fuse.MountOptions{
// The name isn't strictly necessary, but is
// filled in to prevent runc from crashing with
// this error:
// https://github.com/opencontainers/runc/blob/v1.0.0-rc10/libcontainer/mount/mount_linux.go#L69
//
// Newer versions of runc use an improved parser
// that's more reliable:
// https://github.com/moby/sys/blob/master/mountinfo/mountinfo_linux.go
FsName: m.fsName,
AllowOther: m.configuration.AllowOther,
// Speed up workloads that perform many tiny
// writes. This means data is only guaranteed to
// make it into the virtual file system after
// calling close()/fsync()/munmap()/msync().
EnableWritebackCache: true,
}

switch m.configuration.MountMethod {
case virtualpb.FUSEMountConfiguration_DIRECT:
mountOptions.DirectMountStrict = true
case virtualpb.FUSEMountConfiguration_DIRECT_AND_FUSERMOUNT:
mountOptions.DirectMount = true
case virtualpb.FUSEMountConfiguration_FUSERMOUNT:
// No additional options needed for FUSERMOUNT
default:
// Default to use FUSERMOUNT
sfc-gh-guwang marked this conversation as resolved.
Show resolved Hide resolved
}

server, err := go_fuse.NewServer(
fuse.NewMetricsRawFileSystem(
fuse.NewDefaultAttributesInjectingRawFileSystem(
Expand All @@ -61,24 +91,8 @@ func (m *fuseMount) Expose(terminationGroup program.Group, rootDirectory virtual
}),
clock.SystemClock),
m.mountPath,
&go_fuse.MountOptions{
// The name isn't strictly necessary, but is
// filled in to prevent runc from crashing with
// this error:
// https://github.com/opencontainers/runc/blob/v1.0.0-rc10/libcontainer/mount/mount_linux.go#L69
//
// Newer versions of runc use an improved parser
// that's more reliable:
// https://github.com/moby/sys/blob/master/mountinfo/mountinfo_linux.go
FsName: m.fsName,
AllowOther: m.configuration.AllowOther,
DirectMount: m.configuration.DirectMount,
// Speed up workloads that perform many tiny
// writes. This means data is only guaranteed to
// make it into the virtual file system after
// calling close()/fsync()/munmap()/msync().
EnableWritebackCache: true,
})
mountOptions,
)
if err != nil {
return util.StatusWrap(err, "Failed to create FUSE server")
}
Expand Down
Loading
Loading