Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4672984rwb; Tue, 8 Aug 2023 11:54:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEs5orAkKa9RL3hXpcrCTn3p7fx/Yx7alu9xiyxflbGZSzUAqupZ1AToWLQ2owbGKfqCK6w X-Received: by 2002:a17:906:8a71:b0:99b:4bab:2841 with SMTP id hy17-20020a1709068a7100b0099b4bab2841mr849327ejc.26.1691520865608; Tue, 08 Aug 2023 11:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691520865; cv=none; d=google.com; s=arc-20160816; b=ESQdGWWqUduriMQJDVNQEmqiA+37jOcbcuadI203ZHMOVE9kTMQRqlZ7dJcqJSemBj 7IURoph4PEpt8bPoRUVnR0So/0Zq6GR9gD0dm05V2LniAFczYwQMWCQSmyKiYbhSam5C PWsZQx1MXOdp5OfoBLYs3bxj/OKWNzP6wN13Q+TXtPl3TyrHfflVzMlCc5S0St2GXbSh MTXDJxEZv5reQPfhe9jfYktzVtjVUMi5Bx6D54SuK/O0K7362DK2S/Y/WdnkkjcEHxTD q1oeGdW4cF95f0ADLgFJAQ0/Le/VZR/lztMIQex8T1I/MSDnTcO3GGw8wrM/HNC2TtpW wh4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=UqHXroF0EJl+GQpEdHdxmBrPdAQdE5qHCwe+sk9yKxY=; fh=m0SXguoZOlId+vXza3k05csFzKE/FEfC5yKwj3DLHLU=; b=r5CubQ06DF17SP19o2KqtTV6qavDw18WzWzWwx8ram4XMvMY5wo468sgh41Q1dYUcH cxtAN5vQ27xFBLad/RW1vlwuZ8yFWKL/28WCtUPQ3uMerKvzpXku+5Ddn9FWCt4MhYP+ eahfO4hRmn0UlgQOo99VKd5qnQHm7p9yiG366tVD48yMNqE/FM94P10jumVsHFVw/Vcg +Yo9kIftMpOHLzc8hqS8ep2LVjVOD3W5+SZHEPJaxMEO82n0BZtpLyLpMpDUAVY3VIO9 mu2+DSX92K1NaO5MYhL9l0KpUD/J7VXGgXtX8yh8vLem8yMplPnBxdKwjsYtRGVaUrNo i4Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="snqUzZ/B"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a170906604d00b0099bd6fbd6b9si5933048ejj.433.2023.08.08.11.54.00; Tue, 08 Aug 2023 11:54:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="snqUzZ/B"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbjHHRv1 (ORCPT + 99 others); Tue, 8 Aug 2023 13:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbjHHRvF (ORCPT ); Tue, 8 Aug 2023 13:51:05 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A047527575 for ; Tue, 8 Aug 2023 09:22:50 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 33CFF2247B; Tue, 8 Aug 2023 09:15:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1691486155; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UqHXroF0EJl+GQpEdHdxmBrPdAQdE5qHCwe+sk9yKxY=; b=snqUzZ/B6zgsf/a2M2yhOjHmsHNeE9mHSaQedd9HVD8zCfvICExE8fF8i2wK6Mxfya9hLZ 2/YPrWwNzvAADwz9fiEJCcm5eGVH4DwVehewaNCgTRA4QOA24R82BZ5h8KzZzAsfuMyASc 7NNIIhFghv9O3Yq9DX7O1mnhEB4tgtw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1691486155; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UqHXroF0EJl+GQpEdHdxmBrPdAQdE5qHCwe+sk9yKxY=; b=A2nzBfaKm1XJcZKFQiPgvBxqO4IyAZZq1GHglpbsmBy2zo0jaP1RAVWN0z6khC9NMN40dY wK+XojC5yp1xewAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 256AB13451; Tue, 8 Aug 2023 09:15:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pT4SCcsH0mRCEwAAMHmgww (envelope-from ); Tue, 08 Aug 2023 09:15:55 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Caleb Sander , Keith Busch , Sagi Grimberg , Daniel Wagner Subject: [PATCH libnvme v3 1/2] fabrics: Read the supported options lazy Date: Tue, 8 Aug 2023 11:15:49 +0200 Message-ID: <20230808091550.25349-2-dwagner@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230808091550.25349-1-dwagner@suse.de> References: <20230808091550.25349-1-dwagner@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sagi Grimberg Read the options in when we need the for the first time. Signed-off-by: Sagi Grimberg Signed-off-by: Daniel Wagner --- src/nvme/fabrics.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index 800293e2a8e7..9725eeb3cda8 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -357,10 +357,18 @@ static int __add_argument(char **argstr, const char *tok, const char *arg) return 0; } +static int __nvmf_supported_options(nvme_root_t r); +#define nvmf_check_option(r, tok) \ +({ \ + if (!(r)->options) \ + __nvmf_supported_options(r); \ + (r)->options->tok; \ +}) + #define add_bool_argument(o, argstr, tok, arg) \ ({ \ int ret; \ - if (r->options->tok) { \ + if (nvmf_check_option(r, tok)) { \ ret = __add_bool_argument(argstr, \ stringify(tok), \ arg); \ @@ -376,7 +384,7 @@ static int __add_argument(char **argstr, const char *tok, const char *arg) #define add_int_argument(o, argstr, tok, arg, allow_zero) \ ({ \ int ret; \ - if (r->options->tok) { \ + if (nvmf_check_option(r, tok)) { \ ret = __add_int_argument(argstr, \ stringify(tok), \ arg, \ @@ -393,7 +401,7 @@ static int __add_argument(char **argstr, const char *tok, const char *arg) #define add_int_or_minus_one_argument(o, argstr, tok, arg) \ ({ \ int ret; \ - if (r->options->tok) { \ + if (nvmf_check_option(r, tok)) { \ ret = __add_int_or_minus_one_argument(argstr, \ stringify(tok), \ arg); \ @@ -409,7 +417,7 @@ static int __add_argument(char **argstr, const char *tok, const char *arg) #define add_argument(r, argstr, tok, arg) \ ({ \ int ret; \ - if (r->options->tok) { \ + if (nvmf_check_option(r, tok)) { \ ret = __add_argument(argstr, \ stringify(tok), \ arg); \ @@ -913,9 +921,6 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, free(traddr); } - ret = __nvmf_supported_options(h->r); - if (ret) - return ret; ret = build_options(h, c, &argstr); if (ret) return ret; -- 2.41.0