]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Btrfs: use commit root when loading free space cache
authorJosef Bacik <josef@redhat.com>
Thu, 12 Apr 2012 20:03:57 +0000 (16:03 -0400)
committerChris Mason <chris.mason@oracle.com>
Fri, 13 Apr 2012 00:54:01 +0000 (20:54 -0400)
A user reported that booting his box up with btrfs root on 3.4 was way
slower than on 3.3 because I removed the ideal caching code.  It turns out
that we don't load the free space cache if we're in a commit for deadlock
reasons, but since we're reading the cache and it hasn't changed yet we are
safe reading the inode and free space item from the commit root, so do that
and remove all of the deadlock checks so we don't unnecessarily skip loading
the free space cache.  The user reported this fixed the slowness.  Thanks,

Tested-by: Calvin Walton <calvin.walton@kepstin.ca>
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent-tree.c
fs/btrfs/free-space-cache.c

index a2134d8141c13d83ac6d53e26357b47fe71a963a..2b35f8d14bb9a14c7f1539268dce04973413512f 100644 (file)
@@ -529,9 +529,7 @@ static int cache_block_group(struct btrfs_block_group_cache *cache,
         * allocate blocks for the tree root we can't do the fast caching since
         * we likely hold important locks.
         */
-       if (trans && (!trans->transaction->in_commit) &&
-           (root && root != root->fs_info->tree_root) &&
-           btrfs_test_opt(root, SPACE_CACHE)) {
+       if (fs_info->mount_opt & BTRFS_MOUNT_SPACE_CACHE) {
                ret = load_free_space_cache(fs_info, cache);
 
                spin_lock(&cache->lock);
index 054707ed57914ab97b2f8a5e2e1e9f9679884bba..baaa518baaf83c5f8034b58452ce34ccdcbb26a8 100644 (file)
@@ -747,13 +747,6 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
        bool matched;
        u64 used = btrfs_block_group_used(&block_group->item);
 
-       /*
-        * If we're unmounting then just return, since this does a search on the
-        * normal root and not the commit root and we could deadlock.
-        */
-       if (btrfs_fs_closing(fs_info))
-               return 0;
-
        /*
         * If this block group has been marked to be cleared for one reason or
         * another then we can't trust the on disk cache, so just return.
@@ -768,6 +761,8 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
        path = btrfs_alloc_path();
        if (!path)
                return 0;
+       path->search_commit_root = 1;
+       path->skip_locking = 1;
 
        inode = lookup_free_space_inode(root, block_group, path);
        if (IS_ERR(inode)) {