Skip to content

Commit e36d114

Browse files
fdmananakdave
authored andcommitted
btrfs: simplify logic to decrement snapshot counter at btrfs_mksnapshot()
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]>
1 parent a20725e commit e36d114

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

fs/btrfs/ioctl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,6 @@ static noinline int btrfs_mksnapshot(const struct path *parent,
10491049
struct btrfs_qgroup_inherit *inherit)
10501050
{
10511051
int ret;
1052-
bool snapshot_force_cow = false;
10531052

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

10731071
btrfs_wait_ordered_extents(root, U64_MAX, NULL);
10741072

10751073
ret = btrfs_mksubvol(parent, idmap, name, namelen,
10761074
root, readonly, inherit);
1075+
atomic_dec(&root->snapshot_force_cow);
10771076
out:
1078-
if (snapshot_force_cow)
1079-
atomic_dec(&root->snapshot_force_cow);
10801077
btrfs_drew_read_unlock(&root->snapshot_lock);
10811078
return ret;
10821079
}

0 commit comments

Comments
 (0)