]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
btrfs: use round_down() to align block offset at btrfs_cow_block()
authorFilipe Manana <fdmanana@suse.com>
Wed, 27 Sep 2023 11:09:25 +0000 (12:09 +0100)
committerDavid Sterba <dsterba@suse.com>
Thu, 12 Oct 2023 14:44:14 +0000 (16:44 +0200)
At btrfs_cow_block() we can use round_down() to align the extent buffer's
logical offset to the start offset of a metadata block group, instead of
the less easy to read set of bitwise operations (two plus one subtraction).
So replace the bitwise operations with a round_down() call.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c

index 49232b52639017d8bc9ae45a124e984e9365c481..e1af5cc698f9323d48db2cff853712bf01dbdc46 100644 (file)
@@ -718,7 +718,7 @@ int btrfs_cow_block(struct btrfs_trans_handle *trans,
                return 0;
        }
 
-       search_start = buf->start & ~((u64)SZ_1G - 1);
+       search_start = round_down(buf->start, SZ_1G);
 
        /*
         * Before CoWing this block for later modification, check if it's