• Josef Bacik's avatar
    btrfs: load free space cache asynchronously · e747853c
    Josef Bacik authored
    While documenting the usage of the commit_root_sem, I noticed that we do
    not actually take the commit_root_sem in the case of the free space
    cache.  This is problematic because we're supposed to hold that sem
    while we're reading the commit roots, which is what we do for the free
    space cache.
    
    The reason I did it inline when I originally wrote the code was because
    there's the case of unpinning where we need to make sure that the free
    space cache is loaded if we're going to use the free space cache.  But
    we can accomplish the same thing by simply waiting for the cache to be
    loaded.
    
    Rework this code to load the free space cache asynchronously.  This
    allows us to greatly cleanup the caching code because now it's all
    shared by the various caching methods.  We also are now in a position to
    have the commit_root semaphore held while we're loading the free space
    cache.  And finally our modification of ->last_byte_to_unpin is removed
    because it can be handled in the proper way on commit.
    
    Some care must be taken when replaying the log, when we expect that the
    free space cache will be read entirely before we start excluding space
    to replay. This could lead to overwriting space during replay.
    Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    e747853c
extent-tree.c 160 KB