From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55D37C433E2 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 2C859208D5 for ; Fri, 28 Aug 2020 09:51:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C859208D5 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: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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); -- 2.28.0 _______________________________________________ Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org To unsubscribe send an email to linux-nvdimm-leave@lists.01.org