From patchwork Mon Sep 10 06:21:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ocean He X-Patchwork-Id: 10593583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4830A14DB for ; Mon, 10 Sep 2018 06:24:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36AA328C91 for ; Mon, 10 Sep 2018 06:24:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B0CC28E82; Mon, 10 Sep 2018 06:24:10 +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=-2.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id D4ACE28C91 for ; Mon, 10 Sep 2018 06:24:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id AA2B22112292F; Sun, 9 Sep 2018 23:24:09 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::542; helo=mail-pg1-x542.google.com; envelope-from=oceanhehy@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 22D922112121C for ; Sun, 9 Sep 2018 23:24:08 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id s7-v6so9930423pgc.0 for ; Sun, 09 Sep 2018 23:24:08 -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=JF0O4zn/LEpQ/Of9oMm7Pjnzg7UngdrXOP4yvvJEbCU=; b=dVXao5jdrcbYa/pAvRMpR9vVDp8yWciCujeAPE1yKGh8aMh1fWJTTxhxxP18vY74jy /KptFiua34FHKvaO/V8mYUneU8xJQgkdpEESdxpGJH3QOAQ0n4sAAPKRFfHsxvqIIz+6 x8MizVHElTK4CA3j1HQ5uvWkxFWkJoyHHyTc30uaZGn0ptLFkWLu9QJnsBuFhXHxcH+e X55UEUgs+ucx3VB2QlOj02Miz2uycvnG6me8E0zKvgiReOr6v4Lgl6Hxto7/Z09afC3q w6/wC7fMeysjdGCPo/E5OXt29w5C/BwzqwG2x8xtsyOhJFV7qIWM0/4djlaJM3uKryIT 5zoQ== 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=JF0O4zn/LEpQ/Of9oMm7Pjnzg7UngdrXOP4yvvJEbCU=; b=jWd3JSVPS2ojhwMNelopG7P2okhuIrpN6aWqROlSUiXxGTLoFH7V38evBbCSwwAeOD jFj3VNrEG1OppkXOIA8n+k/JW9ancDUlvSXgEvESDyfarwK7bRDfzphgusbxNTipWwLh 14ufmQG+zCJdRy/9Yz13c7hhb6HBWUcn8BBRWwHfiWJs2Oiu8IGeawr/UTohFzPgmEcH kEJ6igqSJ0XKFlbCQTxS76MdNkeEyVuWabM7UDomHBmqUWqeT9MiuRzMhx+jTkuZv0zJ yKTT/R8+65WxcODDgw02RoypJWvApGkO760XP8WNeVaU3UC8BnqLbS07Ro+AtVKpuLbX T/cA== X-Gm-Message-State: APzg51DNCNudar3r4TLTBfeZ3V6XMBu+iHBL6J1wEItSTdFgirDgrzHB SdETZ9T8I5/dfe6akq8dspw= X-Google-Smtp-Source: ANB0VdbASkaicKOnGL6+UsioZtXnGGwHO4TNxNlyJZ1xpvq56/L4LUy8drHngFwzGqkGWyt2AclF0Q== X-Received: by 2002:a62:9349:: with SMTP id b70-v6mr22010117pfe.193.1536560647863; Sun, 09 Sep 2018 23:24:07 -0700 (PDT) Received: from localhost.localdomain ([104.237.86.186]) by smtp.gmail.com with ESMTPSA id e190-v6sm29884955pfc.81.2018.09.09.23.24.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 23:24:07 -0700 (PDT) From: Ocean He To: dan.j.williams@intel.com, zwisler@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com Subject: [PATCH 2/3] libnvdimm, namespace_devs: add function nd_region_reset_ns_seed for namespace seed reset Date: Mon, 10 Sep 2018 02:21:47 -0400 Message-Id: <1536560508-24564-3-git-send-email-oceanhehy@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1536560508-24564-1-git-send-email-oceanhehy@gmail.com> References: <1536560508-24564-1-git-send-email-oceanhehy@gmail.com> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ocean He , linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Ocean He During runtime, if a namespace seed is used for new namespace creation but fail, then it needs to be reset for next namespace creation. Add function nd_region_reset_ns_seed for namespace seed reset and declare it in nd-core.h. Signed-off-by: Ocean He --- drivers/nvdimm/namespace_devs.c | 32 ++++++++++++++++++++++++++++++++ drivers/nvdimm/nd-core.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c index 4a42662..6678bbe 100644 --- a/drivers/nvdimm/namespace_devs.c +++ b/drivers/nvdimm/namespace_devs.c @@ -2129,6 +2129,38 @@ void nd_region_create_ns_seed(struct nd_region *nd_region) nd_device_register(nd_region->ns_seed); } +void nd_region_reset_ns_seed(struct nd_region *nd_region) +{ + struct device *dev = nd_region->ns_seed; + unsigned long long val = 0; + ssize_t rc; + u8 **uuid = NULL; + + rc = __holder_class_store(dev, ""); + dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail to reset claim_class " : "", rc); + + rc = __size_store(dev, val); + if (rc >= 0) + rc = nd_namespace_label_update(nd_region, dev); + dev_dbg(dev, "%s(%zd)\n", rc < 0 ? "fail to reset size " : "", rc); + + if (is_namespace_pmem(dev)) { + struct nd_namespace_pmem *nspm = to_nd_namespace_pmem(dev); + + uuid = &nspm->uuid; + } else if (is_namespace_blk(dev)) { + struct nd_namespace_blk *nsblk = to_nd_namespace_blk(dev); + + uuid = &nsblk->uuid; + } + + if (rc == 0 && val == 0 && uuid) { + /* setting size zero == 'delete namespace' */ + kfree(*uuid); + *uuid = NULL; + } +} + void nd_region_create_dax_seed(struct nd_region *nd_region) { WARN_ON(!is_nvdimm_bus_locked(&nd_region->dev)); diff --git a/drivers/nvdimm/nd-core.h b/drivers/nvdimm/nd-core.h index 7fd74d0..3ec6909 100644 --- a/drivers/nvdimm/nd-core.h +++ b/drivers/nvdimm/nd-core.h @@ -81,6 +81,7 @@ static inline bool is_memory(struct device *dev) void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev); struct nd_region; void nd_region_create_ns_seed(struct nd_region *nd_region); +void nd_region_reset_ns_seed(struct nd_region *nd_region); void nd_region_create_btt_seed(struct nd_region *nd_region); void nd_region_create_pfn_seed(struct nd_region *nd_region); void nd_region_create_dax_seed(struct nd_region *nd_region);