All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/8] btrfs-progs: Add btrfs_is_empty_uuid
Date: Tue, 14 Sep 2021 08:58:54 +0800	[thread overview]
Message-ID: <9a16eae4-5dd0-cb03-7457-38ba62760a7e@gmx.com> (raw)
In-Reply-To: <20210913131729.37897-2-nborisov@suse.com>



On 2021/9/13 下午9:17, Nikolay Borisov wrote:
> This utility function is needed by the RO->RW snapshot detection code.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>   kernel-shared/ctree.h     |  2 ++
>   kernel-shared/uuid-tree.c | 11 +++++++++++
>   2 files changed, 13 insertions(+)
>
> diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
> index 3cca60323e3d..f53436a7f38b 100644
> --- a/kernel-shared/ctree.h
> +++ b/kernel-shared/ctree.h
> @@ -2860,6 +2860,8 @@ int btrfs_lookup_uuid_received_subvol_item(int fd, const u8 *uuid,
>   int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans, u8 *uuid, u8 type,
>   			u64 subvol_id_cpu);
>
> +int btrfs_is_empty_uuid(u8 *uuid);
> +
>   static inline int is_fstree(u64 rootid)
>   {
>   	if (rootid == BTRFS_FS_TREE_OBJECTID ||
> diff --git a/kernel-shared/uuid-tree.c b/kernel-shared/uuid-tree.c
> index 21115a4d2d09..51a7b5d9ff5d 100644
> --- a/kernel-shared/uuid-tree.c
> +++ b/kernel-shared/uuid-tree.c
> @@ -109,3 +109,14 @@ int btrfs_lookup_uuid_received_subvol_item(int fd, const u8 *uuid,
>   					  BTRFS_UUID_KEY_RECEIVED_SUBVOL,
>   					  subvol_id);
>   }
> +
> +int btrfs_is_empty_uuid(u8 *uuid)
> +{

I did the same work in my previous warning try, but it can be even easier:

	u8 empty_uuid[BTRFS_UUID_SIZE] = 0;

	return !memcmpy(uuid, empty_uuid, BTRFS_UUID_SIZE);

So simple that I didn't even create a helper for it...

Thanks,
Qu

> +	int i;
> +
> +	for (i = 0; i < BTRFS_UUID_SIZE; i++) {
> +		if (uuid[i])
> +			return 0;
> +	}
> +	return 1;
> +}
>

  reply	other threads:[~2021-09-14  0:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-13 13:17 [PATCH 0/8] Implement progs support for removing received uuid on RW vols Nikolay Borisov
2021-09-13 13:17 ` [PATCH 1/8] btrfs-progs: Add btrfs_is_empty_uuid Nikolay Borisov
2021-09-14  0:58   ` Qu Wenruo [this message]
2021-09-13 13:17 ` [PATCH 2/8] btrfs-progs: Remove root argument from btrfs_fixup_low_keys Nikolay Borisov
2021-09-14  1:01   ` Qu Wenruo
2021-09-13 13:17 ` [PATCH 3/8] btrfs-progs: Remove fs_info argument from leaf_data_end Nikolay Borisov
2021-09-14  1:02   ` Qu Wenruo
2021-09-13 13:17 ` [PATCH 4/8] btrfs-progs: Remove root argument from btrfs_truncate_item Nikolay Borisov
2021-09-14  1:02   ` Qu Wenruo
2021-09-13 13:17 ` [PATCH 5/8] btrfs-progs: Add btrfs_uuid_tree_remove Nikolay Borisov
2021-09-14  1:07   ` Qu Wenruo
2021-09-14  4:49     ` Nikolay Borisov
2021-09-14  4:57       ` Qu Wenruo
2021-09-13 13:17 ` [PATCH 6/8] btrfs-progs: check/original: Implement removing received data for RW subvols Nikolay Borisov
2021-09-13 13:17 ` [PATCH 7/8] btrfs-progs: check/lowmem: Implement received info clearing for RW volumes Nikolay Borisov
2021-09-13 13:17 ` [PATCH 8/8] btrfs-progs: tests: Add test for received information removal Nikolay Borisov

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=9a16eae4-5dd0-cb03-7457-38ba62760a7e@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --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.