diff options
author | Jakob Unterwurzacher | 2019-08-04 13:45:10 +0200 |
---|---|---|
committer | Jakob Unterwurzacher | 2019-08-04 13:46:33 +0200 |
commit | 13055278f56b941be0ea1ff4eb4840d88fba7e37 (patch) | |
tree | c1f69e012e7e2792b4f87c26e0ba3a0424c7fc59 | |
parent | abb2f1fad0cc6494169abb3e9a486f6f46c6c647 (diff) |
Force -noprealloc on Btrfs
Preallocation on Btrfs is broken ( https://github.com/rfjakob/gocryptfs/issues/395 ,
https://lore.kernel.org/linux-btrfs/CAPv9Zmk46As_P9Gyf_icET53xRda63h7iC1meES9xbdDEt9qow@mail.gmail.com/ )
and slow ( https://github.com/rfjakob/gocryptfs/issues/63 ).
-rw-r--r-- | mount.go | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -19,6 +19,8 @@ import ( "syscall" "time" + "golang.org/x/sys/unix" + "github.com/hanwen/go-fuse/fuse" "github.com/hanwen/go-fuse/fuse/nodefs" "github.com/hanwen/go-fuse/fuse/pathfs" @@ -95,6 +97,18 @@ func doMount(args *argContainer) { } }() } + // Preallocation on Btrfs is broken ( https://github.com/rfjakob/gocryptfs/issues/395 ) + // and slow ( https://github.com/rfjakob/gocryptfs/issues/63 ). + if !args.noprealloc { + var st unix.Statfs_t + err = unix.Statfs(args.cipherdir, &st) + if err == nil && st.Type == unix.BTRFS_SUPER_MAGIC { + tlog.Info.Printf(tlog.ColorYellow + + "Btrfs detected, forcing -noprealloc. See https://github.com/rfjakob/gocryptfs/issues/395 for why." + + tlog.ColorReset) + args.noprealloc = true + } + } // We cannot use JSON for pretty-printing as the fields are unexported tlog.Debug.Printf("cli args: %#v", args) // Initialize gocryptfs (read config file, ask for password, ...) |