linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Use NULL in btrfs_search_slot as trans if we only want to search
@ 2021-07-20 18:02 Marcos Paulo de Souza
  2021-07-21 12:37 ` Nikolay Borisov
  2021-07-21 16:22 ` David Sterba
  0 siblings, 2 replies; 4+ messages in thread
From: Marcos Paulo de Souza @ 2021-07-20 18:02 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba, 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.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
 fs/btrfs/backref.c     | 2 +-
 fs/btrfs/extent-tree.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 7a8a2fc19533..0602c1cc7b62 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -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);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index d296483d148f..d8d5fb9fb77a 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -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.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Use NULL in btrfs_search_slot as trans if we only want to search
  2021-07-20 18:02 [PATCH] btrfs: Use NULL in btrfs_search_slot as trans if we only want to search Marcos Paulo de Souza
@ 2021-07-21 12:37 ` Nikolay Borisov
  2021-07-21 14:51   ` David Sterba
  2021-07-21 16:22 ` David Sterba
  1 sibling, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2021-07-21 12:37 UTC (permalink / raw)
  To: Marcos Paulo de Souza, linux-btrfs; +Cc: dsterba



On 20.07.21 г. 21:02, Marcos Paulo de Souza wrote:
> 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.
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

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.


Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/backref.c     | 2 +-
>  fs/btrfs/extent-tree.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index 7a8a2fc19533..0602c1cc7b62 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -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);
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index d296483d148f..d8d5fb9fb77a 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -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;
>  
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Use NULL in btrfs_search_slot as trans if we only want to search
  2021-07-21 12:37 ` Nikolay Borisov
@ 2021-07-21 14:51   ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2021-07-21 14:51 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: Marcos Paulo de Souza, linux-btrfs, dsterba

On Wed, Jul 21, 2021 at 03:37:03PM +0300, Nikolay Borisov wrote:
> 
> 
> On 20.07.21 г. 21:02, Marcos Paulo de Souza wrote:
> > 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.
> > 
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Use NULL in btrfs_search_slot as trans if we only want to search
  2021-07-20 18:02 [PATCH] btrfs: Use NULL in btrfs_search_slot as trans if we only want to search Marcos Paulo de Souza
  2021-07-21 12:37 ` Nikolay Borisov
@ 2021-07-21 16:22 ` David Sterba
  1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2021-07-21 16:22 UTC (permalink / raw)
  To: Marcos Paulo de Souza; +Cc: linux-btrfs, dsterba

On Tue, Jul 20, 2021 at 03:02:47PM -0300, Marcos Paulo de Souza wrote:
> 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.
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Added to misc-next, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-21 16:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-20 18:02 [PATCH] btrfs: Use NULL in btrfs_search_slot as trans if we only want to search Marcos Paulo de Souza
2021-07-21 12:37 ` Nikolay Borisov
2021-07-21 14:51   ` David Sterba
2021-07-21 16:22 ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).