From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Amir Goldstein <amir73il@gmail.com>,
linux-fsdevel@vger.kernel.org, Shaohua Li <shli@kernel.org>,
Dan Williams <dan.j.williams@intel.com>,
David Howells <dhowells@redhat.com>,
Steven Whitehouse <swhiteho@redhat.com>,
Mimi Zohar <zohar@linux.vnet.ibm.com>,
linux-xfs@vger.kernel.org, linux-raid@vger.kernel.org,
linux-nvdimm@ml01.01.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 04/23] uuid: rename uuid types
Date: Thu, 18 May 2017 10:42:08 -0700 [thread overview]
Message-ID: <20170518174208.GC4519@birch.djwong.org> (raw)
In-Reply-To: <20170518062705.25902-5-hch@lst.de>
On Thu, May 18, 2017 at 08:26:46AM +0200, Christoph Hellwig wrote:
> Our "little endian" UUID really is a Wintel GUID, so rename it and its
> helpers such (guid_t). The big endian UUID is the only true one, so
> give it the name uuid_t. The uuid_le and uuid_be names are retained for
> now, but will hopefully go away soon. The exception to that are the _cmp
> helpers that will be replaced by better primites ASAP and thus don't
I misread that as "better primates ASAP" :)
(Assuming you meant 'primitives'?)
Other than that,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> get the new names.
>
> Also remove the existing typedef in XFS that's now been superceeded by
> the generic type name.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> [andy: also update the UUID_LE/UUID_BE macros including fallout]
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> fs/xfs/xfs_linux.h | 2 --
> include/linux/uuid.h | 55 +++++++++++++++++++++++++++--------------------
> include/uapi/linux/uuid.h | 12 +++++++----
> lib/test_uuid.c | 32 +++++++++++++--------------
> lib/uuid.c | 28 ++++++++++++------------
> lib/vsprintf.c | 4 ++--
> 6 files changed, 72 insertions(+), 61 deletions(-)
>
> diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> index 89ee5ec66837..2c33d915e550 100644
> --- a/fs/xfs/xfs_linux.h
> +++ b/fs/xfs/xfs_linux.h
> @@ -39,8 +39,6 @@ typedef __s64 xfs_daddr_t; /* <disk address> type */
> typedef __u32 xfs_dev_t;
> typedef __u32 xfs_nlink_t;
>
> -typedef uuid_be uuid_t;
> -
> #include "xfs_types.h"
>
> #include "kmem.h"
> diff --git a/include/linux/uuid.h b/include/linux/uuid.h
> index de3aea206562..0410cd002282 100644
> --- a/include/linux/uuid.h
> +++ b/include/linux/uuid.h
> @@ -20,19 +20,15 @@
>
> typedef struct {
> __u8 b[16];
> -} uuid_be;
> +} uuid_t;
>
> -#define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> -((uuid_be) \
> +#define UUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> +((uuid_t) \
> {{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff, \
> ((b) >> 8) & 0xff, (b) & 0xff, \
> ((c) >> 8) & 0xff, (c) & 0xff, \
> (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
>
> -#define NULL_UUID_BE \
> - UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \
> - 0x00, 0x00, 0x00, 0x00)
> -
> /*
> * V1 (time-based) UUID definition [RFC 4122].
> * - the timestamp is a 60-bit value, split 32/16/12, and goes in 100ns
> @@ -63,27 +59,40 @@ struct uuid_v1 {
> */
> #define UUID_STRING_LEN 36
>
> -static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
> -{
> - return memcmp(&u1, &u2, sizeof(uuid_le));
> -}
> -
> -static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2)
> -{
> - return memcmp(&u1, &u2, sizeof(uuid_be));
> -}
> -
> void generate_random_uuid(unsigned char uuid[16]);
>
> -extern void uuid_le_gen(uuid_le *u);
> -extern void uuid_be_gen(uuid_be *u);
> +extern void guid_gen(guid_t *u);
> +extern void uuid_gen(uuid_t *u);
>
> bool __must_check uuid_is_valid(const char *uuid);
>
> -extern const u8 uuid_le_index[16];
> -extern const u8 uuid_be_index[16];
> +extern const u8 guid_index[16];
> +extern const u8 uuid_index[16];
> +
> +int guid_to_bin(const char *uuid, guid_t *u);
> +int uuid_to_bin(const char *uuid, uuid_t *u);
>
> -int uuid_le_to_bin(const char *uuid, uuid_le *u);
> -int uuid_be_to_bin(const char *uuid, uuid_be *u);
> +/* backwards compatibility, don't use in new code */
> +typedef uuid_t uuid_be;
> +#define UUID_BE(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> + UUID(a, _b, c, d0, d1, d2, d3, d4, d5, d6, d7)
> +#define NULL_UUID_BE \
> + UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \
> + 0x00, 0x00, 0x00, 0x00)
> +
> +#define uuid_le_gen(u) guid_gen(u)
> +#define uuid_be_gen(u) uuid_gen(u)
> +#define uuid_le_to_bin(guid, u) guid_to_bin(guid, u)
> +#define uuid_be_to_bin(uuid, u) uuid_to_bin(uuid, u)
> +
> +static inline int uuid_le_cmp(const guid_t u1, const guid_t u2)
> +{
> + return memcmp(&u1, &u2, sizeof(guid_t));
> +}
> +
> +static inline int uuid_be_cmp(const uuid_t u1, const uuid_t u2)
> +{
> + return memcmp(&u1, &u2, sizeof(uuid_t));
> +}
>
> #endif
> diff --git a/include/uapi/linux/uuid.h b/include/uapi/linux/uuid.h
> index 0099756c4bac..1eeeca973315 100644
> --- a/include/uapi/linux/uuid.h
> +++ b/include/uapi/linux/uuid.h
> @@ -22,17 +22,21 @@
>
> typedef struct {
> __u8 b[16];
> -} uuid_le;
> +} guid_t;
>
> -#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> -((uuid_le) \
> +#define GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> +((guid_t) \
> {{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
> (b) & 0xff, ((b) >> 8) & 0xff, \
> (c) & 0xff, ((c) >> 8) & 0xff, \
> (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
>
> +/* backwards compatibility, don't use in new code */
> +typedef guid_t uuid_le;
> +#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) \
> + GUID(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
> #define NULL_UUID_LE \
> UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, \
> - 0x00, 0x00, 0x00, 0x00)
> + 0x00, 0x00, 0x00, 0x00)
>
> #endif /* _UAPI_LINUX_UUID_H_ */
> diff --git a/lib/test_uuid.c b/lib/test_uuid.c
> index 547d3127a3cf..9cad846fd805 100644
> --- a/lib/test_uuid.c
> +++ b/lib/test_uuid.c
> @@ -11,25 +11,25 @@
>
> struct test_uuid_data {
> const char *uuid;
> - uuid_le le;
> - uuid_be be;
> + guid_t le;
> + uuid_t be;
> };
>
> static const struct test_uuid_data test_uuid_test_data[] = {
> {
> .uuid = "c33f4995-3701-450e-9fbf-206a2e98e576",
> - .le = UUID_LE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
> - .be = UUID_BE(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
> + .le = GUID(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
> + .be = UUID(0xc33f4995, 0x3701, 0x450e, 0x9f, 0xbf, 0x20, 0x6a, 0x2e, 0x98, 0xe5, 0x76),
> },
> {
> .uuid = "64b4371c-77c1-48f9-8221-29f054fc023b",
> - .le = UUID_LE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
> - .be = UUID_BE(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
> + .le = GUID(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
> + .be = UUID(0x64b4371c, 0x77c1, 0x48f9, 0x82, 0x21, 0x29, 0xf0, 0x54, 0xfc, 0x02, 0x3b),
> },
> {
> .uuid = "0cb4ddff-a545-4401-9d06-688af53e7f84",
> - .le = UUID_LE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
> - .be = UUID_BE(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
> + .le = GUID(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
> + .be = UUID(0x0cb4ddff, 0xa545, 0x4401, 0x9d, 0x06, 0x68, 0x8a, 0xf5, 0x3e, 0x7f, 0x84),
> },
> };
>
> @@ -61,13 +61,13 @@ static void __init test_uuid_failed(const char *prefix, bool wrong, bool be,
>
> static void __init test_uuid_test(const struct test_uuid_data *data)
> {
> - uuid_le le;
> - uuid_be be;
> + guid_t le;
> + uuid_t be;
> char buf[48];
>
> /* LE */
> total_tests++;
> - if (uuid_le_to_bin(data->uuid, &le))
> + if (guid_to_bin(data->uuid, &le))
> test_uuid_failed("conversion", false, false, data->uuid, NULL);
>
> total_tests++;
> @@ -78,7 +78,7 @@ static void __init test_uuid_test(const struct test_uuid_data *data)
>
> /* BE */
> total_tests++;
> - if (uuid_be_to_bin(data->uuid, &be))
> + if (uuid_to_bin(data->uuid, &be))
> test_uuid_failed("conversion", false, true, data->uuid, NULL);
>
> total_tests++;
> @@ -90,17 +90,17 @@ static void __init test_uuid_test(const struct test_uuid_data *data)
>
> static void __init test_uuid_wrong(const char *data)
> {
> - uuid_le le;
> - uuid_be be;
> + guid_t le;
> + uuid_t be;
>
> /* LE */
> total_tests++;
> - if (!uuid_le_to_bin(data, &le))
> + if (!guid_to_bin(data, &le))
> test_uuid_failed("negative", true, false, data, NULL);
>
> /* BE */
> total_tests++;
> - if (!uuid_be_to_bin(data, &be))
> + if (!uuid_to_bin(data, &be))
> test_uuid_failed("negative", true, true, data, NULL);
> }
>
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 37687af77ff8..f80dc63f6ca8 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -21,10 +21,10 @@
> #include <linux/uuid.h>
> #include <linux/random.h>
>
> -const u8 uuid_le_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
> -EXPORT_SYMBOL(uuid_le_index);
> -const u8 uuid_be_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
> -EXPORT_SYMBOL(uuid_be_index);
> +const u8 guid_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
> +EXPORT_SYMBOL(guid_index);
> +const u8 uuid_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
> +EXPORT_SYMBOL(uuid_index);
>
> /***************************************************************
> * Random UUID interface
> @@ -53,21 +53,21 @@ static void __uuid_gen_common(__u8 b[16])
> b[8] = (b[8] & 0x3F) | 0x80;
> }
>
> -void uuid_le_gen(uuid_le *lu)
> +void guid_gen(guid_t *lu)
> {
> __uuid_gen_common(lu->b);
> /* version 4 : random generation */
> lu->b[7] = (lu->b[7] & 0x0F) | 0x40;
> }
> -EXPORT_SYMBOL_GPL(uuid_le_gen);
> +EXPORT_SYMBOL_GPL(guid_gen);
>
> -void uuid_be_gen(uuid_be *bu)
> +void uuid_gen(uuid_t *bu)
> {
> __uuid_gen_common(bu->b);
> /* version 4 : random generation */
> bu->b[6] = (bu->b[6] & 0x0F) | 0x40;
> }
> -EXPORT_SYMBOL_GPL(uuid_be_gen);
> +EXPORT_SYMBOL_GPL(uuid_gen);
>
> /**
> * uuid_is_valid - checks if UUID string valid
> @@ -115,14 +115,14 @@ static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8 ei[16])
> return 0;
> }
>
> -int uuid_le_to_bin(const char *uuid, uuid_le *u)
> +int guid_to_bin(const char *uuid, guid_t *u)
> {
> - return __uuid_to_bin(uuid, u->b, uuid_le_index);
> + return __uuid_to_bin(uuid, u->b, guid_index);
> }
> -EXPORT_SYMBOL(uuid_le_to_bin);
> +EXPORT_SYMBOL(guid_to_bin);
>
> -int uuid_be_to_bin(const char *uuid, uuid_be *u)
> +int uuid_to_bin(const char *uuid, uuid_t *u)
> {
> - return __uuid_to_bin(uuid, u->b, uuid_be_index);
> + return __uuid_to_bin(uuid, u->b, uuid_index);
> }
> -EXPORT_SYMBOL(uuid_be_to_bin);
> +EXPORT_SYMBOL(uuid_to_bin);
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 2d41de3f98a1..9f37d6208e99 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1308,14 +1308,14 @@ char *uuid_string(char *buf, char *end, const u8 *addr,
> char uuid[UUID_STRING_LEN + 1];
> char *p = uuid;
> int i;
> - const u8 *index = uuid_be_index;
> + const u8 *index = uuid_index;
> bool uc = false;
>
> switch (*(++fmt)) {
> case 'L':
> uc = true; /* fall-through */
> case 'l':
> - index = uuid_le_index;
> + index = guid_index;
> break;
> case 'B':
> uc = true;
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-05-18 17:42 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 6:26 cleanup UUID types V3 Christoph Hellwig
2017-05-18 6:26 ` [PATCH 01/23] xfs: use uuid_copy() helper to abstract uuid_t Christoph Hellwig
2017-05-18 13:27 ` Brian Foster
2017-05-18 23:32 ` Darrick J. Wong
2017-05-18 6:26 ` [PATCH 02/23] xfs: use uuid_be to implement the uuid_t type Christoph Hellwig
2017-05-18 13:27 ` Brian Foster
2017-05-18 23:34 ` Darrick J. Wong
2017-05-18 6:26 ` [PATCH 03/23] uuid: remove uuid_be defintions from the uapi header Christoph Hellwig
2017-05-18 7:12 ` Joe Perches
2017-05-18 7:13 ` Christoph Hellwig
2017-05-19 10:58 ` David Howells
2017-05-21 6:55 ` Christoph Hellwig
2017-05-18 6:26 ` [PATCH 04/23] uuid: rename uuid types Christoph Hellwig
2017-05-18 17:42 ` Darrick J. Wong [this message]
2017-05-18 6:26 ` [PATCH 05/23] uuid: don't export guid_index and uuid_index Christoph Hellwig
2017-05-18 6:26 ` [PATCH 06/23] uuid: add the v1 layout to uuid_t Christoph Hellwig
2017-05-18 6:26 ` [PATCH 07/23] uuid: hoist helpers uuid_equal() and uuid_copy() from xfs Christoph Hellwig
2017-05-18 6:26 ` [PATCH 08/23] uuid: hoist uuid_is_null() helper from libnvdimm Christoph Hellwig
2017-05-18 6:26 ` [PATCH 09/23] S390/sysinfo: use uuid_is_null instead of opencoding it Christoph Hellwig
2017-05-18 6:26 ` [PATCH 10/23] afs: switch to use uuid_t and uuid_gen Christoph Hellwig
2017-05-22 18:49 ` Andy Shevchenko
2017-05-23 8:49 ` Christoph Hellwig
2017-05-23 13:11 ` Andy Shevchenko
2017-05-25 13:00 ` Christoph Hellwig
2017-05-25 13:29 ` Andy Shevchenko
2017-05-18 6:26 ` [PATCH 11/23] uuid: remove struct uuid_v1 Christoph Hellwig
2017-05-18 6:26 ` [PATCH 12/23] xfs: remove uuid_getnodeuniq and xfs_uu_t Christoph Hellwig
2017-05-18 13:27 ` Brian Foster
2017-05-18 23:35 ` Darrick J. Wong
2017-05-18 6:26 ` [PATCH 13/23] md: namespace private helper names Christoph Hellwig
2017-05-18 18:32 ` Shaohua Li
2017-05-22 18:52 ` Andy Shevchenko
2017-05-23 8:41 ` Christoph Hellwig
2017-05-18 6:26 ` [PATCH 14/23] xfs: use the common helper uuid_is_null() Christoph Hellwig
2017-05-18 13:27 ` Brian Foster
2017-05-18 6:26 ` [PATCH 15/23] block: remove blk_part_pack_uuid Christoph Hellwig
2017-05-18 23:15 ` Mimi Zohar
2017-05-18 6:26 ` [PATCH 16/23] ima/policy: switch to use uuid_t Christoph Hellwig
2017-05-18 23:16 ` Mimi Zohar
2017-05-18 6:26 ` [PATCH 17/23] fs: switch ->s_uuid to uuid_t Christoph Hellwig
2017-05-18 23:17 ` Mimi Zohar
2017-05-18 6:27 ` [PATCH 18/23] overlayfs: use uuid_t instead of uuid_be Christoph Hellwig
2017-05-18 6:27 ` [PATCH 19/23] partitions/ldm: switch to use uuid_t Christoph Hellwig
2017-05-18 6:27 ` [PATCH 20/23] sysctl: " Christoph Hellwig
2017-05-18 6:27 ` [PATCH 21/23] nvme: switch to uuid_t Christoph Hellwig
2017-05-18 6:27 ` [PATCH 22/23] scsi_debug: " Christoph Hellwig
2017-05-18 6:27 ` [PATCH 23/23] uuid: remove uuid_be Christoph Hellwig
2017-05-18 7:57 ` Amir Goldstein
2017-05-18 8:56 ` Christoph Hellwig
2017-05-22 18:59 ` Andy Shevchenko
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=20170518174208.GC4519@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=amir73il@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@ml01.01.org \
--cc=linux-raid@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=shli@kernel.org \
--cc=swhiteho@redhat.com \
--cc=zohar@linux.vnet.ibm.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 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).