]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: use variable for end offset in extent_writepage_io()
authorFilipe Manana <fdmanana@suse.com>
Mon, 12 Jan 2026 14:55:54 +0000 (09:55 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2026 15:31:26 +0000 (16:31 +0100)
[ Upstream commit 46a23908598f4b8e61483f04ea9f471b2affc58a ]

Instead of repeating the expression "start + len" multiple times, store it
in a variable and use it where needed.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <asj@kernel.org>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Stable-dep-of: e9e3b22ddfa7 ("btrfs: fix beyond-EOF write handling")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/extent_io.c

index 3658b74a97adb9c7fa8b0c888a1a455d70f95015..657c4652f8b482fa5e4226271b6abadce174a70e 100644 (file)
@@ -1498,6 +1498,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
        unsigned long range_bitmap = 0;
        bool submitted_io = false;
        int found_error = 0;
+       const u64 end = start + len;
        const u64 folio_start = folio_pos(folio);
        const u64 folio_end = folio_start + folio_size(folio);
        const unsigned int blocks_per_folio = btrfs_blocks_per_folio(fs_info, folio);
@@ -1505,7 +1506,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
        int bit;
        int ret = 0;
 
-       ASSERT(start >= folio_start && start + len <= folio_end);
+       ASSERT(start >= folio_start && end <= folio_end);
 
        ret = btrfs_writepage_cow_fixup(folio);
        if (ret) {
@@ -1515,7 +1516,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
                return 1;
        }
 
-       for (cur = start; cur < start + len; cur += fs_info->sectorsize)
+       for (cur = start; cur < end; cur += fs_info->sectorsize)
                set_bit((cur - folio_start) >> fs_info->sectorsize_bits, &range_bitmap);
        bitmap_and(&bio_ctrl->submit_bitmap, &bio_ctrl->submit_bitmap, &range_bitmap,
                   blocks_per_folio);
@@ -1544,7 +1545,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
                        btrfs_put_ordered_extent(ordered);
 
                        btrfs_mark_ordered_io_finished(inode, folio, cur,
-                                                      start + len - cur, true);
+                                                      end - cur, true);
                        /*
                         * This range is beyond i_size, thus we don't need to
                         * bother writing back.
@@ -1553,8 +1554,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
                         * writeback the sectors with subpage dirty bits,
                         * causing writeback without ordered extent.
                         */
-                       btrfs_folio_clear_dirty(fs_info, folio, cur,
-                                               start + len - cur);
+                       btrfs_folio_clear_dirty(fs_info, folio, cur, end - cur);
                        break;
                }
                ret = submit_one_sector(inode, folio, cur, bio_ctrl, i_size);