diff mbox series

[6/9] btrfs: open code set_extent_bits

Message ID 016d0db9c71e15f4c39ea866ce82a425db55cf07.1684967923.git.dsterba@suse.com (mailing list archive)
State New, archived
Headers show
Series Parameter cleanups in extent state helpers | expand

Commit Message

David Sterba May 24, 2023, 11:04 p.m. UTC
This helper calls set_extent_bit with two more parameters set to default
values, but otherwise it's purpose is not clear.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/dev-replace.c           |  4 ++--
 fs/btrfs/extent-io-tree.h        |  6 ------
 fs/btrfs/extent-tree.c           | 10 +++++-----
 fs/btrfs/file-item.c             | 10 +++++-----
 fs/btrfs/relocation.c            | 11 ++++++-----
 fs/btrfs/tests/extent-io-tests.c | 11 ++++++-----
 6 files changed, 24 insertions(+), 28 deletions(-)

Comments

Christoph Hellwig May 25, 2023, 9:03 a.m. UTC | #1
On Thu, May 25, 2023 at 01:04:32AM +0200, David Sterba wrote:
> This helper calls set_extent_bit with two more parameters set to default
> values, but otherwise it's purpose is not clear.

... and the naming is confusing as f*%$ given that it doesn't set any
more or less bits thatn set_extent_bit.  Good riddance.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Qu Wenruo May 25, 2023, 10:34 a.m. UTC | #2
On 2023/5/25 07:04, David Sterba wrote:
> This helper calls set_extent_bit with two more parameters set to default
> values, but otherwise it's purpose is not clear.
>
> Signed-off-by: David Sterba <dsterba@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   fs/btrfs/dev-replace.c           |  4 ++--
>   fs/btrfs/extent-io-tree.h        |  6 ------
>   fs/btrfs/extent-tree.c           | 10 +++++-----
>   fs/btrfs/file-item.c             | 10 +++++-----
>   fs/btrfs/relocation.c            | 11 ++++++-----
>   fs/btrfs/tests/extent-io-tests.c | 11 ++++++-----
>   6 files changed, 24 insertions(+), 28 deletions(-)
>
> diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
> index 78696d331639..3a0fc57d5db9 100644
> --- a/fs/btrfs/dev-replace.c
> +++ b/fs/btrfs/dev-replace.c
> @@ -795,8 +795,8 @@ static int btrfs_set_target_alloc_state(struct btrfs_device *srcdev,
>   	while (!find_first_extent_bit(&srcdev->alloc_state, start,
>   				      &found_start, &found_end,
>   				      CHUNK_ALLOCATED, &cached_state)) {
> -		ret = set_extent_bits(&tgtdev->alloc_state, found_start,
> -				      found_end, CHUNK_ALLOCATED);
> +		ret = set_extent_bit(&tgtdev->alloc_state, found_start,
> +				     found_end, CHUNK_ALLOCATED, NULL, GFP_NOFS);
>   		if (ret)
>   			break;
>   		start = found_end + 1;
> diff --git a/fs/btrfs/extent-io-tree.h b/fs/btrfs/extent-io-tree.h
> index ef9d54cdee5c..5a53a4558366 100644
> --- a/fs/btrfs/extent-io-tree.h
> +++ b/fs/btrfs/extent-io-tree.h
> @@ -156,12 +156,6 @@ int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
>   int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
>   		   u32 bits, struct extent_state **cached_state, gfp_t mask);
>
> -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, GFP_NOFS);
> -}
> -
>   static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
>   		u64 end, struct extent_state **cached_state)
>   {
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 47cfb694cdbf..03b2a7c508b9 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -73,8 +73,8 @@ int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info,
>   			      u64 start, u64 num_bytes)
>   {
>   	u64 end = start + num_bytes - 1;
> -	set_extent_bits(&fs_info->excluded_extents, start, end,
> -			EXTENT_UPTODATE);
> +	set_extent_bit(&fs_info->excluded_extents, start, end,
> +		       EXTENT_UPTODATE, NULL, GFP_NOFS);
>   	return 0;
>   }
>
> @@ -5981,9 +5981,9 @@ static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed)
>   		ret = btrfs_issue_discard(device->bdev, start, len,
>   					  &bytes);
>   		if (!ret)
> -			set_extent_bits(&device->alloc_state, start,
> -					start + bytes - 1,
> -					CHUNK_TRIMMED);
> +			set_extent_bit(&device->alloc_state, start,
> +				       start + bytes - 1,
> +				       CHUNK_TRIMMED, NULL, GFP_NOFS);
>   		mutex_unlock(&fs_info->chunk_mutex);
>
>   		if (ret)
> diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
> index e74b9804bcde..1e364a7b74aa 100644
> --- a/fs/btrfs/file-item.c
> +++ b/fs/btrfs/file-item.c
> @@ -94,8 +94,8 @@ int btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start,
>
>   	if (btrfs_fs_incompat(inode->root->fs_info, NO_HOLES))
>   		return 0;
> -	return set_extent_bits(&inode->file_extent_tree, start, start + len - 1,
> -			       EXTENT_DIRTY);
> +	return set_extent_bit(&inode->file_extent_tree, start, start + len - 1,
> +			      EXTENT_DIRTY, NULL, GFP_NOFS);
>   }
>
>   /*
> @@ -438,9 +438,9 @@ blk_status_t btrfs_lookup_bio_sums(struct btrfs_bio *bbio)
>   			    BTRFS_DATA_RELOC_TREE_OBJECTID) {
>   				u64 file_offset = bbio->file_offset + bio_offset;
>
> -				set_extent_bits(&inode->io_tree, file_offset,
> -						file_offset + sectorsize - 1,
> -						EXTENT_NODATASUM);
> +				set_extent_bit(&inode->io_tree, file_offset,
> +					       file_offset + sectorsize - 1,
> +					       EXTENT_NODATASUM, NULL, GFP_NOFS);
>   			} else {
>   				btrfs_warn_rl(fs_info,
>   			"csum hole found for disk bytenr range [%llu, %llu)",
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 38cfbd38a819..1ed8b132fe2a 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -174,8 +174,9 @@ static void mark_block_processed(struct reloc_control *rc,
>   	    in_range(node->bytenr, rc->block_group->start,
>   		     rc->block_group->length)) {
>   		blocksize = rc->extent_root->fs_info->nodesize;
> -		set_extent_bits(&rc->processed_blocks, node->bytenr,
> -				node->bytenr + blocksize - 1, EXTENT_DIRTY);
> +		set_extent_bit(&rc->processed_blocks, node->bytenr,
> +			       node->bytenr + blocksize - 1, EXTENT_DIRTY,
> +			       NULL, GFP_NOFS);
>   	}
>   	node->processed = 1;
>   }
> @@ -3051,9 +3052,9 @@ static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
>   			u64 boundary_end = boundary_start +
>   					   fs_info->sectorsize - 1;
>
> -			set_extent_bits(&BTRFS_I(inode)->io_tree,
> -					boundary_start, boundary_end,
> -					EXTENT_BOUNDARY);
> +			set_extent_bit(&BTRFS_I(inode)->io_tree,
> +				       boundary_start, boundary_end,
> +				       EXTENT_BOUNDARY, NULL, GFP_NOFS);
>   		}
>   		unlock_extent(&BTRFS_I(inode)->io_tree, clamped_start, clamped_end,
>   			      &cached_state);
> diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
> index b9de94a50868..acaaddf7181a 100644
> --- a/fs/btrfs/tests/extent-io-tests.c
> +++ b/fs/btrfs/tests/extent-io-tests.c
> @@ -503,8 +503,8 @@ static int test_find_first_clear_extent_bit(void)
>   	 * Set 1M-4M alloc/discard and 32M-64M thus leaving a hole between
>   	 * 4M-32M
>   	 */
> -	set_extent_bits(&tree, SZ_1M, SZ_4M - 1,
> -			CHUNK_TRIMMED | CHUNK_ALLOCATED);
> +	set_extent_bit(&tree, SZ_1M, SZ_4M - 1,
> +		       CHUNK_TRIMMED | CHUNK_ALLOCATED, NULL, GFP_NOFS);
>
>   	find_first_clear_extent_bit(&tree, SZ_512K, &start, &end,
>   				    CHUNK_TRIMMED | CHUNK_ALLOCATED);
> @@ -516,8 +516,8 @@ static int test_find_first_clear_extent_bit(void)
>   	}
>
>   	/* Now add 32M-64M so that we have a hole between 4M-32M */
> -	set_extent_bits(&tree, SZ_32M, SZ_64M - 1,
> -			CHUNK_TRIMMED | CHUNK_ALLOCATED);
> +	set_extent_bit(&tree, SZ_32M, SZ_64M - 1,
> +		       CHUNK_TRIMMED | CHUNK_ALLOCATED, NULL, GFP_NOFS);
>
>   	/*
>   	 * Request first hole starting at 12M, we should get 4M-32M
> @@ -548,7 +548,8 @@ static int test_find_first_clear_extent_bit(void)
>   	 * Set 64M-72M with CHUNK_ALLOC flag, then search for CHUNK_TRIMMED flag
>   	 * being unset in this range, we should get the entry in range 64M-72M
>   	 */
> -	set_extent_bits(&tree, SZ_64M, SZ_64M + SZ_8M - 1, CHUNK_ALLOCATED);
> +	set_extent_bit(&tree, SZ_64M, SZ_64M + SZ_8M - 1, CHUNK_ALLOCATED, NULL,
> +		       GFP_NOFS);
>   	find_first_clear_extent_bit(&tree, SZ_64M + SZ_1M, &start, &end,
>   				    CHUNK_TRIMMED);
>
diff mbox series

