Skip to content

Commit 97bdf1a

Browse files
fdmananakdave
authored andcommitted
btrfs: do not account twice for inode ref when reserving metadata units
When reserving metadata units for creating an inode, we don't need to reserve one extra unit for the inode ref item because when creating the inode, at btrfs_create_new_inode(), we always insert the inode item and the inode ref item in a single batch (a single btree insert operation, and both ending up in the same leaf). As we have accounted already one unit for the inode item, the extra unit for the inode ref item is superfluous, it only makes us reserve more metadata than necessary and often adding more reclaim pressure if we are low on available metadata space. Reviewed-by: Nikolay Borisov <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent aa9ffad commit 97bdf1a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

fs/btrfs/inode.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6164,12 +6164,15 @@ int btrfs_new_inode_prepare(struct btrfs_new_inode_args *args,
61646164
(*trans_num_items)++;
61656165
} else {
61666166
/*
6167-
* 1 to add inode ref
61686167
* 1 to add dir item
61696168
* 1 to add dir index
61706169
* 1 to update parent inode item
6170+
*
6171+
* No need for 1 unit for the inode ref item because it is
6172+
* inserted in a batch together with the inode item at
6173+
* btrfs_create_new_inode().
61716174
*/
6172-
*trans_num_items += 4;
6175+
*trans_num_items += 3;
61736176
}
61746177
return 0;
61756178
}

0 commit comments

Comments
 (0)