From: Liu Bo Date: Mon, 23 Jul 2012 11:50:03 +0000 (-0600) Subject: Btrfs: make btrfs's allocation smoothly with preallocation X-Git-Tag: upstream/snapshot3+hdmi~6698^2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df57dbe6bf73cc44305d81c24982a11da49b1f79;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git Btrfs: make btrfs's allocation smoothly with preallocation For backref walking, we've introduce delayed ref's sequence. However, it changes our preallocation behavior. The story is that when we preallocate an extent and then mark it written piece by piece, the ideal case should be that we don't need to COW the extent, which is why we use 'preallocate'. But we may not make use of preallocation, since when we check for cross refs on the extent, we may have two ref entries which have the same content except the sequence value, and we recognize them as cross refs and do COW to allocate another extent. So we end up with several pieces of space instead of an whole extent. Signed-off-by: Liu Bo Signed-off-by: Josef Bacik --- diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 6621ed7..71b2d1c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -2581,8 +2581,10 @@ static noinline int check_delayed_ref(struct btrfs_trans_handle *trans, node = rb_prev(node); if (node) { + int seq = ref->seq; + ref = rb_entry(node, struct btrfs_delayed_ref_node, rb_node); - if (ref->bytenr == bytenr) + if (ref->bytenr == bytenr && ref->seq == seq) goto out_unlock; }