• Filipe Manana's avatar
    btrfs: properly flush delalloc when entering fiemap · 33a86cfa
    Filipe Manana authored
    If the flag FIEMAP_FLAG_SYNC is passed to fiemap, it means all delalloc
    should be flushed and writeback complete. We call the generic helper
    fiemap_prep() which does a filemap_write_and_wait() in case that flag is
    given, however that is not enough if we have compression. Because a
    single filemap_fdatawrite_range() only starts compression (in an async
    thread) and therefore returns before the compression is done and writeback
    is started.
    
    So make btrfs_fiemap(), actually wait for all writeback to start and
    complete if FIEMAP_FLAG_SYNC is set. We start and wait for writeback
    on the whole possible file range, from 0 to LLONG_MAX, because that is
    what the generic code at fiemap_prep() does.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    33a86cfa
inode.c 327 KB