All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Marcos Paulo de Souza <mpdesouza@suse.com>, linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com, nborisov@suse.com
Subject: Re: [PATCH 1/7] btrfs: Reorder btrfs_find_item arguments
Date: Thu, 5 Aug 2021 10:16:59 +0800	[thread overview]
Message-ID: <f50cc30c-ea62-5581-2a52-d3a475d3044d@gmx.com> (raw)
In-Reply-To: <20210804184854.10696-2-mpdesouza@suse.com>



On 2021/8/5 上午2:48, Marcos Paulo de Souza wrote:
> It's more natural do use objectid, type and offset, in this order, when
> dealing with btrfs keys.

I'm completely fine with this part.

>
> No functional changes.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
>   fs/btrfs/backref.c | 9 ++++-----
>   fs/btrfs/ctree.c   | 2 +-
>   fs/btrfs/ctree.h   | 2 +-
>   3 files changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index f735b8798ba1..9e92faaafa02 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -1691,8 +1691,8 @@ char *btrfs_ref_to_path(struct btrfs_root *fs_root, struct btrfs_path *path,
>   				btrfs_tree_read_unlock(eb);
>   			free_extent_buffer(eb);
>   		}
> -		ret = btrfs_find_item(fs_root, path, parent, 0,
> -				BTRFS_INODE_REF_KEY, &found_key);
> +		ret = btrfs_find_item(fs_root, path, parent, BTRFS_INODE_REF_KEY,
> +					0, &found_key);
>   		if (ret > 0)
>   			ret = -ENOENT;
>   		if (ret)
> @@ -2063,9 +2063,8 @@ static int iterate_inode_refs(u64 inum, struct btrfs_root *fs_root,
>   	struct btrfs_key found_key;
>
>   	while (!ret) {
> -		ret = btrfs_find_item(fs_root, path, inum,
> -				parent ? parent + 1 : 0, BTRFS_INODE_REF_KEY,
> -				&found_key);
> +		ret = btrfs_find_item(fs_root, path, inum, BTRFS_INODE_REF_KEY,
> +				parent ? parent + 1 : 0, &found_key);
>
>   		if (ret < 0)
>   			break;
> diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
> index 84627cbd5b5b..c0002ec9c025 100644
> --- a/fs/btrfs/ctree.c
> +++ b/fs/btrfs/ctree.c
> @@ -1528,7 +1528,7 @@ setup_nodes_for_search(struct btrfs_trans_handle *trans,
>   }
>
>   int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path,
> -		u64 iobjectid, u64 ioff, u8 key_type,
> +		u64 iobjectid, u8 key_type, u64 ioff,
>   		struct btrfs_key *found_key)

But the @found_key part makes me wonder.

Is it really needed?

The caller has @path and return value. If we return 0, we know it's an
exact match, no need to grab the key.
If we return 1, caller can easily grab the key using @path (if they
really need).

So can we also remove @found_key parameter, and add some comment on the
function?

Thanks,
Qu

>   {
>   	int ret;
> diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
> index a898257ad2b5..0a971e98f5f9 100644
> --- a/fs/btrfs/ctree.h
> +++ b/fs/btrfs/ctree.h
> @@ -2858,7 +2858,7 @@ int btrfs_duplicate_item(struct btrfs_trans_handle *trans,
>   			 struct btrfs_path *path,
>   			 const struct btrfs_key *new_key);
>   int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path,
> -		u64 inum, u64 ioff, u8 key_type, struct btrfs_key *found_key);
> +		u64 inum, u8 key_type, u64 ioff, struct btrfs_key *found_key);
>   int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
>   		      const struct btrfs_key *key, struct btrfs_path *p,
>   		      int ins_len, int cow);
>

  reply	other threads:[~2021-08-05  2:17 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-04 18:48 [PATCH 0/7] btrfs: Use btrfs_find_item whenever possible Marcos Paulo de Souza
2021-08-04 18:48 ` [PATCH 1/7] btrfs: Reorder btrfs_find_item arguments Marcos Paulo de Souza
2021-08-05  2:16   ` Qu Wenruo [this message]
2021-08-05 17:28     ` Marcos Paulo de Souza
2021-08-05 22:23       ` Qu Wenruo
2021-08-16 16:51   ` David Sterba
2021-08-04 18:48 ` [PATCH 2/7] btrfs: backref: Use btrfs_find_item in btrfs_find_one_extref Marcos Paulo de Souza
2021-08-05  6:33   ` Qu Wenruo
2021-08-04 18:48 ` [PATCH 3/7] btrfs: zoned: Use btrfs_find_item in calculate_emulated_zone_size Marcos Paulo de Souza
2021-08-05  6:39   ` Qu Wenruo
2021-08-06  5:52     ` Naohiro Aota
2021-08-06  6:11       ` Qu Wenruo
2021-08-06  6:18   ` Naohiro Aota
2021-08-04 18:48 ` [PATCH 4/7] btrfs: root-tree: Use btrfs_find_item in btrfs_find_orphan_roots Marcos Paulo de Souza
2021-08-05  6:42   ` Qu Wenruo
2021-08-04 18:48 ` [PATCH 5/7] btrfs: scrub: Use btrfs_find_item in scrub_enumerate_chunks Marcos Paulo de Souza
2021-08-04 18:48 ` [PATCH 6/7] btrfs: tree-log: Simplify log_new_ancestors Marcos Paulo de Souza
2021-08-05  9:00   ` Filipe Manana
2021-08-05 12:41     ` Marcos Paulo de Souza
2021-08-04 18:48 ` [PATCH 7/7] btrfs: ioctl: Simplify btrfs_ioctl_get_subvol_info Marcos Paulo de Souza
2021-08-05 12:13   ` Anand Jain
2021-08-05 14:23     ` Marcos Paulo de Souza

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f50cc30c-ea62-5581-2a52-d3a475d3044d@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mpdesouza@suse.com \
    --cc=nborisov@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.