]> 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 13:54:50 +0000 (08:54 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Jan 2026 15:35:30 +0000 (16:35 +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 7cbccd4604c5081c5f52793bbf76e2be3a5efd25..ca09f42d26aa1938c51b932622ed5fafca6abf86 100644 (file)
@@ -1691,6 +1691,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);
@@ -1698,7 +1699,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 == -EAGAIN) {
@@ -1714,7 +1715,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
                return ret;
        }
 
-       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);
@@ -1743,7 +1744,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.
@@ -1752,8 +1753,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);