]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
btrfs: adjust while loop condition in run_delalloc_nocow
authorJosef Bacik <josef@toxicpanda.com>
Mon, 12 Feb 2024 21:27:15 +0000 (16:27 -0500)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 May 2024 19:31:09 +0000 (21:31 +0200)
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.

Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c

index d8037775ab75114be712b1ed4a78c57cb37dcfce..2fe82614521c67d3bcdbb1d25902fa6db7c112a2 100644 (file)
@@ -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 @@ must_cow:
                 */
                if (ret)
                        goto error;
-               if (cur_offset > end)
-                       break;
        }
        btrfs_release_path(path);