• L
    Btrfs: fix btrfs_ordered_update_i_size to update disk_i_size properly · 19fd2df5
    Liu Bo 提交于
    btrfs_ordered_update_i_size can be called by truncate and endio, but
    only endio takes ordered_extent which contains the completed IO.
    
    while truncating down a file, if there are some in-flight IOs,
    btrfs_ordered_update_i_size in endio will set disk_i_size to
    @orig_offset that is zero.  If truncating-down fails somehow, we try to
    recover in memory isize with this zero'd disk_i_size.
    
    Fix it by only updating disk_i_size with @orig_offset when
    btrfs_ordered_update_i_size is not called from endio while truncating
    down and waiting for in-flight IOs completing their work before recover
    in-memory size.
    
    Besides fixing the above issue, add an assertion for last_size to double
    check we truncate down to the desired size.
    Signed-off-by: NLiu Bo <bo.li.liu@oracle.com>
    Signed-off-by: NDavid Sterba <dsterba@suse.com>
    19fd2df5
ordered-data.c 31.4 KB