Commit 5caa490e authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba
Browse files

btrfs: control extent reference updates with a control flag for truncate



We've had weird bugs in the past where we forgot to adjust the truncate
path to deal with the fact that we can be called by the tree log path.
Instead of checking if our root is a LOG_ROOT use a flag on the
btrfs_truncate_control to indicate that we don't want to do extent
reference updates during this truncate.

Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 462b728e
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -659,8 +659,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
		}
		should_throttle = false;

		if (del_item && extent_start != 0 &&
		    root->root_key.objectid != BTRFS_TREE_LOG_OBJECTID) {
		if (del_item && extent_start != 0 && !control->skip_ref_updates) {
			struct btrfs_ref ref = { 0 };

			bytes_deleted += extent_num_bytes;
+6 −0
Original line number Diff line number Diff line
@@ -37,6 +37,12 @@ struct btrfs_truncate_control {
	 * removed only if their offset >= new_size.
	 */
	u32 min_type;

	/*
	 * IN: true if we don't want to do extent reference updates for any file
	 * extents we drop.
	 */
	bool skip_ref_updates;
};

int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
+1 −0
Original line number Diff line number Diff line
@@ -4101,6 +4101,7 @@ static int truncate_inode_items(struct btrfs_trans_handle *trans,
	struct btrfs_truncate_control control = {
		.new_size = new_size,
		.min_type = min_type,
		.skip_ref_updates = true,
	};
	int ret;