Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2375629imm; Sun, 9 Sep 2018 23:25:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZZXxn6y9fy9+OVq81zQcnEYObPBklf/w4OkgV5CiQCquq4qF+y0mBuEaea6TYDNB1A++8M X-Received: by 2002:a62:4704:: with SMTP id u4-v6mr22214062pfa.76.1536560734268; Sun, 09 Sep 2018 23:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536560734; cv=none; d=google.com; s=arc-20160816; b=NvTHjB68eJQjrj+FnP7KVaZm7swhl/buQd2c08Kn4Bf/lSoe8e4jDaa1jLPJzGIV0u LLZd2XbxzV77+XE8rWLnB7GZf53YwH8lh3ZSbLhnG0+hNsMZHS1RhfZWFlqgezJyik/O 74A3jlrcFfUjTDf2xwn2tX3ZL3EeRP8117JODhJmMn9KCb4u/zaNecEhy1EkAHS3oZ1c bupRGZaHYQxCtDkb76ztrV8gdzER3kRQecXQBCf7Pb5yAjkPfVi30VhkeU4KP5ACZaF2 x3h+R7PVobsOwd7tmZOKJPC0te5r9LmFxlz2GtQDFGZxiFYre3Kwj7ianfBpFo0f+gWS Xg9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=3MmFh5VYNhBbWAgBarErsEIFlbjZvJPeEdHR7yalks8=; b=a1jyMymOAumqtCktXJj/JnegBUgTN6YN40cidFCqEYlVkgewjryduBBXHjbLpDM4tn zOJC+9fb1FnVw8umcZSwhESTUbYlGZsJ4DETxiq0cMFjivSR8jC7BS5SOOhsS4vOVnwi zbZI4pP3mCaZxYT6OqB2ATVFLuOeDKGWoUxHW1D61spWNMaeQbaUw9k/5oG6+O1YzS7X W6O1E43Yf4TplrU0z7qzjv3wQFSYttUvtYtEWzLZU5oiKlMlL8qpsGzr5bU0PcLBL+mb nXlv0Li7/+7MzB6gv2Iv1SYxjni5vvtiTipx3LLRCtD+X9dKT+/K9W0pyLlI2Kq7IqOb wxpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jXSLJXlo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d70-v6si16462295pfd.114.2018.09.09.23.25.18; Sun, 09 Sep 2018 23:25:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jXSLJXlo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbeIJLQg (ORCPT + 99 others); Mon, 10 Sep 2018 07:16:36 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:41207 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726405AbeIJLQf (ORCPT ); Mon, 10 Sep 2018 07:16:35 -0400 Received: by mail-pl1-f196.google.com with SMTP id b12-v6so9230560plr.8 for ; Sun, 09 Sep 2018 23:24:10 -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=3MmFh5VYNhBbWAgBarErsEIFlbjZvJPeEdHR7yalks8=; b=jXSLJXlot2IR2g7En6xCzJouoS5MAIcvPjxxGHeNhNdxkewv0TeRiuJkK58S6mGHdv CnEfwzqUoPNVTh6snNhv1eUfc7WMDg5fcA1NH+x0binvxbJJ1r+RUGWH1+aoWblULpmM HO6sAjz+7dz1Cd1PKEaFKE0PU+ztrm4eWWF/nOQxa49FVsPEIqXGvr70HVep1A5NcOBx MZrAftjohhWoxPtwHpYzOnLY61y6huNIPdULZf/3WfDJs1s6A2+wzXxBsC2GwrmPU3KM lepmp6NQcphykNAK4Bo/dDmOTkiray0cV8rf879Q73zdoTFSipVcmsZpWTGXXLf786NB lXfA== 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=3MmFh5VYNhBbWAgBarErsEIFlbjZvJPeEdHR7yalks8=; b=QtKNBnGYsxexorRtlHt+zwh8I9bXZJohg3PglWeKrC+Rp2VUmkQABMgxNIwJ7ObsUs SvghZ45nYcSwGtk5pScQId5GtW6rWomQnwBRQVMiB7u1oO4vJnOanMJZWbW9nCb5k/eB kxdpbxXe8yMxZ0HjZWTHdLvREIxGQfGu1E6NSoOb7B9vV+tGRNDzWaJzzQF8nIk4Pjt5 qNXpn/iwhmMVDHfal41rjD4qeAw8eSePiBwq1x92k4/OZkIovhV7qP4wnASywJbKaVIW eqBnzaUCaaAY2MyoVJRiajqCRcENAxuyaVKfVTzHirwUs5rXrbYuipMbZm8DktxpCEsh kBrw== X-Gm-Message-State: APzg51CMrD51jbtXj+7By9/RtPwiaQpDd6Gi8R+hMsUy2t2v0NdKdnBg ewwtRX6ynnm7MPeKp/hhqcBFmtU9 X-Received: by 2002:a17:902:b089:: with SMTP id p9-v6mr20108057plr.254.1536560650554; Sun, 09 Sep 2018 23:24:10 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Sep 2018 23:24:10 -0700 (PDT) From: Ocean He To: dan.j.williams@intel.com, zwisler@kernel.org, vishal.l.verma@intel.com, dave.jiang@intel.com Cc: linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Ocean He Subject: [PATCH 3/3] libnvdimm, region_devs: reset related seeds when fail to create namespace Date: Mon, 10 Sep 2018 02:21:48 -0400 Message-Id: <1536560508-24564-4-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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ocean He During runtime, namespace creation may fail if blocked by commit 15d36fecd0bdc7510b70 ("mm: disallow mappings that conflict for devm_memremap_pages()"). To ensure pfn_seed/dax_seed and namespace_seed are ready for next namespace creation, here to do detach and reset. Signed-off-by: Ocean He --- drivers/nvdimm/region_devs.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index fa37afc..4c46fb6 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -703,7 +703,27 @@ void nd_mapping_free_labels(struct nd_mapping *nd_mapping) kfree(label_ent); } } +/* + * To ensure pfn_seed/dax_seed and namespace_seed are ready for + * next namespace creation, here to do detach and reset. + */ +void nd_region_detach_and_reset(struct device *dev, + struct nd_region *nd_region) +{ + /* Only nd_pmem has been verified, fix me for other dev type. */ + if (!is_nd_pmem(&nd_region->dev)) + return; + if (is_nd_pfn(dev) || is_nd_dax(dev)) { + struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev); + struct nd_namespace_common *ndns = to_ndns(nd_region->ns_seed); + + if (nd_pfn->ndns == ndns && ndns->claim == dev) { + nd_detach_and_reset(dev, &nd_pfn->ndns); + nd_region_reset_ns_seed(nd_region); + } + } +} /* * Upon successful probe/remove, take/release a reference on the * associated interleave set (if present), and plant new btt + namespace @@ -774,6 +794,20 @@ static void nd_region_notify_driver_action(struct nvdimm_bus *nvdimm_bus, nd_region_create_ns_seed(nd_region); nvdimm_bus_unlock(dev); } + if (is_nd_pfn(dev) && !probe) { + nd_region = to_nd_region(dev->parent); + nvdimm_bus_lock(dev); + if (nd_region->pfn_seed == dev) + nd_region_detach_and_reset(dev, nd_region); + nvdimm_bus_unlock(dev); + } + if (is_nd_dax(dev) && !probe) { + nd_region = to_nd_region(dev->parent); + nvdimm_bus_lock(dev); + if (nd_region->dax_seed == dev) + nd_region_detach_and_reset(dev, nd_region); + nvdimm_bus_unlock(dev); + } } void nd_region_probe_success(struct nvdimm_bus *nvdimm_bus, struct device *dev) -- 1.8.3.1