Commit bb55f626 authored by Nikolay Borisov's avatar Nikolay Borisov Committed by David Sterba

btrfs: simplify extent type checks in run_delalloc_nocow

There is no point in checking the type of the extent again just to set
the 'type' variable, when this check has already been performed before.
Instead, extend the original if branch with an 'else' clause. This
allows to remove one local variable and make it obvious how the code
flow differs for prealloc/regular extents.
Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent a6bd9cd1
...@@ -1336,7 +1336,6 @@ static noinline int run_delalloc_nocow(struct inode *inode, ...@@ -1336,7 +1336,6 @@ static noinline int run_delalloc_nocow(struct inode *inode,
u64 disk_bytenr = 0; u64 disk_bytenr = 0;
u64 num_bytes = 0; u64 num_bytes = 0;
u64 disk_num_bytes; u64 disk_num_bytes;
int type;
u64 ram_bytes; u64 ram_bytes;
int extent_type; int extent_type;
bool nocow = false; bool nocow = false;
...@@ -1572,16 +1571,17 @@ static noinline int run_delalloc_nocow(struct inode *inode, ...@@ -1572,16 +1571,17 @@ static noinline int run_delalloc_nocow(struct inode *inode,
goto error; goto error;
} }
free_extent_map(em); free_extent_map(em);
} ret = btrfs_add_ordered_extent(inode, cur_offset,
disk_bytenr, num_bytes,
if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) { num_bytes,
type = BTRFS_ORDERED_PREALLOC; BTRFS_ORDERED_PREALLOC);
} else { } else {
type = BTRFS_ORDERED_NOCOW; ret = btrfs_add_ordered_extent(inode, cur_offset,
disk_bytenr, num_bytes,
num_bytes,
BTRFS_ORDERED_NOCOW);
} }
ret = btrfs_add_ordered_extent(inode, cur_offset, disk_bytenr,
num_bytes, num_bytes,type);
if (nocow) if (nocow)
btrfs_dec_nocow_writers(fs_info, disk_bytenr); btrfs_dec_nocow_writers(fs_info, disk_bytenr);
BUG_ON(ret); /* -ENOMEM */ BUG_ON(ret); /* -ENOMEM */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment