Skip to content

Commit e8e2100

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: comment and minor simplifications in run_delalloc_nocow
Add a comment explaining why we keep the BUG also use the already read and cached value of extent ram bytes stored in 'ram_bytes'. Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 922f051 commit e8e2100

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/btrfs/inode.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,16 +1503,15 @@ static noinline int run_delalloc_nocow(struct inode *inode,
15031503
goto out_check;
15041504
nocow = true;
15051505
} else if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
1506-
extent_end = found_key.offset +
1507-
btrfs_file_extent_ram_bytes(leaf, fi);
1508-
extent_end = ALIGN(extent_end,
1509-
fs_info->sectorsize);
1506+
extent_end = found_key.offset + ram_bytes;
1507+
extent_end = ALIGN(extent_end, fs_info->sectorsize);
15101508
/* Skip extents outside of our requested range */
15111509
if (extent_end <= start) {
15121510
path->slots[0]++;
15131511
goto next_slot;
15141512
}
15151513
} else {
1514+
/* If this triggers then we have a memory corruption */
15161515
BUG();
15171516
}
15181517
out_check:

0 commit comments

Comments
 (0)