diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-10-23 16:58:09 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-12-08 17:54:03 +0300 |
commit | 4d7240f0abda6a75ce54e8d488db2e4ca4460185 (patch) | |
tree | 7f867f97e2dcb9d48d688da50f34e80d51bdc139 /fs/btrfs/inode.c | |
parent | cd79909bc7cdd8043a22d699aae1e8435792c824 (diff) | |
download | linux-4d7240f0abda6a75ce54e8d488db2e4ca4460185.tar.xz |
btrfs: load the free space cache inode extents from commit root
Historically we've allowed recursive locking specifically for the free
space inode. This is because we are only doing reads and know that it's
safe. However we don't actually need this feature, we can get away with
reading the commit root for the extents. In fact if we want to allow
asynchronous loading of the free space cache we have to use the commit
root, otherwise we will deadlock.
Switch to using the commit root for the file extents. These are only
read at load time, and are replaced as soon as we start writing the
cache out to disk. The cache is never read again, so this is
legitimate. This matches what we do for the inode itself, as we read
that from the commit root as well.
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index d3b2740f4d70..d2ef8308ad0a 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -6675,7 +6675,16 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode, /* Chances are we'll be called again, so go ahead and do readahead */ path->reada = READA_FORWARD; - path->recurse = btrfs_is_free_space_inode(inode); + + /* + * The same explanation in load_free_space_cache applies here as well, + * we only read when we're loading the free space cache, and at that + * point the commit_root has everything we need. + */ + if (btrfs_is_free_space_inode(inode)) { + path->search_commit_root = 1; + path->skip_locking = 1; + } ret = btrfs_lookup_file_extent(NULL, root, path, objectid, start, 0); if (ret < 0) { |