From 893e41149ed353f355047003b89eeff456990e76 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 2 Jul 2018 23:54:37 +0200 Subject: [PATCH] fusefrontend: disallow O_DIRECT and fall back to buffered IO O_DIRECT accesses must be aligned in both offset and length. Due to our crypto header, alignment will be off, even if userspace makes aligned accesses. Running xfstests generic/013 on ext4 used to trigger lots of EINVAL errors due to missing alignment. Just fall back to buffered IO. --- internal/fusefrontend/fs.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go index f66e6d4..2cdc362 100644 --- a/internal/fusefrontend/fs.go +++ b/internal/fusefrontend/fs.go @@ -101,6 +101,11 @@ func (fs *FS) mangleOpenFlags(flags uint32) (newFlags int) { } // We also cannot open the file in append mode, we need to seek back for RMW newFlags = newFlags &^ os.O_APPEND + // O_DIRECT accesses must be aligned in both offset and length. Due to our + // crypto header, alignment will be off, even if userspace makes aligned + // accesses. Running xfstests generic/013 on ext4 used to trigger lots of + // EINVAL errors due to missing alignment. Just fall back to buffered IO. + newFlags = newFlags &^ syscall.O_DIRECT return newFlags }