From patchwork Tue May 2 20:19:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9708565 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 7409960349 for ; Tue, 2 May 2017 20:19:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 676B6284DA for ; Tue, 2 May 2017 20:19:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BD5D28558; Tue, 2 May 2017 20:19:27 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 0C365284DA for ; Tue, 2 May 2017 20:19:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751151AbdEBUTZ (ORCPT ); Tue, 2 May 2017 16:19:25 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:36581 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750850AbdEBUTX (ORCPT ); Tue, 2 May 2017 16:19:23 -0400 Received: by mail-wr0-f193.google.com with SMTP id v42so19472341wrc.3; Tue, 02 May 2017 13:19:22 -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; bh=bMiAIEcdxyKE6uD/k0Cpj/uz6jJ1yyRZNnc9XzEGUEY=; b=lQSfhmhXa7K1gKYxFv3UyDIvn3jBpEwvFQzb6N7qj6kKGlYtK4jtj/Hpb2gTabd6HI LbGQrmBGRqXyFUMQsYif1so2fVvwUv3tUXuZyWxLFBT+FJCz8x408xdZ8t3XQLrpuE0S CayUpGrL+o8PwvtWOFcB/ff9jschOKKWrbj1hapFWAWcqbRcpwQwGFgJ8nyR5c1css0r ysOwOlkBG6HRlKh7P935pPzUpAoFv/2ZJJvHNVHeHVusit1FXM3bHR3QRWNY22teMXjT HxDYAefzuHw5NnrDxeaqZOQ+QBfSOwcw5QPqMe/rYfbbd3LzEIUf5zDZ6MV9UfjpGQIN 6TfA== 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; bh=bMiAIEcdxyKE6uD/k0Cpj/uz6jJ1yyRZNnc9XzEGUEY=; b=pFkzVUrNe3DcymGoV93SsPAHyFBNkVoWbXGxEORGJwgSCnFzPt7qgYCi6tic0QTB75 sP4gVoMaRD9hmGqWlzeHlcp4z0U1aAgqHGn8KN/7dLONDvpMo+OzXqYG80o4bKyn/PkI Jr8PbnwOEZjbjJBKCo8GeIFToH6looO1aF/RFZ6sUNxbHKt4B0jKLT0plduLzP7D2GB8 sowxn//OdkDBKuJS1b2+ZZhrNvixlzeV3cBNOzyexEwsEBJ02I6XgQIBeBP99+yAr2Iw ENyEtkLvjIzBqLkSPYpfDhBV898kZYRFEkxZVLnA+J63YnMconwKISp2grR7Y8nd6VBE 8tzQ== X-Gm-Message-State: AN3rC/7yA6vGd/H9jfkNp+4i+dz81zofD8ZT+YfkVMwoJCsj41QCg9u0 sD2R4VMh/DovOg== X-Received: by 10.223.164.148 with SMTP id g20mr21092248wrb.89.1493756361862; Tue, 02 May 2017 13:19:21 -0700 (PDT) Received: from amir-VirtualBox.lan (bzq-79-179-55-127.red.bezeqint.net. [79.179.55.127]) by smtp.gmail.com with ESMTPSA id l82sm1928542wmf.17.2017.05.02.13.19.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 May 2017 13:19:20 -0700 (PDT) From: Amir Goldstein To: Christoph Hellwig Cc: Miklos Szeredi , Mimi Zohar , Konrad Rzeszutek Wilk , Richard Weinberger , "Darrick J . Wong" , Mark Fasheh , Al Viro , linux-xfs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Dan Williams , Andy Shevchenko , David Howells Subject: [RFC][PATCH] linux/uuid.h: hoist uuid_is_null() helper from libnvdimm Date: Tue, 2 May 2017 23:19:23 +0300 Message-Id: <1493756363-5113-1-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need a helper for VFS to check if struct super_block field s_uuid was filled by the filesystem, before consumers can use it. The libnvdimm code already has a private helper to check if uuid is null and the helper name is not using a private namespace prefix, which prevents us from using the same helper name as a common function. Hoist the libnvdimm helper as an inline helper to linux/uuid.h. Suggested-by: Christoph Hellwig Cc: Dan Williams Cc: Andy Shevchenko Cc: David Howells Signed-off-by: Amir Goldstein Acked-by: Dan Williams --- drivers/nvdimm/btt_devs.c | 8 +------- include/linux/uuid.h | 7 +++++++ 2 files changed, 8 insertions(+), 7 deletions(-) Christoph, Following your suggestion to provide a helper for checking if filesystem had filled sb->s_uuid, here is a patch to add that helper. I considered hoisting xfs's uuid_is_nil() helper and uuid_t to uuid.h, but that would have been more painful, so just moved this simple helper instead. We can continue debating which implementation is better, but that would be futile... If in the future xfs uuid table code is going to be moved to VFS, we should probably move variants of the xfs/uuid.c functions to lib/uuid.c if those variants don't already exist. CC'ing the maintainers of clearcache and EVM/IMA to see if this helper should be added (as sanity?) to their code before accessing sb->s_uuid. I truely hope that EVM/IMA signatures do not expect xfs/ubifs to keep exporting null s_uuid, because if they do, then starting to export s_uuid for xfs/ubifs may require a new config/mkfs/mount option and that would be a shame. Cheers, Amir. diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c index 97dd292..d0fcda2 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 diff --git a/include/linux/uuid.h b/include/linux/uuid.h index 4dff73a..d3f8656 100644 --- a/include/linux/uuid.h +++ b/include/linux/uuid.h @@ -58,6 +58,13 @@ static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2) return memcmp(&u1, &u2, sizeof(uuid_be)); } +static inline bool uuid_is_null(u8 *uuid) +{ + static const u8 null_uuid[16]; + + return (memcmp(uuid, null_uuid, 16) == 0); +} + void generate_random_uuid(unsigned char uuid[16]); extern void uuid_le_gen(uuid_le *u);