Skip to content

Commit 9cb1a58

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 3b7ca18 commit 9cb1a58

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
@@ -1691,14 +1691,15 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
16911691
unsigned long range_bitmap = 0;
16921692
bool submitted_io = false;
16931693
int found_error = 0;
1694+
const u64 end = start + len;
16941695
const u64 folio_start = folio_pos(folio);
16951696
const u64 folio_end = folio_start + folio_size(folio);
16961697
const unsigned int blocks_per_folio = btrfs_blocks_per_folio(fs_info, folio);
16971698
u64 cur;
16981699
int bit;
16991700
int ret = 0;
17001701

1701-
ASSERT(start >= folio_start && start + len <= folio_end);
1702+
ASSERT(start >= folio_start && end <= folio_end);
17021703

17031704
ret = btrfs_writepage_cow_fixup(folio);
17041705
if (ret == -EAGAIN) {
@@ -1714,7 +1715,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
17141715
return ret;
17151716
}
17161717

1717-
for (cur = start; cur < start + len; cur += fs_info->sectorsize)
1718+
for (cur = start; cur < end; cur += fs_info->sectorsize)
17181719
set_bit((cur - folio_start) >> fs_info->sectorsize_bits, &range_bitmap);
17191720
bitmap_and(&bio_ctrl->submit_bitmap, &bio_ctrl->submit_bitmap, &range_bitmap,
17201721
blocks_per_folio);
@@ -1743,7 +1744,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
17431744
btrfs_put_ordered_extent(ordered);
17441745

17451746
btrfs_mark_ordered_io_finished(inode, folio, cur,
1746-
start + len - cur, true);
1747+
end - cur, true);
17471748
/*
17481749
* This range is beyond i_size, thus we don't need to
17491750
* bother writing back.
@@ -1752,8 +1753,7 @@ static noinline_for_stack int extent_writepage_io(struct btrfs_inode *inode,
17521753
* writeback the sectors with subpage dirty bits,
17531754
* causing writeback without ordered extent.
17541755
*/
1755-
btrfs_folio_clear_dirty(fs_info, folio, cur,
1756-
start + len - cur);
1756+
btrfs_folio_clear_dirty(fs_info, folio, cur, end - cur);
17571757
break;
17581758
}
17591759
ret = submit_one_sector(inode, folio, cur, bio_ctrl, i_size);

0 commit comments

Comments
 (0)