Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1638990 > unrolled thread
| Started by | Christoph Hellwig <hch@lst.de> |
|---|---|
| First post | 2017-05-10 20:10 +0200 |
| Last post | 2017-05-10 20:10 +0200 |
| Articles | 7 on this page of 27 — 4 participants |
Back to article view | Back to linux.kernel
cleanup UUID types Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 04/16] uuid: don't export guid_index and uuid_index Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 03/16] uuid: rename uuid types Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
Re: [PATCH 03/16] uuid: rename uuid types David Howells <dhowells@redhat.com> - 2017-05-10 20:30 +0200
Re: [PATCH 03/16] uuid: rename uuid types Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-05-11 13:40 +0200
Re: [PATCH 03/16] uuid: rename uuid types Amir Goldstein <amir73il@gmail.com> - 2017-05-10 21:20 +0200
Re: [PATCH 03/16] uuid: rename uuid types Christoph Hellwig <hch@lst.de> - 2017-05-11 10:00 +0200
Re: [PATCH 03/16] uuid: rename uuid types Amir Goldstein <amir73il@gmail.com> - 2017-05-11 10:40 +0200
[PATCH 02/16] xfs: use uuid_be to implement the uuid_t type Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 06/16] afs: switch to use uuid_t and uuid_gen Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
Re: [PATCH 06/16] afs: switch to use uuid_t and uuid_gen David Howells <dhowells@redhat.com> - 2017-05-10 20:30 +0200
[PATCH 16/16] fs: switch ->s_uuid to uuid_t Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
Re: [PATCH 16/16] fs: switch ->s_uuid to uuid_t Amir Goldstein <amir73il@gmail.com> - 2017-05-10 21:10 +0200
Re: [PATCH 16/16] fs: switch ->s_uuid to uuid_t Christoph Hellwig <hch@lst.de> - 2017-05-11 10:00 +0200
[PATCH 13/16] block: remove blk_part_pack_uuid Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 14/16] block: remove blk_part_pack_uuid Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
Re: [PATCH 14/16] block: remove blk_part_pack_uuid Christoph Hellwig <hch@lst.de> - 2017-05-10 20:20 +0200
[PATCH 05/16] uuid: add the v1 layout to uuid_t Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
Re: [PATCH 05/16] uuid: add the v1 layout to uuid_t David Howells <dhowells@redhat.com> - 2017-05-10 20:30 +0200
Re: [PATCH 05/16] uuid: add the v1 layout to uuid_t Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-05-11 13:50 +0200
Re: [PATCH 05/16] uuid: add the v1 layout to uuid_t Christoph Hellwig <hch@lst.de> - 2017-05-11 14:10 +0200
[PATCH 01/16] xfs: use uuid_copy() helper to abstract uuid_t Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 09/16] md: namespace private helper names Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 12/16] xfs: use the common helper uuid_is_null() Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 08/16] xfs: remove uuid_getnodeuniq and xfs_uu_t Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 10/16] uuid: hoist helpers uuid_equal() and uuid_copy() from xfs Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
[PATCH 11/16] uuid: hoist uuid_is_null() helper from libnvdimm Christoph Hellwig <hch@lst.de> - 2017-05-10 20:10 +0200
Page 2 of 2 — ← Prev page 1 [2]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-11 14:10 +0200 |
| Subject | Re: [PATCH 05/16] uuid: add the v1 layout to uuid_t |
| Message-ID | <tFV4R-68O-7@gated-at.bofh.it> |
| In reply to | #1639322 |
On Thu, May 11, 2017 at 02:40:38PM +0300, Andy Shevchenko wrote: > On Wed, 2017-05-10 at 20:02 +0200, Christoph Hellwig wrote: > > Turn the content of uuid_t into a union and add the fields for the v1 > > interpretation to it. > > In the branch it has fix for UUID() wrt union change, but there missed > similar for GUID(). Actually UUID needed this because uuid_t has a unіon inside, GUID should not need it because it doesn't. > While here, can we indent \ to be the same as of the rest lines in > macro(s) ? Sure.
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-10 20:10 +0200 |
| Subject | [PATCH 01/16] xfs: use uuid_copy() helper to abstract uuid_t |
| Message-ID | <tFEdI-40t-33@gated-at.bofh.it> |
| In reply to | #1638990 |
From: Amir Goldstein <amir73il@gmail.com> uuid_t definition is about to change. Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/xfs/xfs_inode_item.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 08cb7d1a4a3a..013cc78d7daf 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c @@ -834,9 +834,7 @@ xfs_inode_item_format_convert( in_f->ilf_dsize = in_f32->ilf_dsize; in_f->ilf_ino = in_f32->ilf_ino; /* copy biggest field of ilf_u */ - memcpy(in_f->ilf_u.ilfu_uuid.__u_bits, - in_f32->ilf_u.ilfu_uuid.__u_bits, - sizeof(uuid_t)); + uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f32->ilf_u.ilfu_uuid); in_f->ilf_blkno = in_f32->ilf_blkno; in_f->ilf_len = in_f32->ilf_len; in_f->ilf_boffset = in_f32->ilf_boffset; @@ -851,9 +849,7 @@ xfs_inode_item_format_convert( in_f->ilf_dsize = in_f64->ilf_dsize; in_f->ilf_ino = in_f64->ilf_ino; /* copy biggest field of ilf_u */ - memcpy(in_f->ilf_u.ilfu_uuid.__u_bits, - in_f64->ilf_u.ilfu_uuid.__u_bits, - sizeof(uuid_t)); + uuid_copy(&in_f->ilf_u.ilfu_uuid, &in_f64->ilf_u.ilfu_uuid); in_f->ilf_blkno = in_f64->ilf_blkno; in_f->ilf_len = in_f64->ilf_len; in_f->ilf_boffset = in_f64->ilf_boffset; -- 2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-10 20:10 +0200 |
| Subject | [PATCH 09/16] md: namespace private helper names |
| Message-ID | <tFEdI-40t-31@gated-at.bofh.it> |
| In reply to | #1638990 |
From: Amir Goldstein <amir73il@gmail.com>
The md private helper uuid_equal() collides with a generic helper
of the same name.
Rename the md private helper to md_uuid_equal() and do the same for
md_sb_equal().
Cc: Shaohua Li <shli@kernel.org>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/md/md.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 82f798be964f..65795cc4cb7d 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -825,7 +825,7 @@ static int read_disk_sb(struct md_rdev *rdev, int size)
return -EINVAL;
}
-static int uuid_equal(mdp_super_t *sb1, mdp_super_t *sb2)
+static int md_uuid_equal(mdp_super_t *sb1, mdp_super_t *sb2)
{
return sb1->set_uuid0 == sb2->set_uuid0 &&
sb1->set_uuid1 == sb2->set_uuid1 &&
@@ -833,7 +833,7 @@ static int uuid_equal(mdp_super_t *sb1, mdp_super_t *sb2)
sb1->set_uuid3 == sb2->set_uuid3;
}
-static int sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
+static int md_sb_equal(mdp_super_t *sb1, mdp_super_t *sb2)
{
int ret;
mdp_super_t *tmp1, *tmp2;
@@ -1025,12 +1025,12 @@ static int super_90_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor
} else {
__u64 ev1, ev2;
mdp_super_t *refsb = page_address(refdev->sb_page);
- if (!uuid_equal(refsb, sb)) {
+ if (!md_uuid_equal(refsb, sb)) {
pr_warn("md: %s has different UUID to %s\n",
b, bdevname(refdev->bdev,b2));
goto abort;
}
- if (!sb_equal(refsb, sb)) {
+ if (!md_sb_equal(refsb, sb)) {
pr_warn("md: %s has same UUID but different superblock to %s\n",
b, bdevname(refdev->bdev, b2));
goto abort;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-10 20:10 +0200 |
| Subject | [PATCH 12/16] xfs: use the common helper uuid_is_null() |
| Message-ID | <tFEdI-40t-37@gated-at.bofh.it> |
| In reply to | #1638990 |
From: Amir Goldstein <amir73il@gmail.com>
Use the common helper uuid_is_null() and remove the xfs specific
helper uuid_is_nil().
The common helper does not check for the NULL pointer value as
xfs helper did, but xfs code never calls the helper with a pointer
that can be NULL.
Conform comments and warning strings to use the term 'null uuid'
instead of 'nil uuid', because this is the terminology used by
lib/uuid.c and its users. It is also the terminology used in
userspace by libuuid and xfsprogs.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
[hch: remove now unused uuid.[ch]]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/Makefile | 3 +--
fs/xfs/uuid.c | 32 --------------------------------
fs/xfs/uuid.h | 23 -----------------------
fs/xfs/xfs_linux.h | 1 -
fs/xfs/xfs_log_recover.c | 6 +++---
fs/xfs/xfs_mount.c | 8 ++++----
6 files changed, 8 insertions(+), 65 deletions(-)
delete mode 100644 fs/xfs/uuid.c
delete mode 100644 fs/xfs/uuid.h
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index 5c90f82b8f6b..a6e955bfead8 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -98,8 +98,7 @@ xfs-y += xfs_aops.o \
xfs_sysfs.o \
xfs_trans.o \
xfs_xattr.o \
- kmem.o \
- uuid.o
+ kmem.o
# low-level transaction/log code
xfs-y += xfs_log.o \
diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
deleted file mode 100644
index 737c186ea98b..000000000000
--- a/fs/xfs/uuid.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#include <xfs.h>
-
-int
-uuid_is_nil(uuid_t *uuid)
-{
- int i;
- char *cp = (char *)uuid;
-
- if (uuid == NULL)
- return 0;
- /* implied check of version number here... */
- for (i = 0; i < sizeof *uuid; i++)
- if (*cp++) return 0; /* not nil */
- return 1; /* is nil */
-}
diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
deleted file mode 100644
index 5aea49bf0963..000000000000
--- a/fs/xfs/uuid.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-#ifndef __XFS_SUPPORT_UUID_H__
-#define __XFS_SUPPORT_UUID_H__
-
-extern int uuid_is_nil(uuid_t *uuid);
-
-#endif /* __XFS_SUPPORT_UUID_H__ */
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
index 2c33d915e550..2d167fe643ec 100644
--- a/fs/xfs/xfs_linux.h
+++ b/fs/xfs/xfs_linux.h
@@ -43,7 +43,6 @@ typedef __u32 xfs_nlink_t;
#include "kmem.h"
#include "mrlock.h"
-#include "uuid.h"
#include <linux/semaphore.h>
#include <linux/mm.h>
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index cd0b077deb35..8cec1e5505a4 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -352,13 +352,13 @@ xlog_header_check_mount(
{
ASSERT(head->h_magicno == cpu_to_be32(XLOG_HEADER_MAGIC_NUM));
- if (uuid_is_nil(&head->h_fs_uuid)) {
+ if (uuid_is_null(&head->h_fs_uuid)) {
/*
* IRIX doesn't write the h_fs_uuid or h_fmt fields. If
- * h_fs_uuid is nil, we assume this log was last mounted
+ * h_fs_uuid is null, we assume this log was last mounted
* by IRIX and continue.
*/
- xfs_warn(mp, "nil uuid in log - IRIX style log");
+ xfs_warn(mp, "null uuid in log - IRIX style log");
} else if (unlikely(!uuid_equal(&mp->m_sb.sb_uuid, &head->h_fs_uuid))) {
xfs_warn(mp, "log has mismatched uuid - can't recover");
xlog_header_check_dump(mp, head);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 742e4a61c0bc..682b336a7a6a 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -80,14 +80,14 @@ xfs_uuid_mount(
if (mp->m_flags & XFS_MOUNT_NOUUID)
return 0;
- if (uuid_is_nil(uuid)) {
- xfs_warn(mp, "Filesystem has nil UUID - can't mount");
+ if (uuid_is_null(uuid)) {
+ xfs_warn(mp, "Filesystem has null UUID - can't mount");
return -EINVAL;
}
mutex_lock(&xfs_uuid_table_mutex);
for (i = 0, hole = -1; i < xfs_uuid_table_size; i++) {
- if (uuid_is_nil(&xfs_uuid_table[i])) {
+ if (uuid_is_null(&xfs_uuid_table[i])) {
hole = i;
continue;
}
@@ -124,7 +124,7 @@ xfs_uuid_unmount(
mutex_lock(&xfs_uuid_table_mutex);
for (i = 0; i < xfs_uuid_table_size; i++) {
- if (uuid_is_nil(&xfs_uuid_table[i]))
+ if (uuid_is_null(&xfs_uuid_table[i]))
continue;
if (!uuid_equal(uuid, &xfs_uuid_table[i]))
continue;
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-10 20:10 +0200 |
| Subject | [PATCH 08/16] xfs: remove uuid_getnodeuniq and xfs_uu_t |
| Message-ID | <tFEdI-40t-39@gated-at.bofh.it> |
| In reply to | #1638990 |
Directly use the v1 intepretation of uuid_t instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/uuid.c | 25 -------------------------
fs/xfs/uuid.h | 1 -
fs/xfs/xfs_mount.c | 6 +++++-
3 files changed, 5 insertions(+), 27 deletions(-)
diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
index b83f76b6d410..937deaf2128d 100644
--- a/fs/xfs/uuid.c
+++ b/fs/xfs/uuid.c
@@ -17,31 +17,6 @@
*/
#include <xfs.h>
-/* IRIX interpretation of an uuid_t */
-typedef struct {
- __be32 uu_timelow;
- __be16 uu_timemid;
- __be16 uu_timehi;
- __be16 uu_clockseq;
- __be16 uu_node[3];
-} xfs_uu_t;
-
-/*
- * uuid_getnodeuniq - obtain the node unique fields of a UUID.
- *
- * This is not in any way a standard or condoned UUID function;
- * it just something that's needed for user-level file handles.
- */
-void
-uuid_getnodeuniq(uuid_t *uuid, int fsid [2])
-{
- xfs_uu_t *uup = (xfs_uu_t *)uuid;
-
- fsid[0] = (be16_to_cpu(uup->uu_clockseq) << 16) |
- be16_to_cpu(uup->uu_timemid);
- fsid[1] = be32_to_cpu(uup->uu_timelow);
-}
-
int
uuid_is_nil(uuid_t *uuid)
{
diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
index 4f1441ba4fa5..65b5cebf2f99 100644
--- a/fs/xfs/uuid.h
+++ b/fs/xfs/uuid.h
@@ -20,7 +20,6 @@
extern int uuid_is_nil(uuid_t *uuid);
extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
-extern void uuid_getnodeuniq(uuid_t *uuid, int fsid [2]);
static inline void
uuid_copy(uuid_t *dst, uuid_t *src)
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 2eaf81859166..742e4a61c0bc 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -793,7 +793,11 @@ xfs_mountfs(
* Copies the low order bits of the timestamp and the randomly
* set "sequence" number out of a UUID.
*/
- uuid_getnodeuniq(&sbp->sb_uuid, mp->m_fixedfsid);
+ mp->m_fixedfsid[0] =
+ ((u32)sbp->sb_uuid.v1.clock_seq_hi_and_reserved << 24) |
+ ((u32)sbp->sb_uuid.v1.clock_seq_low << 16) |
+ be16_to_cpu(sbp->sb_uuid.v1.time_mid);
+ mp->m_fixedfsid[1] = be32_to_cpu(sbp->sb_uuid.v1.time_low);
mp->m_dmevmask = 0; /* not persistent; set after each mount */
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-10 20:10 +0200 |
| Subject | [PATCH 10/16] uuid: hoist helpers uuid_equal() and uuid_copy() from xfs |
| Message-ID | <tFEdJ-40t-45@gated-at.bofh.it> |
| In reply to | #1638990 |
From: Amir Goldstein <amir73il@gmail.com>
These helper are used to compare and copy two uuid_t type objects.
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
[hch: also provide the respective guid_ versions]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/uuid.c | 6 ------
fs/xfs/uuid.h | 7 -------
include/linux/uuid.h | 20 ++++++++++++++++++++
3 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/fs/xfs/uuid.c b/fs/xfs/uuid.c
index 937deaf2128d..737c186ea98b 100644
--- a/fs/xfs/uuid.c
+++ b/fs/xfs/uuid.c
@@ -30,9 +30,3 @@ uuid_is_nil(uuid_t *uuid)
if (*cp++) return 0; /* not nil */
return 1; /* is nil */
}
-
-int
-uuid_equal(uuid_t *uuid1, uuid_t *uuid2)
-{
- return memcmp(uuid1, uuid2, sizeof(uuid_t)) ? 0 : 1;
-}
diff --git a/fs/xfs/uuid.h b/fs/xfs/uuid.h
index 65b5cebf2f99..5aea49bf0963 100644
--- a/fs/xfs/uuid.h
+++ b/fs/xfs/uuid.h
@@ -19,12 +19,5 @@
#define __XFS_SUPPORT_UUID_H__
extern int uuid_is_nil(uuid_t *uuid);
-extern int uuid_equal(uuid_t *uuid1, uuid_t *uuid2);
-
-static inline void
-uuid_copy(uuid_t *dst, uuid_t *src)
-{
- memcpy(dst, src, sizeof(uuid_t));
-}
#endif /* __XFS_SUPPORT_UUID_H__ */
diff --git a/include/linux/uuid.h b/include/linux/uuid.h
index 28a5a894b926..b7fec8b266eb 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -29,11 +29,31 @@ static inline int guid_cmp(const guid_t u1, const guid_t u2)
return memcmp(&u1, &u2, sizeof(guid_t));
}
+static inline bool guid_equal(const guid_t *u1, const guid_t *u2)
+{
+ return memcmp(u1, u2, sizeof(guid_t)) == 0;
+}
+
+static inline void guid_copy(guid_t *dst, const guid_t *src)
+{
+ memcpy(dst, src, sizeof(guid_t));
+}
+
static inline int uuid_cmp(const uuid_t u1, const uuid_t u2)
{
return memcmp(&u1, &u2, sizeof(uuid_t));
}
+static inline bool uuid_equal(const uuid_t *u1, const uuid_t *u2)
+{
+ return memcmp(u1, u2, sizeof(uuid_t)) == 0;
+}
+
+static inline void uuid_copy(uuid_t *dst, const uuid_t *src)
+{
+ memcpy(dst, src, sizeof(uuid_t));
+}
+
void generate_random_uuid(unsigned char uuid[16]);
extern void guid_gen(guid_t *u);
--
2.11.0
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@lst.de> |
|---|---|
| Date | 2017-05-10 20:10 +0200 |
| Subject | [PATCH 11/16] uuid: hoist uuid_is_null() helper from libnvdimm |
| Message-ID | <tFEdJ-40t-43@gated-at.bofh.it> |
| In reply to | #1638990 |
From: Amir Goldstein <amir73il@gmail.com>
Hoist the libnvdimm helper as an inline helper to linux/uuid.h
using an auxiliary const variable uuid_null in lib/uuid.c.
[hch: also add the guid variant. Both do the same but I'd like
to keep casts to a minimum]
The common helper uses the new abstract type uuid_t * instead of
u8 *.
Suggested-by: Christoph Hellwig <hch@lst.de>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
[hch: added guid_is_null]
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/nvdimm/btt_devs.c | 9 +--------
include/linux/uuid.h | 13 +++++++++++++
lib/uuid.c | 5 +++++
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 4b76af2b8715..734290d30557 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -222,13 +222,6 @@ struct device *nd_btt_create(struct nd_region *nd_region)
return dev;
}
-static bool uuid_is_null(u8 *uuid)
-{
- static const u8 null_uuid[16];
-
- return (memcmp(uuid, null_uuid, 16) == 0);
-}
-
/**
* nd_btt_arena_is_valid - check if the metadata layout is valid
* @nd_btt: device with BTT geometry and backing device info
@@ -249,7 +242,7 @@ bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super)
if (memcmp(super->signature, BTT_SIG, BTT_SIG_LEN) != 0)
return false;
- if (!uuid_is_null(super->parent_uuid))
+ if (!guid_is_null((guid_t *)&super->parent_uuid))
if (memcmp(super->parent_uuid, parent_uuid, 16) != 0)
return false;
diff --git a/include/linux/uuid.h b/include/linux/uuid.h
index b7fec8b266eb..2f9bdc88079e 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -24,6 +24,9 @@
*/
#define UUID_STRING_LEN 36
+extern const guid_t guid_null;
+extern const uuid_t uuid_null;
+
static inline int guid_cmp(const guid_t u1, const guid_t u2)
{
return memcmp(&u1, &u2, sizeof(guid_t));
@@ -39,6 +42,11 @@ static inline void guid_copy(guid_t *dst, const guid_t *src)
memcpy(dst, src, sizeof(guid_t));
}
+static inline bool guid_is_null(guid_t *guid)
+{
+ return guid_equal(guid, &guid_null);
+}
+
static inline int uuid_cmp(const uuid_t u1, const uuid_t u2)
{
return memcmp(&u1, &u2, sizeof(uuid_t));
@@ -54,6 +62,11 @@ static inline void uuid_copy(uuid_t *dst, const uuid_t *src)
memcpy(dst, src, sizeof(uuid_t));
}
+static inline bool uuid_is_null(uuid_t *uuid)
+{
+ return uuid_equal(uuid, &uuid_null);
+}
+
void generate_random_uuid(unsigned char uuid[16]);
extern void guid_gen(guid_t *u);
diff --git a/lib/uuid.c b/lib/uuid.c
index 003bf6823003..25145bfb0eaa 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -21,6 +21,11 @@
#include <linux/uuid.h>
#include <linux/random.h>
+const guid_t guid_null;
+EXPORT_SYMBOL(guid_null);
+const uuid_t uuid_null;
+EXPORT_SYMBOL(uuid_null);
+
const u8 guid_index[16] = {3,2,1,0,5,4,7,6,8,9,10,11,12,13,14,15};
const u8 uuid_index[16] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
--
2.11.0
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | linux.kernel
csiph-web