From patchwork Thu Dec 17 23:00:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kani, Toshi" X-Patchwork-Id: 7877821 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 31BC29F349 for ; Thu, 17 Dec 2015 23:00:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56B4020443 for ; Thu, 17 Dec 2015 23:00:19 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 28A7720437 for ; Thu, 17 Dec 2015 23:00:18 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 065C71A21DE; Thu, 17 Dec 2015 15:00:18 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from g2t2354.austin.hp.com (g2t2354.austin.hp.com [15.217.128.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7C1F41A21DE for ; Thu, 17 Dec 2015 15:00:16 -0800 (PST) Received: from g2t2360.austin.hp.com (g2t2360.austin.hp.com [16.197.8.247]) by g2t2354.austin.hp.com (Postfix) with ESMTP id B6FA549; Thu, 17 Dec 2015 23:00:15 +0000 (UTC) Received: from misato.fc.hp.com (misato.fc.hp.com [16.78.168.61]) by g2t2360.austin.hp.com (Postfix) with ESMTP id 16CA93F; Thu, 17 Dec 2015 23:00:15 +0000 (UTC) From: Toshi Kani To: dan.j.williams@intel.com Subject: [PATCH] BTT: Change nd_btt_arena_is_valid() to verify UUID Date: Thu, 17 Dec 2015 16:00:00 -0700 Message-Id: <1450393200-6802-1-git-send-email-toshi.kani@hpe.com> X-Mailer: git-send-email 2.4.3 Cc: linux-kernel@vger.kernel.org, micah.parrish@hpe.com, linux-nvdimm@lists.01.org X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When user unbinds a BTT disk and binds again with a different sector size without wiping out the disk, a BTT disk is created with a wrong size. This is because the bind operation keeps the previous metadata, which leads nd_btt->lbasize inconsistent with internal_lbasize and external_lbasize in the arena. A reboot also reattaches the BTT from the previous metadata. Change nd_btt_arena_is_valid() to check if nd_btt->uuid matches with super->uuid when a new UUID is set for binding. This assures the bind operation writes the metadata with the values specified by user. Cc: Vishal Verma Cc: Dan Williams Reported-by: Micah Parrish Signed-off-by: Toshi Kani --- drivers/nvdimm/btt_devs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/nvdimm/btt_devs.c b/drivers/nvdimm/btt_devs.c index cb47751..176ea25 100644 --- a/drivers/nvdimm/btt_devs.c +++ b/drivers/nvdimm/btt_devs.c @@ -218,6 +218,8 @@ static bool uuid_is_null(u8 *uuid) * Check consistency of the btt info block with itself by validating * the checksum, and with the parent namespace by verifying the * parent_uuid contained in the info block with the one supplied in. + * When nd_btt->uuid is set for binding, verify if the metadata is + * stale. * * Returns: * false for an invalid info block, true for a valid one @@ -234,6 +236,10 @@ bool nd_btt_arena_is_valid(struct nd_btt *nd_btt, struct btt_sb *super) if (memcmp(super->parent_uuid, parent_uuid, 16) != 0) return false; + if (nd_btt->uuid) + if (memcmp(super->uuid, nd_btt->uuid, 16) != 0) + return false; + checksum = le64_to_cpu(super->checksum); super->checksum = 0; if (checksum != nd_sb_checksum((struct nd_gen_sb *) super))