• Filipe Manana's avatar
    btrfs: add missing inode updates on each iteration when replacing extents · 983d8209
    Filipe Manana authored
    When replacing file extents, called during fallocate, hole punching,
    clone and deduplication, we may not be able to replace/drop all the
    target file extent items with a single transaction handle. We may get
    -ENOSPC while doing it, in which case we release the transaction handle,
    balance the dirty pages of the btree inode, flush delayed items and get
    a new transaction handle to operate on what's left of the target range.
    
    By dropping and replacing file extent items we have effectively modified
    the inode, so we should bump its iversion and update its mtime/ctime
    before we update the inode item. This is because if the transaction
    we used for partially modifying the inode gets committed by someone after
    we release it and before we finish the rest of the range, a power failure
    happens, then after mounting the filesystem our inode has an outdated
    iversion and mtime/ctime, corresponding to the values it had before we
    changed it.
    
    So add the missing iversion and mtime/ctime updates.
    Reviewed-by: default avatarBoris Burkov <boris@bur.io>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    983d8209
file.c 104 KB