On 2021/7/16 22:39, Eric Biggers wrote:
From: Eric Biggers <[email protected]>
f2fs_write_begin() assumes that all blocks were preallocated by
default unless FI_NO_PREALLOC is explicitly set. This invites data
corruption, as there are cases in which not all blocks are preallocated.
Commit 47501f87c61a ("f2fs: preallocate DIO blocks when forcing
buffered_io") fixed one case, but there are others remaining.
Could you please explain which cases we missed to handle previously?
then I can check those related logic before and after the rework.
- /*
- * If force_buffere_io() is true, we have to allocate
- * blocks all the time, since f2fs_direct_IO will fall
- * back to buffered IO.
- */
- if (!f2fs_force_buffered_io(inode, iocb, from) &&
- f2fs_lfs_mode(F2FS_I_SB(inode)))
We should keep this OPU DIO logic, otherwise, in lfs mode, write dio
will always allocate two block addresses for each 4k append IO.
I jsut test based on codes of last f2fs dev-test branch.
rm /mnt/f2fs/dio
dd if=/dev/zero of=/mnt/f2fs/dio bs=4k count=4 oflag=direct
<...>-763176 [001] ...1 177258.793370: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 0, start blkaddr = 0xe1a2e, len = 0x1, flags =
48,seg_type = 1, may_create = 1, err = 0
<...>-763176 [001] ...1 177258.793462: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 0, start blkaddr = 0xe1a2f, len = 0x1, flags =
16,seg_type = 1, may_create = 1, err = 0
dd-763176 [001] ...1 177258.793575: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 1, start blkaddr = 0xe1a30, len = 0x1, flags =
48,seg_type = 1, may_create = 1, err = 0
dd-763176 [001] ...1 177258.793599: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 1, start blkaddr = 0xe1a31, len = 0x1, flags =
16,seg_type = 1, may_create = 1, err = 0
dd-763176 [001] ...1 177258.793735: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 2, start blkaddr = 0xe1a32, len = 0x1, flags =
48,seg_type = 1, may_create = 1, err = 0
dd-763176 [001] ...1 177258.793769: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 2, start blkaddr = 0xe1a33, len = 0x1, flags =
16,seg_type = 1, may_create = 1, err = 0
dd-763176 [001] ...1 177258.793859: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 3, start blkaddr = 0xe1a34, len = 0x1, flags =
48,seg_type = 1, may_create = 1, err = 0
dd-763176 [001] ...1 177258.793885: f2fs_map_blocks: dev =
(259,1), ino = 6, file offset = 3, start blkaddr = 0xe1a35, len = 0x1, flags =
16,seg_type = 1, may_create = 1, err = 0
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel