Commit 1cab5e72 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: merge __set_extent_bit and set_extent_bit

There are only 2 direct calls to set_extent_bit outside of extent-io -
in btrfs_find_new_delalloc_bytes and btrfs_truncate_block, the rest are
thin wrappers around __set_extent_bit. This adds unnecessary indirection
and just makes it more annoying when looking at the various extent bit
manipulation functions.  This patch renames __set_extent_bit to
set_extent_bit effectively removing a level of indirection. No
functional changes.
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
[ reformat and remove __must_check ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 729f7961
...@@ -168,14 +168,17 @@ static inline int clear_extent_bits(struct extent_io_tree *tree, u64 start, ...@@ -168,14 +168,17 @@ 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, int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
unsigned bits, struct extent_changeset *changeset); unsigned bits, struct extent_changeset *changeset);
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,
unsigned bits, struct extent_state **cached_state, gfp_t mask); unsigned bits, unsigned exclusive_bits, u64 *failed_start,
struct extent_state **cached_state, gfp_t mask,
struct extent_changeset *changeset);
int set_extent_bits_nowait(struct extent_io_tree *tree, u64 start, u64 end, int set_extent_bits_nowait(struct extent_io_tree *tree, u64 start, u64 end,
unsigned bits); unsigned bits);
static inline int set_extent_bits(struct extent_io_tree *tree, u64 start, static inline int set_extent_bits(struct extent_io_tree *tree, u64 start,
u64 end, unsigned bits) u64 end, unsigned bits)
{ {
return set_extent_bit(tree, start, end, bits, NULL, GFP_NOFS); return set_extent_bit(tree, start, end, bits, 0, NULL, NULL, GFP_NOFS,
NULL);
} }
static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
...@@ -188,7 +191,8 @@ static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start, ...@@ -188,7 +191,8 @@ 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, static inline int set_extent_dirty(struct extent_io_tree *tree, u64 start,
u64 end, gfp_t mask) u64 end, gfp_t mask)
{ {
return set_extent_bit(tree, start, end, EXTENT_DIRTY, NULL, mask); return set_extent_bit(tree, start, end, EXTENT_DIRTY, 0, NULL, NULL,
mask, NULL);
} }
static inline int clear_extent_dirty(struct extent_io_tree *tree, u64 start, static inline int clear_extent_dirty(struct extent_io_tree *tree, u64 start,
...@@ -209,7 +213,7 @@ static inline int set_extent_delalloc(struct extent_io_tree *tree, u64 start, ...@@ -209,7 +213,7 @@ static inline int set_extent_delalloc(struct extent_io_tree *tree, u64 start,
{ {
return set_extent_bit(tree, start, end, return set_extent_bit(tree, start, end,
EXTENT_DELALLOC | EXTENT_UPTODATE | extra_bits, EXTENT_DELALLOC | EXTENT_UPTODATE | extra_bits,
cached_state, GFP_NOFS); 0, NULL, cached_state, GFP_NOFS, NULL);
} }
static inline int set_extent_defrag(struct extent_io_tree *tree, u64 start, static inline int set_extent_defrag(struct extent_io_tree *tree, u64 start,
...@@ -217,20 +221,21 @@ static inline int set_extent_defrag(struct extent_io_tree *tree, u64 start, ...@@ -217,20 +221,21 @@ static inline int set_extent_defrag(struct extent_io_tree *tree, u64 start,
{ {
return set_extent_bit(tree, start, end, return set_extent_bit(tree, start, end,
EXTENT_DELALLOC | EXTENT_UPTODATE | EXTENT_DEFRAG, EXTENT_DELALLOC | EXTENT_UPTODATE | EXTENT_DEFRAG,
cached_state, GFP_NOFS); 0, NULL, cached_state, GFP_NOFS, NULL);
} }
static inline int set_extent_new(struct extent_io_tree *tree, u64 start, static inline int set_extent_new(struct extent_io_tree *tree, u64 start,
u64 end) u64 end)
{ {
return set_extent_bit(tree, start, end, EXTENT_NEW, NULL, GFP_NOFS); return set_extent_bit(tree, start, end, EXTENT_NEW, 0, NULL, NULL,
GFP_NOFS, NULL);
} }
static inline int set_extent_uptodate(struct extent_io_tree *tree, u64 start, static inline int set_extent_uptodate(struct extent_io_tree *tree, u64 start,
u64 end, struct extent_state **cached_state, gfp_t mask) u64 end, struct extent_state **cached_state, gfp_t mask)
{ {
return set_extent_bit(tree, start, end, EXTENT_UPTODATE, return set_extent_bit(tree, start, end, EXTENT_UPTODATE, 0, NULL,
cached_state, mask); cached_state, mask, NULL);
} }
int find_first_extent_bit(struct extent_io_tree *tree, u64 start, int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
......
...@@ -961,12 +961,10 @@ static void cache_state(struct extent_state *state, ...@@ -961,12 +961,10 @@ static void cache_state(struct extent_state *state,
* *
* [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, unsigned bits,
static int __must_check unsigned 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,
unsigned bits, unsigned exclusive_bits, struct extent_changeset *changeset)
u64 *failed_start, struct extent_state **cached_state,
gfp_t mask, struct extent_changeset *changeset)
{ {
struct extent_state *state; struct extent_state *state;
struct extent_state *prealloc = NULL; struct extent_state *prealloc = NULL;
...@@ -1183,14 +1181,6 @@ __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -1183,14 +1181,6 @@ __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,
unsigned bits, struct extent_state **cached_state, gfp_t mask)
{
return __set_extent_bit(tree, start, end, bits, 0, NULL, cached_state,
mask, NULL);
}
/** /**
* convert_extent_bit - convert all bits in a given range from one bit to * convert_extent_bit - convert all bits in a given range from one bit to
* another * another
...@@ -1421,15 +1411,15 @@ int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -1421,15 +1411,15 @@ int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
*/ */
BUG_ON(bits & EXTENT_LOCKED); BUG_ON(bits & EXTENT_LOCKED);
return __set_extent_bit(tree, start, end, bits, 0, NULL, NULL, GFP_NOFS, return set_extent_bit(tree, start, end, bits, 0, NULL, NULL, GFP_NOFS,
changeset); changeset);
} }
int set_extent_bits_nowait(struct extent_io_tree *tree, u64 start, u64 end, int set_extent_bits_nowait(struct extent_io_tree *tree, u64 start, u64 end,
unsigned bits) unsigned bits)
{ {
return __set_extent_bit(tree, start, end, bits, 0, NULL, NULL, return set_extent_bit(tree, start, end, bits, 0, NULL, NULL,
GFP_NOWAIT, NULL); GFP_NOWAIT, NULL);
} }
int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end, int clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
...@@ -1464,9 +1454,9 @@ int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end, ...@@ -1464,9 +1454,9 @@ int lock_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
u64 failed_start; u64 failed_start;
while (1) { while (1) {
err = __set_extent_bit(tree, start, end, EXTENT_LOCKED, err = set_extent_bit(tree, start, end, EXTENT_LOCKED,
EXTENT_LOCKED, &failed_start, EXTENT_LOCKED, &failed_start,
cached_state, GFP_NOFS, NULL); cached_state, GFP_NOFS, NULL);
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;
...@@ -1482,8 +1472,8 @@ int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end) ...@@ -1482,8 +1472,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, NULL); &failed_start, NULL, GFP_NOFS, NULL);
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,
......
...@@ -2340,8 +2340,8 @@ static int btrfs_find_new_delalloc_bytes(struct btrfs_inode *inode, ...@@ -2340,8 +2340,8 @@ static int btrfs_find_new_delalloc_bytes(struct btrfs_inode *inode,
ret = set_extent_bit(&inode->io_tree, search_start, ret = set_extent_bit(&inode->io_tree, search_start,
search_start + em_len - 1, search_start + em_len - 1,
EXTENT_DELALLOC_NEW, EXTENT_DELALLOC_NEW, 0, NULL, cached_state,
NULL, cached_state, GFP_NOFS); GFP_NOFS, NULL);
next: next:
search_start = extent_map_end(em); search_start = extent_map_end(em);
free_extent_map(em); free_extent_map(em);
...@@ -4769,7 +4769,7 @@ int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len, ...@@ -4769,7 +4769,7 @@ int btrfs_truncate_block(struct btrfs_inode *inode, loff_t from, loff_t len,
if (only_release_metadata) if (only_release_metadata)
set_extent_bit(&inode->io_tree, block_start, block_end, set_extent_bit(&inode->io_tree, block_start, block_end,
EXTENT_NORESERVE, NULL, GFP_NOFS); EXTENT_NORESERVE, 0, NULL, NULL, GFP_NOFS, NULL);
out_unlock: out_unlock:
if (ret) { if (ret) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment