• Josef Bacik's avatar
    btrfs: clear space cache inode generation always · 591ddc92
    Josef Bacik authored
    commit 8e138e0d upstream.
    
    We discovered a box that had double allocations, and suspected the space
    cache may be to blame.  While auditing the write out path I noticed that
    if we've already setup the space cache we will just carry on.  This
    means that any error we hit after cache_save_setup before we go to
    actually write the cache out we won't reset the inode generation, so
    whatever was already written will be considered correct, except it'll be
    stale.  Fix this by _always_ resetting the generation on the block group
    inode, this way we only ever have valid or invalid cache.
    
    With this patch I was no longer able to reproduce cache corruption with
    dm-log-writes and my bpf error injection tool.
    Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    591ddc92
extent-tree.c 290 KB