mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
btrfs: use a single switch statement when initializing delayed ref head
At init_delayed_ref_head(), we are using two separate if statements to check the delayed ref head action, and initializing 'must_insert_reserved' to false twice, once when the variable is declared and once again in an else branch. Make this simpler and more straightforward by having a single switch statement, also moving the comment about a drop action to the corresponding switch case to make it more clear and eliminating the duplicated initialization of 'must_insert_reserved' to false. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
committed by
David Sterba
parent
61c681fef7
commit
f1ed785a5b
@@ -702,29 +702,33 @@ static void init_delayed_ref_head(struct btrfs_delayed_ref_head *head_ref,
|
|||||||
/* If reserved is provided, it must be a data extent. */
|
/* If reserved is provided, it must be a data extent. */
|
||||||
BUG_ON(!is_data && reserved);
|
BUG_ON(!is_data && reserved);
|
||||||
|
|
||||||
/*
|
switch (action) {
|
||||||
* The head node stores the sum of all the mods, so dropping a ref
|
case BTRFS_UPDATE_DELAYED_HEAD:
|
||||||
* should drop the sum in the head node by one.
|
|
||||||
*/
|
|
||||||
if (action == BTRFS_UPDATE_DELAYED_HEAD)
|
|
||||||
count_mod = 0;
|
count_mod = 0;
|
||||||
else if (action == BTRFS_DROP_DELAYED_REF)
|
break;
|
||||||
|
case BTRFS_DROP_DELAYED_REF:
|
||||||
|
/*
|
||||||
|
* The head node stores the sum of all the mods, so dropping a ref
|
||||||
|
* should drop the sum in the head node by one.
|
||||||
|
*/
|
||||||
count_mod = -1;
|
count_mod = -1;
|
||||||
|
break;
|
||||||
/*
|
case BTRFS_ADD_DELAYED_EXTENT:
|
||||||
* BTRFS_ADD_DELAYED_EXTENT means that we need to update the reserved
|
/*
|
||||||
* accounting when the extent is finally added, or if a later
|
* BTRFS_ADD_DELAYED_EXTENT means that we need to update the
|
||||||
* modification deletes the delayed ref without ever inserting the
|
* reserved accounting when the extent is finally added, or if a
|
||||||
* extent into the extent allocation tree. ref->must_insert_reserved
|
* later modification deletes the delayed ref without ever
|
||||||
* is the flag used to record that accounting mods are required.
|
* inserting the extent into the extent allocation tree.
|
||||||
*
|
* ref->must_insert_reserved is the flag used to record that
|
||||||
* Once we record must_insert_reserved, switch the action to
|
* accounting mods are required.
|
||||||
* BTRFS_ADD_DELAYED_REF because other special casing is not required.
|
*
|
||||||
*/
|
* Once we record must_insert_reserved, switch the action to
|
||||||
if (action == BTRFS_ADD_DELAYED_EXTENT)
|
* BTRFS_ADD_DELAYED_REF because other special casing is not
|
||||||
|
* required.
|
||||||
|
*/
|
||||||
must_insert_reserved = true;
|
must_insert_reserved = true;
|
||||||
else
|
break;
|
||||||
must_insert_reserved = false;
|
}
|
||||||
|
|
||||||
refcount_set(&head_ref->refs, 1);
|
refcount_set(&head_ref->refs, 1);
|
||||||
head_ref->bytenr = bytenr;
|
head_ref->bytenr = bytenr;
|
||||||
|
Reference in New Issue
Block a user