From patchwork Tue Sep 11 08:31:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ocean He X-Patchwork-Id: 10595261 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 309A514BD for ; Tue, 11 Sep 2018 08:31:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2074C2914C for ; Tue, 11 Sep 2018 08:31:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1456529154; Tue, 11 Sep 2018 08:31: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=-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 A163B2914C for ; Tue, 11 Sep 2018 08:31:26 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 4F3B421A07A80; Tue, 11 Sep 2018 01:31:26 -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::441; helo=mail-pf1-x441.google.com; envelope-from=oceanhehy@gmail.com; receiver=linux-nvdimm@lists.01.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (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 69EDF21A07A80 for ; Tue, 11 Sep 2018 01:31:24 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id d4-v6so11871186pfn.0 for ; Tue, 11 Sep 2018 01:31:24 -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=u1zSNgtKB2mL+zFvSSihQq4jQciQisUlChjxB/6Imgk=; b=uFc1ewX8H0xg01okUINkcm0uXfMON095Sr/NFuEM8DT9g0wtz4SBr+L+BANUWVAOtC FIWLU3n5iwucPw6/YePB9Yv/inoWUwVERxpJmdIhO/+bkGKtTww9LKWLJmezULexwC0j jFUSUp7AsULD8qaz7MdxIQfY6fcoBt53gRYux6rI12K/MSQUpW9jKzXkPrcDmuaBoaDp AgvqXQNt9dJlhrQAGriLGlZjzBhPVsfzv+FlU/o3pgNGMxcyskjPTIVC2DHA6zAVBelQ zn19/BWHDacg0OFnSvLst2ios94tbhropX2T/j1F8odmtUA+046qb8vDcx7mrSg6d5+o lsBA== 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=u1zSNgtKB2mL+zFvSSihQq4jQciQisUlChjxB/6Imgk=; b=GzycAckBUMhczLtgZrm8U2Dixi2bM0FpL8EU1xbhdG4vIGEkeYd99ITZdvh+y51inD kWLn1HnH2IF/nQjnq1bCYPjyeZKMxNb3AhpucsMaUlRrWhiEV8rmh50M5R3KsaiVi778 xWDoMI6rCa3nqISPCsb4EvlZDdSqngTLvYF+RK8DQoMx74MBZvQqDuBRV3kIs8WoAnSE 1y8AnYTBT2Vds1LBebAXK3hT0+YCygWYPjnJWwakzhX3smcTIHGzoOBf82vcs7Xf4W+s OWYSENjiO0+AIAxSKrCLlnutBU9cfl/xsW9NZY+un6dyhP8LyCX9NUKbXR7Qx0Y819bw tsHA== X-Gm-Message-State: APzg51A4MCfAJfA/okPS1m33oFyEb7M/rRoFKxhXK1ZzH1GtwBJC+5Yp UcZNs8+E7oUmwnw5gECyhWl+7qY0 X-Google-Smtp-Source: ANB0VdYhh5fsHR7N8/+p1ETMeMcXHjrTLyxGaiCQDh4QK4nAnBKXpy/P58CsPZsZq0bHuJzInAEYGQ== X-Received: by 2002:a62:2646:: with SMTP id m67-v6mr28447726pfm.254.1536654683745; Tue, 11 Sep 2018 01:31:23 -0700 (PDT) Received: from 192.168.190.131 ([45.56.155.212]) by smtp.gmail.com with ESMTPSA id v140-v6sm25758174pgb.45.2018.09.11.01.31.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 01:31:23 -0700 (PDT) From: oceanhehy@gmail.com To: dan.j.williams@intel.com, vishal.l.verma@intel.com, qi.fuli@jp.fujitsu.com, linux-nvdimm@lists.01.org Subject: [ndctl PATCH] ndctl: recover from failed namespace creation Date: Tue, 11 Sep 2018 04:31:09 -0400 Message-Id: <1536654669-23828-1-git-send-email-oceanhehy@gmail.com> X-Mailer: git-send-email 1.8.3.1 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 MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Ocean He When namespace creation failure occurs, the consumed namespace (seed or 0th idle) and pfn/dax seed would block next namespace creation. A recovery is needed to handle this type failure. A symptom example (section size is 128MB) based on kernel 4.19-rc2 and ndctl v62: # ndctl create-namespace -r region1 -s 100m -t pmem -m fsdax { "dev":"namespace1.0", "mode":"fsdax", "map":"dev", "size":"96.00 MiB (100.66 MB)", "uuid":"ef9a0556-a610-40b5-8c71-43991765a2cc", "raw_uuid":"177b22e2-b7e8-482f-a063-2b8de876d979", "sector_size":512, "blockdev":"pmem1", "numa_node":1 } # ndctl create-namespace -r region1 -s 100m -t pmem -m fsdax libndctl: ndctl_pfn_enable: pfn1.1: failed to enable Error: namespace1.1: failed to enable failed to create namespace: No such device or address # ndctl destroy-namespace namespace1.0 -f destroyed 1 namespace # ndctl create-namespace -r region1 -s 128m -t pmem -m fsdax failed to create namespace: Device or resource busy Signed-off-by: Ocean He Reviewed-by: Dan Williams --- Additional information: A kernel patch to fix this has been reviewed by Dan Williams, and he prefers to handle it in ndctl directly. https://www.spinics.net/lists/kernel/msg2901465.html ndctl/namespace.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 510553c..76ee2ed 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -393,6 +393,8 @@ static int setup_namespace(struct ndctl_region *region, try(ndctl_pfn, set_align, pfn, p->align); try(ndctl_pfn, set_namespace, pfn, ndns); rc = ndctl_pfn_enable(pfn); + if (rc) + ndctl_pfn_set_namespace(pfn, NULL); } else if (p->mode == NDCTL_NS_MODE_DAX) { struct ndctl_dax *dax = ndctl_region_get_dax_seed(region); @@ -402,6 +404,8 @@ static int setup_namespace(struct ndctl_region *region, try(ndctl_dax, set_align, dax, p->align); try(ndctl_dax, set_namespace, dax, ndns); rc = ndctl_dax_enable(dax); + if (rc) + ndctl_dax_set_namespace(dax, NULL); } else if (p->mode == NDCTL_NS_MODE_SAFE) { struct ndctl_btt *btt = ndctl_region_get_btt_seed(region); @@ -783,7 +787,13 @@ static int namespace_create(struct ndctl_region *region) return -ENODEV; } - return setup_namespace(region, ndns, &p); + rc = setup_namespace(region, ndns, &p); + if (rc) { + ndctl_namespace_set_enforce_mode(ndns, NDCTL_NS_MODE_RAW); + ndctl_namespace_delete(ndns); + } + + return rc; } static int zero_info_block(struct ndctl_namespace *ndns)