From patchwork Fri Aug 28 09:51:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 11742523 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B6F3138A for ; Fri, 28 Aug 2020 09:51:14 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52D23208FE for ; Fri, 28 Aug 2020 09:51:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52D23208FE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 075CF128BF5BA; Fri, 28 Aug 2020 02:51:14 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=195.135.220.15; helo=mx2.suse.de; envelope-from=msuchanek@suse.de; receiver= Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (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 60361128A7AD1 for ; Fri, 28 Aug 2020 02:51:11 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 572EDABED; Fri, 28 Aug 2020 09:51:42 +0000 (UTC) From: Michal Suchanek To: linux-nvdimm@lists.01.org Subject: [PATCH 1/3] ndctl/namespace: Skip seed namespaces when processing all namespaces. Date: Fri, 28 Aug 2020 11:51:03 +0200 Message-Id: X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Message-ID-Hash: SN2ZNONHY23KNB2VBOFZVEYQUJABS4TX X-Message-ID-Hash: SN2ZNONHY23KNB2VBOFZVEYQUJABS4TX X-MailFrom: msuchanek@suse.de X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: Michal Suchanek , Harish Sriram X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: The seed namespaces are exposed by the kernel but most operations are not valid on seed namespaces. When processing all namespaces the user gets confusing errors from ndctl trying to process seed namespaces. The kernel does not provide any way to tell that a namspace is seed namespace but skipping namespaces with zero size and UUID is a good heuristic. The user can still specify the namespace by name directly in case processing it is desirable. Fixes: #41 Link: https://patchwork.kernel.org/patch/11473645/ Reviewed-by: Santosh S Tested-by: Harish Sriram Signed-off-by: Michal Suchanek --- ndctl/namespace.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index e734248c9752..3fabe4799d75 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -2171,9 +2171,19 @@ static int do_xaction_namespace(const char *namespace, ndctl_namespace_foreach_safe(region, ndns, _n) { ndns_name = ndctl_namespace_get_devname(ndns); - if (strcmp(namespace, "all") != 0 - && strcmp(namespace, ndns_name) != 0) - continue; + if (strcmp(namespace, "all") == 0) { + static const uuid_t zero_uuid; + uuid_t uuid; + + ndctl_namespace_get_uuid(ndns, uuid); + if (!ndctl_namespace_get_size(ndns) && + !memcmp(uuid, zero_uuid, sizeof(uuid_t))) + continue; + } else { + if (strcmp(namespace, ndns_name) != 0) + continue; + } + switch (action) { case ACTION_DISABLE: rc = ndctl_namespace_disable_safe(ndns); From patchwork Fri Aug 28 09:51:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 11742525 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 48C9E16B1 for ; Fri, 28 Aug 2020 09:51:15 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 30008208FE for ; Fri, 28 Aug 2020 09:51:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 30008208FE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 1B3A5128BF5BC; Fri, 28 Aug 2020 02:51:15 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=195.135.220.15; helo=mx2.suse.de; envelope-from=msuchanek@suse.de; receiver= Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (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 DF3BF128A7AD1 for ; Fri, 28 Aug 2020 02:51:12 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2B401AC5E; Fri, 28 Aug 2020 09:51:44 +0000 (UTC) From: Michal Suchanek To: linux-nvdimm@lists.01.org Subject: [PATCH 2/3] ndctl/namespace: Suppress -ENXIO when processing all namespaces. Date: Fri, 28 Aug 2020 11:51:04 +0200 Message-Id: <17d792c9efe8de3b196ed6a46e3af03c2c176fa3.1598608222.git.msuchanek@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Message-ID-Hash: GS2OET4NIVF2F45X6LJQRBQZ5PIF3E5R X-Message-ID-Hash: GS2OET4NIVF2F45X6LJQRBQZ5PIF3E5R X-MailFrom: msuchanek@suse.de X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: Michal Suchanek , Harish Sriram X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: When processing all namespaces and no namespaces exist user gets the default -ENXIO. Set default rc to 0 when processing all namespaces. This avoids confusing error message printed in addition to the message saying 0 namespaces were affected. Before: # ndctl check-namespace all namespace0.0: namespace_check: namespace0.0: check aborted, namespace online error checking namespaces: Device or resource busy checked 0 namespaces # ndctl disable-namespace all disabled 1 namespace # ndctl check-namespace all namespace0.0: namespace_check: Unable to recover any BTT info blocks error checking namespaces: No such device or address checked 0 namespaces # ndctl destroy-namespace all destroyed 1 namespace # ndctl check-namespace all error checking namespaces: No such device or address checked 0 namespaces # ndctl destroy-namespace all error destroying namespaces: No such device or address destroyed 0 namespaces After: # ndctl check-namespace all namespace0.0: namespace_check: namespace0.0: check aborted, namespace online error checking namespaces: Device or resource busy checked 0 namespaces # ndctl disable-namespace namespace0.0 disabled 1 namespace # ndctl check-namespace all namespace0.0: namespace_check: Unable to recover any BTT info blocks error checking namespaces: No such device or address checked 0 namespaces # ndctl destroy-namespace all destroyed 1 namespace # ndctl check-namespace all checked 0 namespaces # ndctl destroy-namespace all destroyed 0 namespaces # ndctl destroy-namespace all destroyed 0 namespaces Note: this does change the return value from -ENXIO to 0 in the cases when no namespaces exist and processing all namespaces was requested. Link: https://patchwork.kernel.org/patch/11681431/ Signed-off-by: Michal Suchanek Reviewed-by: Santosh S --- v2: fix the error code references in the commit message --- ndctl/namespace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 3fabe4799d75..835f4076008a 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -2112,6 +2112,9 @@ static int do_xaction_namespace(const char *namespace, if (!namespace && action != ACTION_CREATE) return rc; + if (namespace && (strcmp(namespace, "all") == 0)) + rc = 0; + if (verbose) ndctl_set_log_priority(ctx, LOG_DEBUG); From patchwork Fri Aug 28 09:51:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 11742527 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64C3014E5 for ; Fri, 28 Aug 2020 09:51:16 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 48B78208FE for ; Fri, 28 Aug 2020 09:51:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 48B78208FE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-nvdimm-bounces@lists.01.org Received: from ml01.vlan13.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2F948128BF5C0; Fri, 28 Aug 2020 02:51:16 -0700 (PDT) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=195.135.220.15; helo=mx2.suse.de; envelope-from=msuchanek@suse.de; receiver= Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (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 E7A91128A7AD1 for ; Fri, 28 Aug 2020 02:51:13 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 38F22AC97; Fri, 28 Aug 2020 09:51:45 +0000 (UTC) From: Michal Suchanek To: linux-nvdimm@lists.01.org Subject: [PATCH 3/3] namespace-action: Drop zero namespace checks. Date: Fri, 28 Aug 2020 11:51:05 +0200 Message-Id: <486878ed6f1d74827afb42543f3186fe386059de.1598608222.git.msuchanek@suse.de> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 Message-ID-Hash: 5UVOSAND6V4T5XFCRSUK47F6VMXGGJR7 X-Message-ID-Hash: 5UVOSAND6V4T5XFCRSUK47F6VMXGGJR7 X-MailFrom: msuchanek@suse.de X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation CC: Michal Suchanek , Harish Sriram X-Mailman-Version: 3.1.1 Precedence: list List-Id: "Linux-nvdimm developer list." Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Santosh Sivaraj With seed namespaces catched early on these checks for sizes in enable and destroy namespace code path are not needed. Link: https://patchwork.kernel.org/patch/11739975/ Signed-off-by: Santosh Sivaraj [rebased on top of the previous patches] Signed-off-by: Michal Suchanek --- ndctl/lib/libndctl.c | 5 ----- ndctl/namespace.c | 11 ----------- 2 files changed, 16 deletions(-) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 952192c4c6b5..ecced5a3ae0b 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -4253,16 +4253,11 @@ NDCTL_EXPORT int ndctl_namespace_enable(struct ndctl_namespace *ndns) const char *devname = ndctl_namespace_get_devname(ndns); struct ndctl_ctx *ctx = ndctl_namespace_get_ctx(ndns); struct ndctl_region *region = ndns->region; - unsigned long long size = ndctl_namespace_get_size(ndns); int rc; if (ndctl_namespace_is_enabled(ndns)) return 0; - /* Don't try to enable idle namespace (no capacity allocated) */ - if (size == 0) - return -ENXIO; - rc = ndctl_bind(ctx, ndns->module, devname); /* diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 835f4076008a..65bca9191603 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -1094,7 +1094,6 @@ static int namespace_destroy(struct ndctl_region *region, struct ndctl_namespace *ndns) { const char *devname = ndctl_namespace_get_devname(ndns); - unsigned long long size; bool did_zero = false; int rc; @@ -1139,19 +1138,9 @@ static int namespace_destroy(struct ndctl_region *region, goto out; } - size = ndctl_namespace_get_size(ndns); - rc = ndctl_namespace_delete(ndns); if (rc) debug("%s: failed to reclaim\n", devname); - - /* - * Don't report a destroyed namespace when no capacity was - * allocated. - */ - if (size == 0 && rc == 0) - rc = 1; - out: return rc; }