btrfs: remove failed_start argument from set_extent_bit

This is only used for internal locking related helpers, everybody else
just passes in NULL.  I've changed set_extent_bit to __set_extent_bit
and made it static, removed failed_start from set_extent_bit and have it
call __set_extent_bit with a NULL failed_start, and I've moved some code
down below the now static __set_extent_bit.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Josef Bacik 2022-09-09 17:53:41 -04:00 committed by David Sterba
parent dbbf49928f
commit 994bcd1eae
3 changed files with 30 additions and 26 deletions

View File

@ -954,10 +954,10 @@ out:
*
* [start, end] is inclusive This takes the tree lock.
*/
int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
u32 bits, u64 *failed_start,
struct extent_state **cached_state, gfp_t mask,
struct extent_changeset *changeset)
static int __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
u32 bits, u64 *failed_start,
struct extent_state **cached_state,
struct extent_changeset *changeset, gfp_t mask)
{
struct extent_state *state;
struct extent_state *prealloc = NULL;
@ -1169,6 +1169,14 @@ out:
}
int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
u32 bits, struct extent_state **cached_state, gfp_t mask,
struct extent_changeset *changeset)
{
return __set_extent_bit(tree, start, end, bits, NULL, cached_state,
changeset, mask);
}
/*
* Convert all bits in a given range from one bit to another
*
@ -1605,8 +1613,8 @@ int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
*/
ASSERT(!(bits & EXTENT_LOCKED));
return set_extent_bit(tree, start, end, bits, NULL, NULL, GFP_NOFS,
changeset);
return __set_extent_bit(tree, start, end, bits, NULL, NULL, changeset,
GFP_NOFS);
}
int clear_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
@ -1627,8 +1635,8 @@ int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end)
int err;
u64 failed_start;
err = set_extent_bit(tree, start, end, EXTENT_LOCKED, &failed_start,
NULL, GFP_NOFS, NULL);
err = __set_extent_bit(tree, start, end, EXTENT_LOCKED, &failed_start,
NULL, NULL, GFP_NOFS);
if (err == -EEXIST) {
if (failed_start > start)
clear_extent_bit(tree, start, failed_start - 1,
@ -1649,9 +1657,9 @@ int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
u64 failed_start;
while (1) {
err = set_extent_bit(tree, start, end, EXTENT_LOCKED,
&failed_start, cached_state, GFP_NOFS,
NULL);
err = __set_extent_bit(tree, start, end, EXTENT_LOCKED,
&failed_start, cached_state, NULL,
GFP_NOFS);
if (err == -EEXIST) {
wait_extent_bit(tree, failed_start, end, EXTENT_LOCKED);
start = failed_start;

View File

@ -160,22 +160,19 @@ static inline int clear_extent_bits(struct extent_io_tree *tree, u64 start,
int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
u32 bits, struct extent_changeset *changeset);
int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
u32 bits, u64 *failed_start,
struct extent_state **cached_state, gfp_t mask,
u32 bits, struct extent_state **cached_state, gfp_t mask,
struct extent_changeset *changeset);
static inline int set_extent_bits_nowait(struct extent_io_tree *tree, u64 start,
u64 end, u32 bits)
{
return set_extent_bit(tree, start, end, bits, NULL, NULL, GFP_NOWAIT,
NULL);
return set_extent_bit(tree, start, end, bits, NULL, GFP_NOWAIT, NULL);
}
static inline int set_extent_bits(struct extent_io_tree *tree, u64 start,
u64 end, u32 bits)
{
return set_extent_bit(tree, start, end, bits, NULL, NULL, GFP_NOFS,
NULL);
return set_extent_bit(tree, start, end, bits, NULL, GFP_NOFS, NULL);
}
static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
@ -188,8 +185,7 @@ static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
static inline int set_extent_dirty(struct extent_io_tree *tree, u64 start,
u64 end, gfp_t mask)
{
return set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, NULL, mask,
NULL);
return set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, mask, NULL);
}
static inline int clear_extent_dirty(struct extent_io_tree *tree, u64 start,
@ -210,7 +206,7 @@ static inline int set_extent_delalloc(struct extent_io_tree *tree, u64 start,
{
return set_extent_bit(tree, start, end,
EXTENT_DELALLOC | extra_bits,
NULL, cached_state, GFP_NOFS, NULL);
cached_state, GFP_NOFS, NULL);
}
static inline int set_extent_defrag(struct extent_io_tree *tree, u64 start,
@ -218,20 +214,20 @@ static inline int set_extent_defrag(struct extent_io_tree *tree, u64 start,
{
return set_extent_bit(tree, start, end,
EXTENT_DELALLOC | EXTENT_DEFRAG,
NULL, cached_state, GFP_NOFS, NULL);
cached_state, GFP_NOFS, NULL);
}
static inline int set_extent_new(struct extent_io_tree *tree, u64 start,
u64 end)
{
return set_extent_bit(tree, start, end, EXTENT_NEW, NULL, NULL,
GFP_NOFS, NULL);
return set_extent_bit(tree, start, end, EXTENT_NEW, NULL, GFP_NOFS,
NULL);
}
static inline int set_extent_uptodate(struct extent_io_tree *tree, u64 start,
u64 end, struct extent_state **cached_state, gfp_t mask)
{
return set_extent_bit(tree, start, end, EXTENT_UPTODATE, NULL,
return set_extent_bit(tree, start, end, EXTENT_UPTODATE,
cached_state, mask, NULL);
}

View File

@ -2815,7 +2815,7 @@ static int btrfs_find_new_delalloc_bytes(struct btrfs_inode *inode,
ret = set_extent_bit(&inode->io_tree, search_start,
search_start + em_len - 1,
EXTENT_DELALLOC_NEW, NULL, cached_state,
EXTENT_DELALLOC_NEW, cached_state,
GFP_NOFS, NULL);
next:
search_start = extent_map_end(em);
@ -4962,7 +4962,7 @@ again:
if (only_release_metadata)
set_extent_bit(&inode->io_tree, block_start, block_end,
EXTENT_NORESERVE, NULL, NULL, GFP_NOFS, NULL);
EXTENT_NORESERVE, NULL, GFP_NOFS, NULL);
out_unlock:
if (ret) {