• Q
    btrfs: Avoid truncate tailing page if fallocate range doesn't exceed inode size · 0f6925fa
    Qu Wenruo 提交于
    Current code will always truncate tailing page if its alloc_start is
    smaller than inode size.
    
    For example, the file extent layout is like:
    0	4K	8K	16K	32K
    |<-----Extent A---------------->|
    |<--Inode size: 18K---------->|
    
    But if calling fallocate even for range [0,4K), it will cause btrfs to
    re-truncate the range [16,32K), causing COW and a new extent.
    
    0	4K	8K	16K	32K
    |///////|	<- Fallocate call range
    |<-----Extent A-------->|<--B-->|
    
    The cause is quite easy, just a careless btrfs_truncate_inode() in a
    else branch without extra judgment.
    Fix it by add judgment on whether the fallocate range is beyond isize.
    Signed-off-by: NQu Wenruo <quwenruo@cn.fujitsu.com>
    Signed-off-by: NChris Mason <clm@fb.com>
    0f6925fa
file.c 76.2 KB