Btrfs: Do delalloc accounting via hooks in the extent_state code

Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Chris Mason
2008-01-29 15:55:23 -05:00
parent 9c58309d6c
commit 291d673e6a
5 changed files with 53 additions and 46 deletions

View File

@@ -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)