Skip to content

Commit

Permalink
btrfs: simplify logic to decrement snapshot counter at btrfs_mksnapsh…
Browse files Browse the repository at this point in the history
…ot()

There's no point in having a 'snapshot_force_cow' variable to track if we
need to decrement the root->snapshot_force_cow counter, as we never jump
to the 'out' label after incrementing the counter. Simplify this by
removing the variable and always decrementing the counter before the 'out'
label, right after the call to btrfs_mksubvol().

Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
fdmanana authored and kdave committed Nov 6, 2024
1 parent 3532cb3 commit 39cbe2b
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,6 @@ static noinline int btrfs_mksnapshot(const struct path *parent,
struct btrfs_qgroup_inherit *inherit)
{
int ret;
bool snapshot_force_cow = false;

/*
* Force new buffered writes to reserve space even when NOCOW is
Expand All @@ -1068,15 +1067,13 @@ static noinline int btrfs_mksnapshot(const struct path *parent,
* creation.
*/
atomic_inc(&root->snapshot_force_cow);
snapshot_force_cow = true;

btrfs_wait_ordered_extents(root, U64_MAX, NULL);

ret = btrfs_mksubvol(parent, idmap, name, namelen,
root, readonly, inherit);
atomic_dec(&root->snapshot_force_cow);
out:
if (snapshot_force_cow)
atomic_dec(&root->snapshot_force_cow);
btrfs_drew_read_unlock(&root->snapshot_lock);
return ret;
}
Expand Down

0 comments on commit 39cbe2b

Please sign in to comment.