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.
This commit is contained in:
Jakob Unterwurzacher 2018-07-02 23:54:37 +02:00
parent c51fc9e07d
commit 893e41149e
1 changed files with 5 additions and 0 deletions

View File

@ -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
}