Patch

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index 78696d331639..3a0fc57d5db9 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -795,8 +795,8 @@  static int btrfs_set_target_alloc_state(struct btrfs_device *srcdev,
 	while (!find_first_extent_bit(&srcdev->alloc_state, start,
 				      &found_start, &found_end,
 				      CHUNK_ALLOCATED, &cached_state)) {
-		ret = set_extent_bits(&tgtdev->alloc_state, found_start,
-				      found_end, CHUNK_ALLOCATED);
+		ret = set_extent_bit(&tgtdev->alloc_state, found_start,
+				     found_end, CHUNK_ALLOCATED, NULL, GFP_NOFS);
 		if (ret)
 			break;
 		start = found_end + 1;
diff --git a/fs/btrfs/extent-io-tree.h b/fs/btrfs/extent-io-tree.h
index ef9d54cdee5c..5a53a4558366 100644
--- a/fs/btrfs/extent-io-tree.h
+++ b/fs/btrfs/extent-io-tree.h
@@ -156,12 +156,6 @@  int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
 int set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
 		   u32 bits, struct extent_state **cached_state, gfp_t mask);
 
-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, GFP_NOFS);
-}
-
 static inline int clear_extent_uptodate(struct extent_io_tree *tree, u64 start,
 		u64 end, struct extent_state **cached_state)
 {
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 47cfb694cdbf..03b2a7c508b9 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -73,8 +73,8 @@  int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info,
 			      u64 start, u64 num_bytes)
 {
 	u64 end = start + num_bytes - 1;
-	set_extent_bits(&fs_info->excluded_extents, start, end,
-			EXTENT_UPTODATE);
+	set_extent_bit(&fs_info->excluded_extents, start, end,
+		       EXTENT_UPTODATE, NULL, GFP_NOFS);
 	return 0;
 }
 
