summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-29 15:55:23 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:00 -0400
commit291d673e6a22d9c6834e939f66c7cfef90669021 (patch)
tree841e9be40bb5fbf7c978c789ee67183cef596686 /fs/btrfs/extent_io.c
parent9c58309d6cf22471dacbcb6de54d00cef9ca20d4 (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.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 8aec72253a1..e81b35b0618 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,
return 0;
}
+static void set_state_cb(struct extent_io_tree *tree,
+ struct extent_state *state,
+ unsigned long bits)
+{
+ if (tree->ops && tree->ops->set_bit_hook) {
+ tree->ops->set_bit_hook(tree->mapping->host, state->start,
+ state->end, bits);
+ }
+}
+
+static void clear_state_cb(struct extent_io_tree *tree,
+ struct extent_state *state,
+ unsigned long bits)
+{
+ if (tree->ops && tree->ops->set_bit_hook) {
+ tree->ops->clear_bit_hook(tree->mapping->host, state->start,
+ state->end, bits);
+ }
+}
+
/*
* insert an extent_state struct into the tree. 'bits' are set on the
* struct before it is inserted.
@@ -281,6 +301,7 @@ static int insert_state(struct extent_io_tree *tree,
state->state |= bits;
state->start = start;
state->end = end;
+ set_state_cb(tree, state, bits);
node = tree_insert(&tree->state, end, &state->rb_node);
if (node) {
struct extent_state *found;
@@ -349,6 +370,7 @@ static int clear_state_bit(struct extent_io_tree *tree,
tree->dirty_bytes -= range;
}
state->state &= ~bits;
+ clear_state_cb(tree, state, bits);
if (wake)
wake_up(&state->wq);
if (delete || state->state == 0) {
@@ -553,6 +575,7 @@ static void set_state_bits(struct extent_io_tree *tree,
tree->dirty_bytes += range;
}
state->state |= bits;
+ set_state_cb(tree, state, bits);
}
/*
@@ -975,6 +998,7 @@ search_again:
goto search_again;
}
state->state |= EXTENT_LOCKED;
+ set_state_cb(tree, state, EXTENT_LOCKED);
if (!found)
*start = state->start;
found++;
@@ -1474,6 +1498,7 @@ static int end_bio_extent_readpage(struct bio *bio,
state = NULL;
}
clear->state |= EXTENT_UPTODATE;
+ set_state_cb(tree, clear, EXTENT_UPTODATE);
clear_state_bit(tree, clear, EXTENT_LOCKED,
1, 0);
if (cur == start)