Skip to contentSkip to conversation

btrfs: Use NULL in btrfs_search_slot as trans if we only want to search

PATCH In review Marcos Paulo de Souza 3 participants 4 messages Jul 20, 2021 – Jul 21, 2021 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Use NULL in btrfs_search_slot as trans if we only want to search

Using a transaction in btrfs_search_slot is only useful when if are searching to add or modify the tree. When the function is only used for searching, insert length and mod arguments are 0, there is no need to use a transaction.

No functional changes, changing for consistency.

---
 fs/btrfs/backref.c     | 2 +-
 fs/btrfs/extent-tree.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/backref.c +1 -1
index 7a8a2fc19533..0602c1cc7b62 100644
@@ -1211,7 +1211,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
 again:
 	head = NULL;
 
-	ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0);
+	ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0);
 	if (ret < 0)
 		goto out;
 	BUG_ON(ret == 0);
fs/btrfs/extent-tree.c +1 -1
index d296483d148f..d8d5fb9fb77a 100644
@@ -153,7 +153,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 	else
 		key.type = BTRFS_EXTENT_ITEM_KEY;
 
-	ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0);
+	ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0);
 	if (ret < 0)
 		goto out_free;
 
Signature · 1 line
2.26.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Marcos Paulo de Souza

Using a transaction in btrfs_search_slot is only useful when if are searching to add or modify the tree. When the function is only used for searching, insert length and mod arguments are 0, there is no need to use a transaction.

No functional changes, changing for consistency.

Basically when cow is 0 and ins_len is also 0 then no paths which utilize a transaction are called so this patch is fine.

Quoted 32 lines
---
 fs/btrfs/backref.c     | 2 +-
 fs/btrfs/extent-tree.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/backref.c +1 -1
index 7a8a2fc19533..0602c1cc7b62 100644
@@ -1211,7 +1211,7 @@ static int find_parent_nodes(struct btrfs_trans_handle *trans,
 again:
 	head = NULL;
 
-	ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0);
+	ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0);
 	if (ret < 0)
 		goto out;
 	BUG_ON(ret == 0);
fs/btrfs/extent-tree.c +1 -1
index d296483d148f..d8d5fb9fb77a 100644
@@ -153,7 +153,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 	else
 		key.type = BTRFS_EXTENT_ITEM_KEY;
 
-	ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0);
+	ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0);
 	if (ret < 0)
 		goto out_free;
 
#2 lore raw
Quoted 8 lines · Nikolay Borisov
Quoted 5 lines · Marcos Paulo de Souza

Using a transaction in btrfs_search_slot is only useful when if are searching to add or modify the tree. When the function is only used for searching, insert length and mod arguments are 0, there is no need to use a transaction.

Quoted 6 lines
Quoted 3 lines

No functional changes, changing for consistency.

Basically when cow is 0 and ins_len is also 0 then no paths which utilize a transaction are called so this patch is fine.

This sounds like a recipe for an assertion.

#3 lore raw
In reply to Marcos Paulo de Souza
Quoted 8 lines · Marcos Paulo de Souza

Using a transaction in btrfs_search_slot is only useful when if are searching to add or modify the tree. When the function is only used for searching, insert length and mod arguments are 0, there is no need to use a transaction.

No functional changes, changing for consistency.

Added to misc-next, thanks.