From patchwork Fri Apr 3 21:05:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Suchanek X-Patchwork-Id: 11473645 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 BE72515AB for ; Fri, 3 Apr 2020 21:05:41 +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 954CB20737 for ; Fri, 3 Apr 2020 21:05:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 954CB20737 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 02A3410FC51E3; Fri, 3 Apr 2020 14:06:31 -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 E140B100E3FDE for ; Fri, 3 Apr 2020 14:06:27 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 334D6ABCC for ; Fri, 3 Apr 2020 21:05:35 +0000 (UTC) From: Michal Suchanek To: linux-nvdimm@lists.01.org Subject: [PATCH] ndctl/namespace: skip zero namespaces when processing Date: Fri, 3 Apr 2020 23:05:14 +0200 Message-Id: <20200403210514.21786-1-msuchanek@suse.de> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Message-ID-Hash: 4YZCACWK45GXBX34MQ3IVSHHNHPS4O4S X-Message-ID-Hash: 4YZCACWK45GXBX34MQ3IVSHHNHPS4O4S 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 , jack@suse.de 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: Hello, this is a fix for github issue #41. I tested on system with vpmem with ndctl 64.1 that the issue is fixed. master builds with the fix applied. 8<-------------------------------------------------------------------->8 The kernel always creates zero length namespace with uuid 0 in each region. When processing all namespaces the user gets confusing errors from ndctl trying to process this namespace. Skip it. The user can still specify the namespace by name directly in case processing it is desirable. Fixes: #41 Signed-off-by: Michal Suchanek Reviewed-by: Santosh S Tested-by: Harish Sriram --- ndctl/namespace.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/ndctl/namespace.c b/ndctl/namespace.c index 0550580707e8..6f4a4b5b8883 100644 --- a/ndctl/namespace.c +++ b/ndctl/namespace.c @@ -2128,9 +2128,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);