summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2022-05-09 16:29:14 +0100
committerDavid Sterba <dsterba@suse.com>2022-05-17 20:15:25 +0200
commit97bdf1a903c51bd773b5828af233f639957a92b7 (patch)
tree115fb34be9ccf1a47d004a398996f144bb084aea
parentaa9ffadfcae33e611d8c2d476bcc2aa0d273b587 (diff)
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 <nborisov@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/inode.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1b76fc49abb8..da13bd0d10f1 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -6164,12 +6164,15 @@ int btrfs_new_inode_prepare(struct btrfs_new_inode_args *args,
(*trans_num_items)++;
} else {
/*
- * 1 to add inode ref
* 1 to add dir item
* 1 to add dir index
* 1 to update parent inode item
+ *
+ * No need for 1 unit for the inode ref item because it is
+ * inserted in a batch together with the inode item at
+ * btrfs_create_new_inode().
*/
- *trans_num_items += 4;
+ *trans_num_items += 3;
}
return 0;
}