Commit ba4ec8fb authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba
Browse files

btrfs: fix calculation of the global block reserve's size



At btrfs_update_global_block_rsv(), we are assuming an unlink operation
uses 5 metadata units, but that's not true anymore, it uses 6 since the
commit bca4ad7c ("btrfs: reserve correct number of items for unlink
and rmdir"). So update the code and comments to consider 6 units.

Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent b13d57db
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -350,14 +350,14 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)


	/*
	/*
	 * But we also want to reserve enough space so we can do the fallback
	 * But we also want to reserve enough space so we can do the fallback
	 * global reserve for an unlink, which is an additional 5 items (see the
	 * global reserve for an unlink, which is an additional 6 items (see the
	 * comment in __unlink_start_trans for what we're modifying.)
	 * comment in __unlink_start_trans for what we're modifying.)
	 *
	 *
	 * But we also need space for the delayed ref updates from the unlink,
	 * But we also need space for the delayed ref updates from the unlink,
	 * so its 10, 5 for the actual operation, and 5 for the delayed ref
	 * so its 12, 6 for the actual operation, and 6 for the delayed ref
	 * updates.
	 * updates.
	 */
	 */
	min_items += 10;
	min_items += 12;


	num_bytes = max_t(u64, num_bytes,
	num_bytes = max_t(u64, num_bytes,
			  btrfs_calc_insert_metadata_size(fs_info, min_items));
			  btrfs_calc_insert_metadata_size(fs_info, min_items));