Skip to content

Commit 21c10e1

Browse files
tytsoqkaiser
authored andcommitted
resize2fs: use Direct I/O when reading the superblock for online resizes
If the file system is mounted, the superblock can be changing while resize2fs is trying to read the superblock, resulting in checksum failures. One way of avoiding this problem is read the superblock using Direct I/O, since the kernel makes sure that what gets written to disk is self-consistent. Suggested-by: Krister Johansen <[email protected]> Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 39bae75 commit 21c10e1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

resize/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ int main (int argc, char ** argv)
409409

410410
if (!(mount_flags & EXT2_MF_MOUNTED) && !print_min_size)
411411
io_flags = EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE;
412+
if (mount_flags & EXT2_MF_MOUNTED)
413+
io_flags |= EXT2_FLAG_DIRECT_IO;
412414

413415
io_flags |= EXT2_FLAG_64BITS | EXT2_FLAG_THREADS;
414416
if (undo_file) {

0 commit comments

Comments
 (0)