summaryrefslogtreecommitdiff
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-08-10 18:06:19 (GMT)
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-10 18:06:19 (GMT)
commite9d0b13b5bbb58c9b840e407a8d181442f799966 (patch)
treed51a7e111a824e883c347c83745109400231de1c /fs/btrfs/ctree.c
parent409eb95d7f6632d5af32b795244ce68a29e49319 (diff)
downloadlinux-e9d0b13b5bbb58c9b840e407a8d181442f799966.tar.xz
Btrfs: Btree defrag on the extent-mapping tree as well
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index c7e47e7..ee1ae00 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -99,7 +99,6 @@ static int __btrfs_cow_block(struct btrfs_trans_handle *trans, struct btrfs_root
if (ret)
return ret;
} else {
- WARN_ON(!root->ref_cows);
clean_tree_block(trans, root, buf);
}
@@ -162,13 +161,14 @@ static int close_blocks(u64 blocknr, u64 other)
int btrfs_realloc_node(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct buffer_head *parent,
- int cache_only)
+ int cache_only, u64 *last_ret)
{
struct btrfs_node *parent_node;
struct buffer_head *cur_bh;
struct buffer_head *tmp_bh;
u64 blocknr;
- u64 search_start = 0;
+ u64 search_start = *last_ret;
+ u64 last_block = 0;
u64 other;
u32 parent_nritems;
int start_slot;
@@ -198,6 +198,8 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
for (i = start_slot; i < end_slot; i++) {
int close = 1;
blocknr = btrfs_node_blockptr(parent_node, i);
+ if (last_block == 0)
+ last_block = blocknr;
if (i > 0) {
other = btrfs_node_blockptr(parent_node, i - 1);
close = close_blocks(blocknr, other);
@@ -206,8 +208,10 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
other = btrfs_node_blockptr(parent_node, i + 1);
close = close_blocks(blocknr, other);
}
- if (close)
+ if (close) {
+ last_block = blocknr;
continue;
+ }
cur_bh = btrfs_find_tree_block(root, blocknr);
if (!cur_bh || !buffer_uptodate(cur_bh) ||
@@ -219,9 +223,9 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
brelse(cur_bh);
cur_bh = read_tree_block(root, blocknr);
}
- if (search_start == 0) {
- search_start = bh_blocknr(cur_bh) & ~((u64)65535);
- }
+ if (search_start == 0)
+ search_start = last_block & ~((u64)65535);
+
err = __btrfs_cow_block(trans, root, cur_bh, parent, i,
&tmp_bh, search_start,
min(8, end_slot - i));