mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
btrfs: use extent_map_end() at btrfs_drop_extent_map_range()
Instead of open coding the end offset calculation of an extent map, use the helper extent_map_end() and cache its result in a local variable, since it's used several times. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
4c0c8cfc84
commit
f3109e33bb
1 changed files with 6 additions and 4 deletions
|
@ -690,6 +690,7 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
|
||||||
}
|
}
|
||||||
while (1) {
|
while (1) {
|
||||||
struct extent_map *em;
|
struct extent_map *em;
|
||||||
|
u64 em_end;
|
||||||
u64 gen;
|
u64 gen;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
bool ends_after_range = false;
|
bool ends_after_range = false;
|
||||||
|
@ -710,7 +711,8 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
|
||||||
write_unlock(&em_tree->lock);
|
write_unlock(&em_tree->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (testend && em->start + em->len > start + len)
|
em_end = extent_map_end(em);
|
||||||
|
if (testend && em_end > start + len)
|
||||||
ends_after_range = true;
|
ends_after_range = true;
|
||||||
if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) {
|
if (skip_pinned && test_bit(EXTENT_FLAG_PINNED, &em->flags)) {
|
||||||
if (ends_after_range) {
|
if (ends_after_range) {
|
||||||
|
@ -718,9 +720,9 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
|
||||||
write_unlock(&em_tree->lock);
|
write_unlock(&em_tree->lock);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
start = em->start + em->len;
|
start = em_end;
|
||||||
if (testend)
|
if (testend)
|
||||||
len = start + len - (em->start + em->len);
|
len = start + len - em_end;
|
||||||
free_extent_map(em);
|
free_extent_map(em);
|
||||||
write_unlock(&em_tree->lock);
|
write_unlock(&em_tree->lock);
|
||||||
continue;
|
continue;
|
||||||
|
@ -767,7 +769,7 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
|
||||||
}
|
}
|
||||||
if (ends_after_range) {
|
if (ends_after_range) {
|
||||||
split->start = start + len;
|
split->start = start + len;
|
||||||
split->len = em->start + em->len - (start + len);
|
split->len = em_end - (start + len);
|
||||||
split->block_start = em->block_start;
|
split->block_start = em->block_start;
|
||||||
split->flags = flags;
|
split->flags = flags;
|
||||||
split->compress_type = em->compress_type;
|
split->compress_type = em->compress_type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue