From 95d3f20b51e9b2ee21822313ad4f31279396407b Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Fri, 29 May 2009 16:35:30 -0400 Subject: Mixed back reference (FORWARD ROLLING FORMAT CHANGE) This commit introduces a new kind of back reference for btrfs metadata. Once a filesystem has been mounted with this commit, IT WILL NO LONGER BE MOUNTABLE BY OLDER KERNELS. The new back ref provides information about pointer's key, level and in which tree the pointer lives. This information allow us to find the pointer by searching the tree. The shortcoming of the new back ref is that it only works for pointers in tree blocks referenced by their owner trees. This is mostly a problem for snapshots, where resolving one of these fuzzy back references would be O(number_of_snapshots) and quite slow. The solution used here is to use the fuzzy back references in the common case where a given tree block is only referenced by one root, and use the full back references when multiple roots have a reference --- extent_io.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'extent_io.c') diff --git a/extent_io.c b/extent_io.c index 4920b291..069c199c 100644 --- a/extent_io.c +++ b/extent_io.c @@ -202,6 +202,7 @@ int clear_extent_bits(struct extent_io_tree *tree, u64 start, struct extent_state *state; struct extent_state *prealloc = NULL; struct cache_extent *node; + u64 last_end; int err; int set = 0; @@ -220,6 +221,7 @@ again: state = container_of(node, struct extent_state, cache_node); if (state->start > end) goto out; + last_end = state->end; /* * | ---- desired range ---- | @@ -243,8 +245,10 @@ again: if (err) goto out; if (state->end <= end) { - start = state->end + 1; set |= clear_state_bit(tree, state, bits); + if (last_end == (u64)-1) + goto out; + start = last_end + 1; } else { start = state->start; } @@ -267,6 +271,9 @@ again: start = state->end + 1; set |= clear_state_bit(tree, state, bits); + if (last_end == (u64)-1) + goto out; + start = last_end + 1; goto search_again; out: if (prealloc) @@ -322,8 +329,10 @@ again: if (state->start == start && state->end <= end) { set = state->state & bits; state->state |= bits; - start = state->end + 1; merge_state(tree, state); + if (last_end == (u64)-1) + goto out; + start = last_end + 1; goto search_again; } /* @@ -353,6 +362,9 @@ again: state->state |= bits; start = state->end + 1; merge_state(tree, state); + if (last_end == (u64)-1) + goto out; + start = last_end + 1; } else { start = state->start; } -- cgit v1.2.3