Whamcloud - gitweb
mmp: do not use O_DIRECT when working with regular file
authorLukas Czerner <lczerner@redhat.com>
Thu, 18 Feb 2021 09:51:46 +0000 (10:51 +0100)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 26 Feb 2021 04:55:00 +0000 (23:55 -0500)
commit76a6c8788c79e4ba72dab691818cdae23e760e86
tree1d97c0adecb1ec05570dd7a384d3447c215a8f85
parentbb2349c518bd6d59edac4148e4cd3373731b1d27
mmp: do not use O_DIRECT when working with regular file

Currently the mmp block is read using O_DIRECT to avoid any caching that
may be done by the VM. However when working with regular files this
creates alignment issues when the device of the host file system has
sector size larger than the blocksize of the file system in the file
we're working with.

This can be reproduced with t_mmp_fail test when run on the device with
4k sector size because the mke2fs fails when trying to read the mmp
block.

Fix it by disabling O_DIRECT when working with regular files. I don't
think there is any risk of doing so since the file system layer, unlike
shared block device, should guarantee cache consistency.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/mmp.c