btrfs: split extent_state ops
set_extent_bit can do exclusive locking but only when called by lock_extent*, Drop the exclusive bits argument except when called by lock_extent. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
committed by
David Sterba
parent
d0082371cf
commit
3fbe5c02ae
@@ -721,9 +721,10 @@ static void uncache_state(struct extent_state **cached_ptr)
|
|||||||
* [start, end] is inclusive This takes the tree lock.
|
* [start, end] is inclusive This takes the tree lock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
|
static int __must_check
|
||||||
int bits, int exclusive_bits, u64 *failed_start,
|
__set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
struct extent_state **cached_state, gfp_t mask)
|
int bits, int exclusive_bits, u64 *failed_start,
|
||||||
|
struct extent_state **cached_state, gfp_t mask)
|
||||||
{
|
{
|
||||||
struct extent_state *state;
|
struct extent_state *state;
|
||||||
struct extent_state *prealloc = NULL;
|
struct extent_state *prealloc = NULL;
|
||||||
@@ -917,6 +918,15 @@ search_again:
|
|||||||
goto again;
|
goto again;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int bits,
|
||||||
|
u64 *failed_start, struct extent_state **cached_state,
|
||||||
|
gfp_t mask)
|
||||||
|
{
|
||||||
|
return __set_extent_bit(tree, start, end, bits, 0, failed_start,
|
||||||
|
cached_state, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convert_extent - convert all bits in a given range from one bit to another
|
* convert_extent - convert all bits in a given range from one bit to another
|
||||||
* @tree: the io tree to search
|
* @tree: the io tree to search
|
||||||
@@ -1111,14 +1121,14 @@ search_again:
|
|||||||
int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
|
int set_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
gfp_t mask)
|
gfp_t mask)
|
||||||
{
|
{
|
||||||
return set_extent_bit(tree, start, end, EXTENT_DIRTY, 0, NULL,
|
return set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL,
|
||||||
NULL, mask);
|
NULL, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
|
int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
int bits, gfp_t mask)
|
int bits, gfp_t mask)
|
||||||
{
|
{
|
||||||
return set_extent_bit(tree, start, end, bits, 0, NULL,
|
return set_extent_bit(tree, start, end, bits, NULL,
|
||||||
NULL, mask);
|
NULL, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1133,7 +1143,7 @@ int set_extent_delalloc(struct extent_io_tree *tree, u64 start, u64 end,
|
|||||||
{
|
{
|
||||||
return set_extent_bit(tree, start, end,
|
return set_extent_bit(tree, start, end,
|
||||||
EXTENT_DELALLOC | EXTENT_UPTODATE,
|
EXTENT_DELALLOC | EXTENT_UPTODATE,
|
||||||
0, NULL, cached_state, mask);
|
NULL, cached_state, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
|
int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
@@ -1147,7 +1157,7 @@ int clear_extent_dirty(struct extent_io_tree *tree, u64 start, u64 end,
|
|||||||
int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end,
|
int set_extent_new(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
gfp_t mask)
|
gfp_t mask)
|
||||||
{
|
{
|
||||||
return set_extent_bit(tree, start, end, EXTENT_NEW, 0, NULL,
|
return set_extent_bit(tree, start, end, EXTENT_NEW, NULL,
|
||||||
NULL, mask);
|
NULL, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1155,7 +1165,7 @@ int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
|
|||||||
struct extent_state **cached_state, gfp_t mask)
|
struct extent_state **cached_state, gfp_t mask)
|
||||||
{
|
{
|
||||||
return set_extent_bit(tree, start, end, EXTENT_UPTODATE, 0,
|
return set_extent_bit(tree, start, end, EXTENT_UPTODATE, 0,
|
||||||
NULL, cached_state, mask);
|
cached_state, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
|
static int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
|
||||||
@@ -1176,9 +1186,9 @@ int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
|
|||||||
int err;
|
int err;
|
||||||
u64 failed_start;
|
u64 failed_start;
|
||||||
while (1) {
|
while (1) {
|
||||||
err = set_extent_bit(tree, start, end, EXTENT_LOCKED | bits,
|
err = __set_extent_bit(tree, start, end, EXTENT_LOCKED | bits,
|
||||||
EXTENT_LOCKED, &failed_start,
|
EXTENT_LOCKED, &failed_start,
|
||||||
cached_state, GFP_NOFS);
|
cached_state, GFP_NOFS);
|
||||||
if (err == -EEXIST) {
|
if (err == -EEXIST) {
|
||||||
wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED);
|
wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED);
|
||||||
start = failed_start;
|
start = failed_start;
|
||||||
@@ -1199,8 +1209,8 @@ int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end)
|
|||||||
int err;
|
int err;
|
||||||
u64 failed_start;
|
u64 failed_start;
|
||||||
|
|
||||||
err = set_extent_bit(tree, start, end, EXTENT_LOCKED, EXTENT_LOCKED,
|
err = __set_extent_bit(tree, start, end, EXTENT_LOCKED, EXTENT_LOCKED,
|
||||||
&failed_start, NULL, GFP_NOFS);
|
&failed_start, NULL, GFP_NOFS);
|
||||||
if (err == -EEXIST) {
|
if (err == -EEXIST) {
|
||||||
if (failed_start > start)
|
if (failed_start > start)
|
||||||
clear_extent_bit(tree, start, failed_start - 1,
|
clear_extent_bit(tree, start, failed_start - 1,
|
||||||
|
@@ -209,7 +209,7 @@ int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
|
|||||||
int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
|
int set_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
int bits, gfp_t mask);
|
int bits, gfp_t mask);
|
||||||
int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
|
int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
int bits, int exclusive_bits, u64 *failed_start,
|
int bits, u64 *failed_start,
|
||||||
struct extent_state **cached_state, gfp_t mask);
|
struct extent_state **cached_state, gfp_t mask);
|
||||||
int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
|
int set_extent_uptodate(struct extent_io_tree *tree, u64 start, u64 end,
|
||||||
struct extent_state **cached_state, gfp_t mask);
|
struct extent_state **cached_state, gfp_t mask);
|
||||||
|
@@ -6233,7 +6233,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
|
|||||||
if (writing) {
|
if (writing) {
|
||||||
write_bits = EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING;
|
write_bits = EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING;
|
||||||
ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend,
|
ret = set_extent_bit(&BTRFS_I(inode)->io_tree, lockstart, lockend,
|
||||||
EXTENT_DELALLOC, 0, NULL, &cached_state,
|
EXTENT_DELALLOC, NULL, &cached_state,
|
||||||
GFP_NOFS);
|
GFP_NOFS);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
|
clear_extent_bit(&BTRFS_I(inode)->io_tree, lockstart,
|
||||||
|
Reference in New Issue
Block a user