@@ -5981,9 +5981,9 @@  static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed)
 		ret = btrfs_issue_discard(device->bdev, start, len,
 					  &bytes);
 		if (!ret)
-			set_extent_bits(&device->alloc_state, start,
-					start + bytes - 1,
-					CHUNK_TRIMMED);
+			set_extent_bit(&device->alloc_state, start,
+				       start + bytes - 1,
+				       CHUNK_TRIMMED, NULL, GFP_NOFS);
 		mutex_unlock(&fs_info->chunk_mutex);
 
 		if (ret)
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
index e74b9804bcde..1e364a7b74aa 100644
--- a/fs/btrfs/file-item.c
+++ b/fs/btrfs/file-item.c
@@ -94,8 +94,8 @@  int btrfs_inode_set_file_extent_range(struct btrfs_inode *inode, u64 start,
 
 	if (btrfs_fs_incompat(inode->root->fs_info, NO_HOLES))
 		return 0;
-	return set_extent_bits(&inode->file_extent_tree, start, start + len - 1,
-			       EXTENT_DIRTY);
+	return set_extent_bit(&inode->file_extent_tree, start, start + len - 1,
+			      EXTENT_DIRTY, NULL, GFP_NOFS);
 }
 
 /*
@@ -438,9 +438,9 @@  blk_status_t btrfs_lookup_bio_sums(struct btrfs_bio *bbio)
 			    BTRFS_DATA_RELOC_TREE_OBJECTID) {
 				u64 file_offset = bbio->file_offset + bio_offset;
 
-				set_extent_bits(&inode->io_tree, file_offset,
-						file_offset + sectorsize - 1,
-						EXTENT_NODATASUM);
+				set_extent_bit(&inode->io_tree, file_offset,
+					       file_offset + sectorsize - 1,
+					       EXTENT_NODATASUM, NULL, GFP_NOFS);
 			} else {
 				btrfs_warn_rl(fs_info,
 			"csum hole found for disk bytenr range [%llu, %llu)",
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 38cfbd38a819..1ed8b132fe2a 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -174,8 +174,9 @@  static void mark_block_processed(struct reloc_control *rc,
 	    in_range(node->bytenr, rc->block_group->start,
 		     rc->block_group->length)) {
 		blocksize = rc->extent_root->fs_info->nodesize;
-		set_extent_bits(&rc->processed_blocks, node->bytenr,
-				node->bytenr + blocksize - 1, EXTENT_DIRTY);
+		set_extent_bit(&rc->processed_blocks, node->bytenr,
+			       node->bytenr + blocksize - 1, EXTENT_DIRTY,
+			       NULL, GFP_NOFS);
 	}
 	node->processed = 1;
 }
@@ -3051,9 +3052,9 @@  static int relocate_one_page(struct inode *inode, struct file_ra_state *ra,
 			u64 boundary_end = boundary_start +
 					   fs_info->sectorsize - 1;
 
-			set_extent_bits(&BTRFS_I(inode)->io_tree,
-					boundary_start, boundary_end,
-					EXTENT_BOUNDARY);
+			set_extent_bit(&BTRFS_I(inode)->io_tree,
+				       boundary_start, boundary_end,
+				       EXTENT_BOUNDARY, NULL, GFP_NOFS);
 		}
 		unlock_extent(&BTRFS_I(inode)->io_tree, clamped_start, clamped_end,
 			      &cached_state);
diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c
index b9de94a50868..acaaddf7181a 100644
--- a/fs/btrfs/tests/extent-io-tests.c
+++ b/fs/btrfs/tests/extent-io-tests.c
@@ -503,8 +503,8 @@  static int test_find_first_clear_extent_bit(void)
 	 * Set 1M-4M alloc/discard and 32M-64M thus leaving a hole between
 	 * 4M-32M
 	 */
