• Eric Biggers's avatar
    f2fs: rework write preallocations · 3d697a4a
    Eric Biggers authored
    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 47501f87 ("f2fs: preallocate DIO blocks when forcing
    buffered_io") fixed one case, but there are others remaining.
    
    Fix up this logic by replacing this flag with FI_PREALLOCATED_ALL, which
    only gets set if all blocks for the current write were preallocated.
    
    Also clean up f2fs_preallocate_blocks(), move it to file.c, and make it
    handle some of the logic that was previously in write_iter() directly.
    Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
    Reviewed-by: default avatarChao Yu <chao@kernel.org>
    Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
    3d697a4a
file.c 108 KB