diff mbox series

[08/17] btrfs: adjust while loop condition in run_delalloc_nocow

Message ID e6b89a60facace44086fc9eaed3e78fbece6c45e.1713363472.git.josef@toxicpanda.com (mailing list archive)
State New
Headers show
Series btrfs: restrain lock extent usage during writeback | expand

Commit Message

Josef Bacik April 17, 2024, 2:35 p.m. UTC
We have the following pattern

while (1) {
	if (cur_offset > end)
		break;
}

Which is just

while (cur_offset <= end) {
}

so adjust the code to be more clear.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/inode.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Goldwyn Rodrigues April 18, 2024, 2:05 p.m. UTC | #1
On 10:35 17/04, Josef Bacik wrote:
> We have the following pattern
> 
> while (1) {
> 	if (cur_offset > end)
> 		break;
> }
> 
> Which is just
> 
> while (cur_offset <= end) {
> }
> 
> so adjust the code to be more clear.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/btrfs/inode.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index f14b3cecce47..80e92d37af34 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -1988,7 +1988,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
>  	nocow_args.end = end;
>  	nocow_args.writeback_path = true;
>  
> -	while (1) {
> +	while (cur_offset <= end) {
>  		struct btrfs_block_group *nocow_bg = NULL;
>  		struct btrfs_ordered_extent *ordered;
>  		struct btrfs_key found_key;
> @@ -2192,8 +2192,6 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
>  		 */
>  		if (ret)
>  			goto error;
> -		if (cur_offset > end)
> -			break;
>  	}
>  	btrfs_release_path(path);
>  

Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index f14b3cecce47..80e92d37af34 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1988,7 +1988,7 @@  static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
 	nocow_args.end = end;
 	nocow_args.writeback_path = true;
 
-	while (1) {
+	while (cur_offset <= end) {
 		struct btrfs_block_group *nocow_bg = NULL;
 		struct btrfs_ordered_extent *ordered;
 		struct btrfs_key found_key;
@@ -2192,8 +2192,6 @@  static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
 		 */
 		if (ret)
 			goto error;
-		if (cur_offset > end)
-			break;
 	}
 	btrfs_release_path(path);