Skip to content

Commit a35b3dd

Browse files
fdmananakdave
authored andcommitted
btrfs: fix comment about nbytes increase at replay_one_extent()
The comment is wrong about the part where it says a prealloc extent does not contribute to an inode's nbytes - it does. Only holes don't contribute and that's what we are checking for, as prealloc extents always have a disk_bytenr different from 0. So fix the comment and re-organize the code to not set nbytes twice and set it to the extent item's number of bytes only if it doesn't represent a hole - in case it's a hole we have already initialized nbytes to 0 when we declared it. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 2d83ed6 commit a35b3dd

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

fs/btrfs/tree-log.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -740,15 +740,10 @@ static noinline int replay_one_extent(struct walk_control *wc)
740740

741741
if (found_type == BTRFS_FILE_EXTENT_REG ||
742742
found_type == BTRFS_FILE_EXTENT_PREALLOC) {
743-
nbytes = btrfs_file_extent_num_bytes(wc->log_leaf, item);
744-
extent_end = start + nbytes;
745-
746-
/*
747-
* We don't add to the inodes nbytes if we are prealloc or a
748-
* hole.
749-
*/
750-
if (btrfs_file_extent_disk_bytenr(wc->log_leaf, item) == 0)
751-
nbytes = 0;
743+
extent_end = start + btrfs_file_extent_num_bytes(wc->log_leaf, item);
744+
/* Holes don't take up space. */
745+
if (btrfs_file_extent_disk_bytenr(wc->log_leaf, item) != 0)
746+
nbytes = btrfs_file_extent_num_bytes(wc->log_leaf, item);
752747
} else if (found_type == BTRFS_FILE_EXTENT_INLINE) {
753748
size = btrfs_file_extent_ram_bytes(wc->log_leaf, item);
754749
nbytes = btrfs_file_extent_ram_bytes(wc->log_leaf, item);

0 commit comments

Comments
 (0)