From patchwork Thu May 4 13:26:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9711971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1ACF660362 for ; Thu, 4 May 2017 13:26:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1044B28665 for ; Thu, 4 May 2017 13:26:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0526A2868D; Thu, 4 May 2017 13:26:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1D9D28665 for ; Thu, 4 May 2017 13:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751904AbdEDN0j (ORCPT ); Thu, 4 May 2017 09:26:39 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34978 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753558AbdEDN0a (ORCPT ); Thu, 4 May 2017 09:26:30 -0400 Received: by mail-wm0-f66.google.com with SMTP id d79so3342495wmi.2; Thu, 04 May 2017 06:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qunjY4Edp/a6RafEYQVlB1JdIY1WC//5x5/yhf1ptFY=; b=VUBUfCbphyBBnP95wLKLiFuxvtxvoUZa07+mAh472Eyqz21VIRLaZ8pZINcc9SBfkC IT6bbsfP+gjaixiqQvH5+ML+jvKJ/qwmfeZRgNQV2a8ptQyYcn6kwNcjpuYE7QPq4hwL FGeDCem7SpETSZnMDqQgFWoJ1Z+yvZZ+S1PyhPOVaCGuErR+CHXqgVXUkUMxCoVaBMlQ trhDS5IxmtfPjtquqB2Nv0+0Oo84uezcVprBxSJdM/kdzPETE4wM9lizWOGhL0M0iq5M Nj/KJXsLjOcmsCVZynBwGAKxOCHLJkwmeOqacVtMCAMpKW63VJcvrpBHfs/Qbc9m7PXf r+0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qunjY4Edp/a6RafEYQVlB1JdIY1WC//5x5/yhf1ptFY=; b=ILLQ4Re5qWzL9cuG8bHB8pmyUu4G/1k9Y0CZ0VC0lj8XLr2vH7oQpVFrM4q1xApTuw IuwdpUC22saRCL4sGOJdINRMH2Ij6pWRMNouz8/JJH13cZIjUfPpG5jJAwwcS49DN296 cj0ExtJu0e/r7Ra68Fihnz/Crof1c7+X5KEWbHWXi2DUCRnMmYtZpe9ItG428PMBBPWs msGxcUaTNKKwop/Lj2UbXX0qG2YHl9oRmr1JCMX86wJj7qFITaFJu40XWeZ7OT8QUxT7 rM/bk0E2Th9SJqGS/N3IWSq4tTj6pcvMhcdlhVEofAESFu/GudA7JoPwVvuOIJ8qdacH F2uA== X-Gm-Message-State: AN3rC/4Lv0mlIisGXeHTaOU1z82KAca6eP6GshdUKq1mApOa6JDVFl6O lbrUHWh2ucZEeg== X-Received: by 10.28.97.139 with SMTP id v133mr1755562wmb.93.1493904389180; Thu, 04 May 2017 06:26:29 -0700 (PDT) Received: from amir-VirtualBox.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id m201sm1831681wmd.15.2017.05.04.06.26.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 May 2017 06:26:28 -0700 (PDT) From: Amir Goldstein To: "Darrick J . Wong" Cc: Christoph Hellwig , Miklos Szeredi , Theodore Tso , Richard Weinberger , Mark Fasheh , Dan Williams , Andy Shevchenko , David Howells , Shaohua Li , Al Viro , 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 Message-Id: <1493904383-2187-8-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1493904383-2187-1-git-send-email-amir73il@gmail.com> References: <1493904383-2187-1-git-send-email-amir73il@gmail.com> Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Dan Williams Cc: Andy Shevchenko Cc: David Howells Signed-off-by: Amir Goldstein --- 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 #include #include +#include #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 #include +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};