summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-defrag.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-11-06 16:26:29 +0100
committerChris Mason <chris.mason@oracle.com>2008-09-25 17:03:57 +0200
commitf84a8b362d9785ca1fa0598d8a90f35184bd8750 (patch)
tree5161beaf9981b793a3efb1034bef8715bc456572 /fs/btrfs/tree-defrag.c
parentFix EXTENT_MAP_INLINE off by one in btrfs_drop_extents (diff)
downloadlinux-f84a8b362d9785ca1fa0598d8a90f35184bd8750.tar.xz
linux-f84a8b362d9785ca1fa0598d8a90f35184bd8750.zip
Btrfs: Optimize allocations as we need to mix data and metadata into one group
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/tree-defrag.c')
-rw-r--r--fs/btrfs/tree-defrag.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index 6ef1ba5f9c2f..3994795edfeb 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -58,6 +58,10 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans,
if (root->fs_info->extent_root == root)
is_extent = 1;
+ if (*level == 1 && cache_only && path->nodes[1] &&
+ !btrfs_buffer_defrag(path->nodes[1])) {
+ goto out;
+ }
while(*level > 0) {
WARN_ON(*level < 0);
WARN_ON(*level >= BTRFS_MAX_LEVEL);
@@ -116,7 +120,7 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans,
WARN_ON(*level >= BTRFS_MAX_LEVEL);
btrfs_clear_buffer_defrag(path->nodes[*level]);
-
+out:
free_extent_buffer(path->nodes[*level]);
path->nodes[*level] = NULL;
*level += 1;