Skip to content

Commit

Permalink
btrfs: cleanup calculation of lockend in lock_and_cleanup_extent_if_n…
Browse files Browse the repository at this point in the history
…eed()

We're just doing rounding up to sectorsize to calculate the lockend.
There is no need to do the unnecessary length calculation, just direct
round_up() is enough.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Qu Wenruo authored and David Sterba committed Oct 7, 2020
1 parent c492302 commit e21139c
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions fs/btrfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1477,9 +1477,7 @@ lock_and_cleanup_extent_if_need(struct btrfs_inode *inode, struct page **pages,
int ret = 0;

start_pos = round_down(pos, fs_info->sectorsize);
last_pos = start_pos
+ round_up(pos + write_bytes - start_pos,
fs_info->sectorsize) - 1;
last_pos = round_up(pos + write_bytes, fs_info->sectorsize) - 1;

if (start_pos < inode->vfs_inode.i_size) {
struct btrfs_ordered_extent *ordered;
Expand Down

0 comments on commit e21139c

Please sign in to comment.