Skip to content

Commit

Permalink
Btrfs: make uncache_state unconditional
Browse files Browse the repository at this point in the history
The extent_io code can take cached pointers into the extent state trees,
and these can make lookups much faster in common operations.  The
caching only happens when specific bits are set that prevent merging
and splitting of the extent state.

A help function was added to uncache the state, and it was testing
the same set of conditionals.  This can leak in very strange corner
cases where the lock bit goes away unexpectedly.

The uncaching should be unconditional.  Once we have a ref on the
extent we should always give it up.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed Apr 13, 2011
1 parent 874d0d2 commit 109b36a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,8 @@ static void uncache_state(struct extent_state **cached_ptr)
{
if (cached_ptr && (*cached_ptr)) {
struct extent_state *state = *cached_ptr;
if (state->state & (EXTENT_IOBITS | EXTENT_BOUNDARY)) {
*cached_ptr = NULL;
free_extent_state(state);
}
*cached_ptr = NULL;
free_extent_state(state);
}
}

Expand Down Expand Up @@ -1764,7 +1762,7 @@ static void end_bio_extent_readpage(struct bio *bio, int err)

spin_lock(&tree->lock);
state = find_first_extent_bit_state(tree, start, 0);
if (state) {
if (state && state->start == start) {
/*
* take a reference on the state, unlock will drop
* the ref
Expand Down

0 comments on commit 109b36a

Please sign in to comment.