summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2009-05-27 09:16:03 -0400
committerChris Mason <chris.mason@oracle.com>2009-06-10 11:29:46 -0400
commit5c939df56c3ea018b58e5aa76181284c2053d699 (patch)
tree6d97449faa69c96998833fcb56a3b65050d34354 /fs
parent07a2039b8eb0af4ff464efd3dfd95de5c02648c6 (diff)
downloadblackbird-obmc-linux-5c939df56c3ea018b58e5aa76181284c2053d699.tar.gz
blackbird-obmc-linux-5c939df56c3ea018b58e5aa76181284c2053d699.zip
btrfs: Fix set/clear_extent_bit for 'end == (u64)-1'
There are some 'start = state->end + 1;' like code in set_extent_bit and clear_extent_bit. They overflow when end == (u64)-1. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/extent_io.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index fe9eb990e443..68260180f587 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -476,6 +476,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
struct extent_state *state;
struct extent_state *prealloc = NULL;
struct rb_node *node;
+ u64 last_end;
int err;
int set = 0;
@@ -498,6 +499,7 @@ again:
if (state->start > end)
goto out;
WARN_ON(state->end < start);
+ last_end = state->end;
/*
* | ---- desired range ---- |
@@ -524,9 +526,11 @@ again:
if (err)
goto out;
if (state->end <= end) {
- start = state->end + 1;
set |= clear_state_bit(tree, state, bits,
wake, delete);
+ if (last_end == (u64)-1)
+ goto out;
+ start = last_end + 1;
} else {
start = state->start;
}
@@ -552,8 +556,10 @@ again:
goto out;
}
- start = state->end + 1;
set |= clear_state_bit(tree, state, bits, wake, delete);
+ if (last_end == (u64)-1)
+ goto out;
+ start = last_end + 1;
goto search_again;
out:
@@ -707,8 +713,10 @@ again:
goto out;
}
set_state_bits(tree, state, bits);
- start = state->end + 1;
merge_state(tree, state);
+ if (last_end == (u64)-1)
+ goto out;
+ start = last_end + 1;
goto search_again;
}
@@ -742,8 +750,10 @@ again:
goto out;
if (state->end <= end) {
set_state_bits(tree, 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;
}
OpenPOWER on IntegriCloud