Skip to content

Commit 8714d9b

Browse files
asjgregkh
authored andcommitted
btrfs: cow_file_range() num_bytes and disk_num_bytes are same
[ Upstream commit 3752d22 ] This patch deletes local variable disk_num_bytes as its value is same as num_bytes in the function cow_file_range(). Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a39010d commit 8714d9b

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

fs/btrfs/inode.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,6 @@ static noinline int cow_file_range(struct inode *inode,
947947
u64 alloc_hint = 0;
948948
u64 num_bytes;
949949
unsigned long ram_size;
950-
u64 disk_num_bytes;
951950
u64 cur_alloc_size;
952951
u64 blocksize = root->sectorsize;
953952
struct btrfs_key ins;
@@ -963,7 +962,6 @@ static noinline int cow_file_range(struct inode *inode,
963962

964963
num_bytes = ALIGN(end - start + 1, blocksize);
965964
num_bytes = max(blocksize, num_bytes);
966-
disk_num_bytes = num_bytes;
967965

968966
/* if this is a small write inside eof, kick off defrag */
969967
if (num_bytes < SZ_64K &&
@@ -992,16 +990,15 @@ static noinline int cow_file_range(struct inode *inode,
992990
}
993991
}
994992

995-
BUG_ON(disk_num_bytes >
996-
btrfs_super_total_bytes(root->fs_info->super_copy));
993+
BUG_ON(num_bytes > btrfs_super_total_bytes(root->fs_info->super_copy));
997994

998995
alloc_hint = get_extent_allocation_hint(inode, start, num_bytes);
999996
btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);
1000997

1001-
while (disk_num_bytes > 0) {
998+
while (num_bytes > 0) {
1002999
unsigned long op;
10031000

1004-
cur_alloc_size = disk_num_bytes;
1001+
cur_alloc_size = num_bytes;
10051002
ret = btrfs_reserve_extent(root, cur_alloc_size, cur_alloc_size,
10061003
root->sectorsize, 0, alloc_hint,
10071004
&ins, 1, 1);
@@ -1058,7 +1055,7 @@ static noinline int cow_file_range(struct inode *inode,
10581055

10591056
btrfs_dec_block_group_reservations(root->fs_info, ins.objectid);
10601057

1061-
if (disk_num_bytes < cur_alloc_size)
1058+
if (num_bytes < cur_alloc_size)
10621059
break;
10631060

10641061
/* we're not doing compressed IO, don't unlock the first
@@ -1076,8 +1073,10 @@ static noinline int cow_file_range(struct inode *inode,
10761073
delalloc_end, locked_page,
10771074
EXTENT_LOCKED | EXTENT_DELALLOC,
10781075
op);
1079-
disk_num_bytes -= cur_alloc_size;
1080-
num_bytes -= cur_alloc_size;
1076+
if (num_bytes < cur_alloc_size)
1077+
num_bytes = 0;
1078+
else
1079+
num_bytes -= cur_alloc_size;
10811080
alloc_hint = ins.objectid + ins.offset;
10821081
start += cur_alloc_size;
10831082
}

0 commit comments

Comments
 (0)