-	set_extent_bits(&tree, SZ_1M, SZ_4M - 1,
-			CHUNK_TRIMMED | CHUNK_ALLOCATED);
+	set_extent_bit(&tree, SZ_1M, SZ_4M - 1,
+		       CHUNK_TRIMMED | CHUNK_ALLOCATED, NULL, GFP_NOFS);
 
 	find_first_clear_extent_bit(&tree, SZ_512K, &start, &end,
 				    CHUNK_TRIMMED | CHUNK_ALLOCATED);
@@ -516,8 +516,8 @@  static int test_find_first_clear_extent_bit(void)
 	}
 
 	/* Now add 32M-64M so that we have a hole between 4M-32M */
-	set_extent_bits(&tree, SZ_32M, SZ_64M - 1,
-			CHUNK_TRIMMED | CHUNK_ALLOCATED);
+	set_extent_bit(&tree, SZ_32M, SZ_64M - 1,
+		       CHUNK_TRIMMED | CHUNK_ALLOCATED, NULL, GFP_NOFS);
 
 	/*
 	 * Request first hole starting at 12M, we should get 4M-32M
@@ -548,7 +548,8 @@  static int test_find_first_clear_extent_bit(void)
 	 * Set 64M-72M with CHUNK_ALLOC flag, then search for CHUNK_TRIMMED flag
 	 * being unset in this range, we should get the entry in range 64M-72M
 	 */
-	set_extent_bits(&tree, SZ_64M, SZ_64M + SZ_8M - 1, CHUNK_ALLOCATED);
+	set_extent_bit(&tree, SZ_64M, SZ_64M + SZ_8M - 1, CHUNK_ALLOCATED, NULL,
+		       GFP_NOFS);
 	find_first_clear_extent_bit(&tree, SZ_64M + SZ_1M, &start, &end,
 				    CHUNK_TRIMMED);