From: Amir Goldstein <amir73il@gmail.com>
To: "Darrick J . Wong" <darrick.wong@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>,
Miklos Szeredi <miklos@szeredi.hu>, Theodore Tso <tytso@mit.edu>,
Richard Weinberger <richard@nod.at>,
Mark Fasheh <mfasheh@versity.com>,
Dan Williams <dan.j.williams@intel.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
David Howells <dhowells@redhat.com>, Shaohua Li <shli@kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: [PATCH v2 7/8] linux/uuid.h: hoist uuid_is_null() helper from libnvdimm
Date: Thu, 4 May 2017 16:26:22 +0300 [thread overview]
Message-ID: <1493904383-2187-8-git-send-email-amir73il@gmail.com> (raw)
In-Reply-To: <1493904383-2187-1-git-send-email-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.
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>
---
drivers/nvdimm/btt_devs.c | 10 ++--------
include/linux/uuid.h | 7 +++++++
lib/uuid.c | 3 +++
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c
index 97dd292..f52c66d 100644
--- a/drivers/nvdimm/btt_devs.c
+++ b/drivers/nvdimm/btt_devs.c
@@ -17,6 +17,7 @@
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/mm.h>
+#include <linux/uuid.h>
#include "nd-core.h"
#include "btt.h"
#include "nd.h"
@@ -222,13 +223,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 +243,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 (!uuid_is_null((uuid_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 a1dd9cc..a617ccf 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -68,6 +68,13 @@ static inline void uuid_copy(uuid_t *dst, const uuid_t *src)
memcpy(dst, src, sizeof(uuid_t));
}
+extern const uuid_t uuid_null;
+
+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 uuid_le_gen(uuid_le *u);
diff --git a/lib/uuid.c b/lib/uuid.c
index 37687af..17d0360 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -21,6 +21,9 @@
#include <linux/uuid.h>
#include <linux/random.h>
+const uuid_t uuid_null;
+EXPORT_SYMBOL(uuid_null);
+
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};
--
2.7.4
next prev parent reply other threads:[~2017-05-04 13:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 13:26 [PATCH v2 0/8] hoist uuid helpers from xfs to linux/uuid.h Amir Goldstein
2017-05-04 13:26 ` [PATCH v2 1/8] xfs: use uuid_copy() helper to abstract uuid_t Amir Goldstein
2017-05-04 13:31 ` Christoph Hellwig
2017-05-04 13:26 ` [PATCH v2 2/8] xfs: re-define uuid_t as common struct uuid_v1 Amir Goldstein
2017-05-04 13:34 ` Christoph Hellwig
2017-05-04 13:57 ` Amir Goldstein
2017-05-04 13:59 ` Christoph Hellwig
2017-05-04 14:00 ` Amir Goldstein
2017-05-04 14:01 ` Christoph Hellwig
2017-05-04 14:16 ` David Howells
2017-05-04 14:18 ` Christoph Hellwig
2017-05-04 14:36 ` David Howells
2017-05-04 13:26 ` [PATCH v2 3/8] xfs: dismiss xfs_uu_t Amir Goldstein
2017-05-04 13:35 ` Christoph Hellwig
2017-05-04 13:26 ` [PATCH v2 4/8] xfs: namespace the helper uuid_getnodeuniq() Amir Goldstein
2017-05-04 13:28 ` Christoph Hellwig
2017-05-04 13:26 ` [PATCH v2 5/8] md: namespace private helper names Amir Goldstein
2017-05-04 13:26 ` [PATCH v2 6/8] linux/uuid.h: hoist helpers uuid_equal() and uuid_copy() from xfs Amir Goldstein
2017-05-04 13:26 ` Amir Goldstein [this message]
2017-05-04 13:30 ` [PATCH v2 7/8] linux/uuid.h: hoist uuid_is_null() helper from libnvdimm Christoph Hellwig
2017-05-04 13:26 ` [PATCH v2 8/8] xfs: use the common helper uuid_is_null() Amir Goldstein
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=1493904383-2187-8-git-send-email-amir73il@gmail.com \
--to=amir73il@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=darrick.wong@oracle.com \
--cc=dhowells@redhat.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mfasheh@versity.com \
--cc=miklos@szeredi.hu \
--cc=richard@nod.at \
--cc=shli@kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/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).