diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-01-29 15:55:23 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:00 -0400 |
commit | 291d673e6a22d9c6834e939f66c7cfef90669021 (patch) | |
tree | 841e9be40bb5fbf7c978c789ee67183cef596686 /fs/btrfs/extent_io.c | |
parent | 9c58309d6cf22471dacbcb6de54d00cef9ca20d4 (diff) |
Btrfs: Do delalloc accounting via hooks in the extent_state code
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r-- | fs/btrfs/extent_io.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 8aec72253a17..e81b35b06187 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -256,6 +256,26 @@ static int merge_state(struct extent_io_tree *tree, | |||
256 | return 0; | 256 | return 0; |
257 | } | 257 | } |
258 | 258 | ||
259 | static void set_state_cb(struct extent_io_tree *tree, | ||
260 | struct extent_state *state, | ||
261 | unsigned long bits) | ||
262 | { | ||
263 | if (tree->ops && tree->ops->set_bit_hook) { | ||
264 | tree->ops->set_bit_hook(tree->mapping->host, state->start, | ||
265 | state->end, bits); | ||
266 | } | ||
267 | } | ||
268 | |||
269 | static void clear_state_cb(struct extent_io_tree *tree, | ||
270 | struct extent_state *state, | ||
271 | unsigned long bits) | ||
272 | { | ||
273 | if (tree->ops && tree->ops->set_bit_hook) { | ||
274 | tree->ops->clear_bit_hook(tree->mapping->host, state->start, | ||
275 | state->end, bits); | ||
276 | } | ||
277 | } | ||
278 | |||
259 | /* | 279 | /* |
260 | * insert an extent_state struct into the tree. 'bits' are set on the | 280 | * insert an extent_state struct into the tree. 'bits' are set on the |
261 | * struct before it is inserted. | 281 | * struct before it is inserted. |
@@ -281,6 +301,7 @@ static int insert_state(struct extent_io_tree *tree, | |||
281 | state->state |= bits; | 301 | state->state |= bits; |
282 | state->start = start; | 302 | state->start = start; |
283 | state->end = end; | 303 | state->end = end; |
304 | set_state_cb(tree, state, bits); | ||
284 | node = tree_insert(&tree->state, end, &state->rb_node); | 305 | node = tree_insert(&tree->state, end, &state->rb_node); |
285 | if (node) { | 306 | if (node) { |
286 | struct extent_state *found; | 307 | struct extent_state *found; |
@@ -349,6 +370,7 @@ static int clear_state_bit(struct extent_io_tree *tree, | |||
349 | tree->dirty_bytes -= range; | 370 | tree->dirty_bytes -= range; |
350 | } | 371 | } |
351 | state->state &= ~bits; | 372 | state->state &= ~bits; |
373 | clear_state_cb(tree, state, bits); | ||
352 | if (wake) | 374 | if (wake) |
353 | wake_up(&state->wq); | 375 | wake_up(&state->wq); |
354 | if (delete || state->state == 0) { | 376 | if (delete || state->state == 0) { |
@@ -553,6 +575,7 @@ static void set_state_bits(struct extent_io_tree *tree, | |||
553 | tree->dirty_bytes += range; | 575 | tree->dirty_bytes += range; |
554 | } | 576 | } |
555 | state->state |= bits; | 577 | state->state |= bits; |
578 | set_state_cb(tree, state, bits); | ||
556 | } | 579 | } |
557 | 580 | ||
558 | /* | 581 | /* |
@@ -975,6 +998,7 @@ search_again: | |||
975 | goto search_again; | 998 | goto search_again; |
976 | } | 999 | } |
977 | state->state |= EXTENT_LOCKED; | 1000 | state->state |= EXTENT_LOCKED; |
1001 | set_state_cb(tree, state, EXTENT_LOCKED); | ||
978 | if (!found) | 1002 | if (!found) |
979 | *start = state->start; | 1003 | *start = state->start; |
980 | found++; | 1004 | found++; |
@@ -1474,6 +1498,7 @@ static int end_bio_extent_readpage(struct bio *bio, | |||
1474 | state = NULL; | 1498 | state = NULL; |
1475 | } | 1499 | } |
1476 | clear->state |= EXTENT_UPTODATE; | 1500 | clear->state |= EXTENT_UPTODATE; |
1501 | set_state_cb(tree, clear, EXTENT_UPTODATE); | ||
1477 | clear_state_bit(tree, clear, EXTENT_LOCKED, | 1502 | clear_state_bit(tree, clear, EXTENT_LOCKED, |
1478 | 1, 0); | 1503 | 1, 0); |
1479 | if (cur == start) | 1504 | if (cur == start) |