Skip to content

Commit afbb578

Browse files
fdmananagregkh
authored andcommitted
btrfs: use variable for end offset in extent_writepage_io()
[ Upstream commit 46a2390 ] 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: e9e3b22 ("btrfs: fix beyond-EOF write handling") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a915072 commit afbb578

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

fs/btrfs/extent_io.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,14 +1498,15 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
14981498
unsigned long range_bitmap = 0;
14991499
bool submitted_io = false;
15001500
int found_error = 0;
1501+
const u64 end = start + len;
15011502
const u64 folio_start = folio_pos(folio);
15021503
const u64 folio_end = folio_start + folio_size(folio);
15031504
const unsigned int blocks_per_folio = btrfs_blocks_per_folio(fs_info, folio);
15041505
u64 cur;
15051506
int bit;
15061507
int ret = 0;
15071508

1508-
ASSERT(start >= folio_start && start + len <= folio_end);
1509+
ASSERT(start >= folio_start && end <= folio_end);
15091510

15101511
ret = btrfs_writepage_cow_fixup(folio);
15111512
if (ret) {
@@ -1515,7 +1516,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
15151516
return 1;
15161517
}
15171518

1518-
for (cur = start; cur < start + len; cur += fs_info->sectorsize)
1519+
for (cur = start; cur < end; cur += fs_info->sectorsize)
15191520
set_bit((cur - folio_start) >> fs_info->sectorsize_bits, &range_bitmap);
15201521
bitmap_and(&bio_ctrl->submit_bitmap, &bio_ctrl->submit_bitmap, &range_bitmap,
15211522
blocks_per_folio);
@@ -1544,7 +1545,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
15441545
btrfs_put_ordered_extent(ordered);
15451546

15461547
btrfs_mark_ordered_io_finished(inode, folio, cur,
1547-
start + len - cur, true);
1548+
end - cur, true);
15481549
/*
15491550
* This range is beyond i_size, thus we don't need to
15501551
* bother writing back.
@@ -1553,8 +1554,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
15531554
* writeback the sectors with subpage dirty bits,
15541555
* causing writeback without ordered extent.
15551556
*/
1556-
btrfs_folio_clear_dirty(fs_info, folio, cur,
1557-
start + len - cur);
1557+
btrfs_folio_clear_dirty(fs_info, folio, cur, end - cur);
15581558
break;
15591559
}
15601560
ret = submit_one_sector(inode, folio, cur, bio_ctrl, i_size);

0 commit comments

Comments
 (0)