Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297858
b: refs/heads/master
c: c2d904e
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Mahoney authored and David Sterba committed Mar 22, 2012
1 parent 60b2788 commit 96c4151
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8c3429300181be44b30f9f017d53dc717da56caa
refs/heads/master: c2d904e086b6f707b73bf065e4d18ded4b86ae9e
58 changes: 38 additions & 20 deletions trunk/fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ struct extent_page_data {
unsigned int sync_io:1;
};

static inline struct btrfs_fs_info *
tree_fs_info(struct extent_io_tree *tree)
{
return btrfs_sb(tree->mapping->host->i_sb);
}

int __init extent_io_init(void)
{
extent_state_cache = kmem_cache_create("extent_state",
Expand Down Expand Up @@ -439,6 +445,13 @@ alloc_extent_state_atomic(struct extent_state *prealloc)
return prealloc;
}

void extent_io_tree_panic(struct extent_io_tree *tree, int err)
{
btrfs_panic(tree_fs_info(tree), err, "Locking error: "
"Extent tree was modified by another "
"thread while locked.");
}

/*
* clear some bits on a range in the tree. This may require splitting
* or inserting elements in the tree, so the gfp mask is used to
Expand Down Expand Up @@ -542,7 +555,9 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, start);
BUG_ON(err == -EEXIST);
if (err)
extent_io_tree_panic(tree, err);

prealloc = NULL;
if (err)
goto out;
Expand All @@ -564,7 +579,9 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, end + 1);
BUG_ON(err == -EEXIST);
if (err)
extent_io_tree_panic(tree, err);

if (wake)
wake_up(&state->wq);

Expand Down Expand Up @@ -742,8 +759,10 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = insert_state(tree, prealloc, start, end, &bits);
if (err)
extent_io_tree_panic(tree, err);

prealloc = NULL;
BUG_ON(err == -EEXIST);
goto out;
}
state = rb_entry(node, struct extent_state, rb_node);
Expand Down Expand Up @@ -809,7 +828,9 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, start);
BUG_ON(err == -EEXIST);
if (err)
extent_io_tree_panic(tree, err);

prealloc = NULL;
if (err)
goto out;
Expand Down Expand Up @@ -846,12 +867,9 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
*/
err = insert_state(tree, prealloc, start, this_end,
&bits);
BUG_ON(err == -EEXIST);
if (err) {
free_extent_state(prealloc);
prealloc = NULL;
goto out;
}
if (err)
extent_io_tree_panic(tree, err);

cache_state(prealloc, cached_state);
prealloc = NULL;
start = this_end + 1;
Expand All @@ -873,7 +891,8 @@ int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
prealloc = alloc_extent_state_atomic(prealloc);
BUG_ON(!prealloc);
err = split_state(tree, state, prealloc, end + 1);
BUG_ON(err == -EEXIST);
if (err)
extent_io_tree_panic(tree, err);

set_state_bits(tree, prealloc, &bits);
cache_state(prealloc, cached_state);
Expand Down Expand Up @@ -946,7 +965,8 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
}
err = insert_state(tree, prealloc, start, end, &bits);
prealloc = NULL;
BUG_ON(err == -EEXIST);
if (err)
extent_io_tree_panic(tree, err);
goto out;
}
state = rb_entry(node, struct extent_state, rb_node);
Expand Down Expand Up @@ -1002,7 +1022,8 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
goto out;
}
err = split_state(tree, state, prealloc, start);
BUG_ON(err == -EEXIST);
if (err)
extent_io_tree_panic(tree, err);
prealloc = NULL;
if (err)
goto out;
Expand Down Expand Up @@ -1041,12 +1062,8 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
*/
err = insert_state(tree, prealloc, start, this_end,
&bits);
BUG_ON(err == -EEXIST);
if (err) {
free_extent_state(prealloc);
prealloc = NULL;
goto out;
}
if (err)
extent_io_tree_panic(tree, err);
prealloc = NULL;
start = this_end + 1;
goto search_again;
Expand All @@ -1065,7 +1082,8 @@ int convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
}

err = split_state(tree, state, prealloc, end + 1);
BUG_ON(err == -EEXIST);
if (err)
extent_io_tree_panic(tree, err);

set_state_bits(tree, prealloc, &bits);
clear_state_bit(tree, prealloc, &clear_bits, 0);
Expand Down

0 comments on commit 96c4151

Please sign in to comment.