aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_map.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-09-10 20:00:27 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-09-10 20:00:27 -0400
commita8c450b211c010ac55190da23ceb6b39b393f411 (patch)
tree0582abbf328a9635fd49b8165e102715e8f9c470 /fs/btrfs/extent_map.c
parent011410bd859a481a335d7db1fb559542c5663fd5 (diff)
Btrfs: Reorder tests in set_extent_bit to properly find holes
Yan Zheng noticed that set_extent_bit was exiting too early when there was a hole in the map. The fix is to reorder the tests to check for the hole first. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_map.c')
-rw-r--r--fs/btrfs/extent_map.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 33f7a18dddf7..370ed97e52f5 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -714,28 +714,6 @@ again:
714 } 714 }
715 /* 715 /*
716 * | ---- desired range ---- | 716 * | ---- desired range ---- |
717 * | state |
718 * We need to split the extent, and set the bit
719 * on the first half
720 */
721 if (state->start <= end && state->end > end) {
722 set = state->state & bits;
723 if (exclusive && set) {
724 *failed_start = start;
725 err = -EEXIST;
726 goto out;
727 }
728 err = split_state(tree, state, prealloc, end + 1);
729 BUG_ON(err == -EEXIST);
730
731 prealloc->state |= bits;
732 merge_state(tree, prealloc);
733 prealloc = NULL;
734 goto out;
735 }
736
737 /*
738 * | ---- desired range ---- |
739 * | state | or | state | 717 * | state | or | state |
740 * 718 *
741 * There's a hole, we need to insert something in it and 719 * There's a hole, we need to insert something in it and
@@ -756,6 +734,28 @@ again:
756 start = this_end + 1; 734 start = this_end + 1;
757 goto search_again; 735 goto search_again;
758 } 736 }
737 /*
738 * | ---- desired range ---- |
739 * | state |
740 * We need to split the extent, and set the bit
741 * on the first half
742 */
743 if (state->start <= end && state->end > end) {
744 set = state->state & bits;
745 if (exclusive && set) {
746 *failed_start = start;
747 err = -EEXIST;
748 goto out;
749 }
750 err = split_state(tree, state, prealloc, end + 1);
751 BUG_ON(err == -EEXIST);
752
753 prealloc->state |= bits;
754 merge_state(tree, prealloc);
755 prealloc = NULL;
756 goto out;
757 }
758
759 goto search_again; 759 goto search_again;
760 760
761out: 761out: