From patchwork Tue Aug 11 21:00:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11709693 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 CCF17109B for ; Tue, 11 Aug 2020 21:01:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B12D020756 for ; Tue, 11 Aug 2020 21:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726173AbgHKVBJ (ORCPT ); Tue, 11 Aug 2020 17:01:09 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40790 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgHKVBJ (ORCPT ); Tue, 11 Aug 2020 17:01:09 -0400 Received: by mail-pf1-f194.google.com with SMTP id k18so8270243pfp.7 for ; Tue, 11 Aug 2020 14:01:07 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=RvtTADagnnCiX9G36QO3CyWOxm7jHsOMd2MXrfM8ToI=; b=t4GCNPnE6YgcowB1MgByYuICVrGuTz5X+Xe3y0G9qtG21999BhXYOzJ/cTXZDtyN9b /LEmBFu8EL++8AIW5i/QA/QsGS5tXXOObBTZFZwAa7WXnMebQ97yCwCElfIfNq5njPRb s+H4d1dvZIhujMuB06qANptvUq8uV3XdBI6k1lcv6v5sgnrSH0xtk0tMnwzd+LSePkB1 kUmBKYG7uyWf0QOLHLE1muIRj0REi3v6eaKijVyTxQqjC6O6ADUzIBGOc4pcIx8r0A66 NaWHNVuDEhr56kfQlUkpvMZxsP+uHe+n4cLBYXq4gFh6bx0hv/601ny5TPLk7/OXkrCa D3Cw== X-Gm-Message-State: AOAM531+BpWsQ2XNaL1tC3U8rZ+dxi1DJ+woAO88N/at3GJRVrkEwG+H 2nDwstkCHGgOgrJHesjvlPY= X-Google-Smtp-Source: ABdhPJwLdDIlak0mFSmvgPgsOZGYS1VC1slhZBoxZr5uF5p/XwRjKaPgSvESTNuTfc2jJNW3DmUNKw== X-Received: by 2002:a63:2946:: with SMTP id p67mr2267164pgp.227.1597179667443; Tue, 11 Aug 2020 14:01:07 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:b58b:5460:6ed2:8ff9]) by smtp.gmail.com with ESMTPSA id o17sm59370pgn.73.2020.08.11.14.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:01:06 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Chaitanya Kulkarni , Christoph Hellwig , Keith Busch , Bart Van Assche Subject: [PATCH v3 1/7] nvme: consolidate nvme requirements based on transport type Date: Tue, 11 Aug 2020 14:00:56 -0700 Message-Id: <20200811210102.194287-2-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811210102.194287-1-sagi@grimberg.me> References: <20200811210102.194287-1-sagi@grimberg.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Right now, only pci and loop have tests, hence these are the only ones that are allowed. The user can pass an env variable nvme_trtype and check for the necessary modules. This allows prepares us to support other transport types. Note that test 031 is designed to run only with nvme, hence it overrides the environment variable to nvme_trtype=pci. Signed-off-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni --- tests/nvme/002 | 3 ++- tests/nvme/003 | 3 ++- tests/nvme/004 | 3 ++- tests/nvme/005 | 6 +++--- tests/nvme/006 | 4 ++-- tests/nvme/007 | 2 +- tests/nvme/008 | 4 ++-- tests/nvme/009 | 2 +- tests/nvme/010 | 4 ++-- tests/nvme/011 | 4 ++-- tests/nvme/012 | 5 +++-- tests/nvme/013 | 4 ++-- tests/nvme/014 | 4 ++-- tests/nvme/015 | 3 ++- tests/nvme/016 | 2 +- tests/nvme/017 | 2 +- tests/nvme/018 | 4 ++-- tests/nvme/019 | 4 ++-- tests/nvme/020 | 2 +- tests/nvme/021 | 4 ++-- tests/nvme/022 | 4 ++-- tests/nvme/023 | 4 ++-- tests/nvme/024 | 4 ++-- tests/nvme/025 | 4 ++-- tests/nvme/026 | 4 ++-- tests/nvme/027 | 4 ++-- tests/nvme/028 | 4 ++-- tests/nvme/029 | 4 ++-- tests/nvme/030 | 5 ++--- tests/nvme/031 | 5 ++--- tests/nvme/032 | 4 ++++ tests/nvme/rc | 19 +++++++++++++++++++ 32 files changed, 80 insertions(+), 54 deletions(-) diff --git a/tests/nvme/002 b/tests/nvme/002 index 07b7fdae2d39..aaa5ec4d729a 100755 --- a/tests/nvme/002 +++ b/tests/nvme/002 @@ -10,7 +10,8 @@ DESCRIPTION="create many subsystems and test discovery" requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/003 b/tests/nvme/003 index ed0feca3cac7..fd696d9efe2c 100755 --- a/tests/nvme/003 +++ b/tests/nvme/003 @@ -11,7 +11,8 @@ DESCRIPTION="test if we're sending keep-alives to a discovery controller" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/004 b/tests/nvme/004 index 0debcd9c7049..b841a8d4cd87 100755 --- a/tests/nvme/004 +++ b/tests/nvme/004 @@ -12,7 +12,8 @@ DESCRIPTION="test nvme and nvmet UUID NS descriptors" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/005 b/tests/nvme/005 index 8c79d234bb1d..df0900b372be 100755 --- a/tests/nvme/005 +++ b/tests/nvme/005 @@ -11,9 +11,9 @@ DESCRIPTION="reset local loopback target" QUICK=1 requires() { - _have_modules loop nvme-core nvme-loop nvmet && \ - _have_module_param_value nvme_core multipath Y && \ - _have_configfs + _nvme_requires + _have_modules loop && \ + _have_module_param_value nvme_core multipath Y } test() { diff --git a/tests/nvme/006 b/tests/nvme/006 index 6c8e18560264..3f47613d52d2 100755 --- a/tests/nvme/006 +++ b/tests/nvme/006 @@ -10,8 +10,8 @@ DESCRIPTION="create an NVMeOF target with a block device-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/007 b/tests/nvme/007 index 58f4bf8808a1..0902745a4ab2 100755 --- a/tests/nvme/007 +++ b/tests/nvme/007 @@ -10,7 +10,7 @@ DESCRIPTION="create an NVMeOF target with a file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules nvme-loop nvmet && _have_configfs + _nvme_requires } test() { diff --git a/tests/nvme/008 b/tests/nvme/008 index 71ff4d962b00..f19de17fefac 100755 --- a/tests/nvme/008 +++ b/tests/nvme/008 @@ -10,8 +10,8 @@ DESCRIPTION="create an NVMeOF host with a block device-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/009 b/tests/nvme/009 index 25c7da2ab854..4afbe62864f6 100755 --- a/tests/nvme/009 +++ b/tests/nvme/009 @@ -10,7 +10,7 @@ DESCRIPTION="create an NVMeOF host with a file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules nvme-loop nvmet && _have_configfs + _nvme_requires } test() { diff --git a/tests/nvme/010 b/tests/nvme/010 index 2ed0f4871a30..53b97484615f 100755 --- a/tests/nvme/010 +++ b/tests/nvme/010 @@ -10,8 +10,8 @@ DESCRIPTION="run data verification fio job on NVMeOF block device-backed ns" TIMED=1 requires() { - _have_program nvme && _have_fio && \ - _have_modules loop nvme-loop nvmet && _have_configfs + _nvme_requires + _have_fio _have_modules loop } test() { diff --git a/tests/nvme/011 b/tests/nvme/011 index 974b33745b99..a54583d5c582 100755 --- a/tests/nvme/011 +++ b/tests/nvme/011 @@ -10,8 +10,8 @@ DESCRIPTION="run data verification fio job on NVMeOF file-backed ns" TIMED=1 requires() { - _have_program nvme && _have_fio && _have_configfs && \ - _have_modules nvme-loop nvmet + _nvme_requires + _have_fio } test() { diff --git a/tests/nvme/012 b/tests/nvme/012 index 27981e903c58..0049c3d8ceb6 100755 --- a/tests/nvme/012 +++ b/tests/nvme/012 @@ -10,8 +10,9 @@ DESCRIPTION="run mkfs and data verification fio job on NVMeOF block device-backe TIMED=1 requires() { - _have_program nvme && _have_program mkfs.xfs && _have_program fio && \ - _have_modules loop nvme-loop nvmet && _have_configfs + _nvme_requires + _have_program mkfs.xfs && _have_program fio && \ + _have_modules loop } test() { diff --git a/tests/nvme/013 b/tests/nvme/013 index af5f3730a2fc..622706ec4088 100755 --- a/tests/nvme/013 +++ b/tests/nvme/013 @@ -10,8 +10,8 @@ DESCRIPTION="run mkfs and data verification fio job on NVMeOF file-backed ns" TIMED=1 requires() { - _have_program nvme && _have_program mkfs.xfs && _have_fio && \ - _have_modules nvme-loop nvmet && _have_configfs + _nvme_requires + _have_program mkfs.xfs && _have_fio } test() { diff --git a/tests/nvme/014 b/tests/nvme/014 index c255d5f12205..9517230253ab 100755 --- a/tests/nvme/014 +++ b/tests/nvme/014 @@ -10,8 +10,8 @@ DESCRIPTION="flush a NVMeOF block device-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/015 b/tests/nvme/015 index a8497a2ba400..40b850974b43 100755 --- a/tests/nvme/015 +++ b/tests/nvme/015 @@ -10,7 +10,8 @@ DESCRIPTION="unit test for NVMe flush for file backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/016 b/tests/nvme/016 index f1e383cb441a..e1bad2f81461 100755 --- a/tests/nvme/016 +++ b/tests/nvme/016 @@ -9,7 +9,7 @@ DESCRIPTION="create/delete many NVMeOF block device-backed ns and test discovery" requires() { - _have_program nvme && _have_modules nvme-loop nvmet && _have_configfs + _nvme_requires } test() { diff --git a/tests/nvme/017 b/tests/nvme/017 index 6787b5c754ba..2e6d649f9b65 100755 --- a/tests/nvme/017 +++ b/tests/nvme/017 @@ -9,7 +9,7 @@ DESCRIPTION="create/delete many file-ns and test discovery" requires() { - _have_program nvme && _have_modules nvme-loop nvmet && _have_configfs + _nvme_requires } test() { diff --git a/tests/nvme/018 b/tests/nvme/018 index 67d89a6f0b24..e39613709c90 100755 --- a/tests/nvme/018 +++ b/tests/nvme/018 @@ -11,8 +11,8 @@ DESCRIPTION="unit test NVMe-oF out of range access on a file backend" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/019 b/tests/nvme/019 index a8b0204ec0eb..86a2a2945b35 100755 --- a/tests/nvme/019 +++ b/tests/nvme/019 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe DSM Discard command on NVMeOF block-device ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/020 b/tests/nvme/020 index b480ee1b92d0..ccadec6a5822 100755 --- a/tests/nvme/020 +++ b/tests/nvme/020 @@ -10,7 +10,7 @@ DESCRIPTION="test NVMe DSM Discard command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules nvme-loop nvmet && _have_configfs + _nvme_requires } test() { diff --git a/tests/nvme/021 b/tests/nvme/021 index bbee54d16ff1..bbcb9d56a350 100755 --- a/tests/nvme/021 +++ b/tests/nvme/021 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe list command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/022 b/tests/nvme/022 index 9ba07c1cc50f..452e7b3d196c 100755 --- a/tests/nvme/022 +++ b/tests/nvme/022 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe reset command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/023 b/tests/nvme/023 index ed2a5ad7653f..2714571d16d9 100755 --- a/tests/nvme/023 +++ b/tests/nvme/023 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe smart-log command on NVMeOF block-device ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/024 b/tests/nvme/024 index 538580947c5c..1f87bd19ec69 100755 --- a/tests/nvme/024 +++ b/tests/nvme/024 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe smart-log command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/025 b/tests/nvme/025 index 0039fefa5007..1b9e33351f61 100755 --- a/tests/nvme/025 +++ b/tests/nvme/025 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe effects-log command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/026 b/tests/nvme/026 index 7e89d840529c..21a265a630ba 100755 --- a/tests/nvme/026 +++ b/tests/nvme/026 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe ns-descs command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/027 b/tests/nvme/027 index 4d293beb8b47..d7d33796e122 100755 --- a/tests/nvme/027 +++ b/tests/nvme/027 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe ns-rescan command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/028 b/tests/nvme/028 index 1280107ed5df..1643857437e8 100755 --- a/tests/nvme/028 +++ b/tests/nvme/028 @@ -10,8 +10,8 @@ DESCRIPTION="test NVMe list-subsys command on NVMeOF file-backed ns" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/029 b/tests/nvme/029 index 65eb40031888..9f437285d085 100755 --- a/tests/nvme/029 +++ b/tests/nvme/029 @@ -11,8 +11,8 @@ DESCRIPTION="test userspace IO via nvme-cli read/write interface" QUICK=1 requires() { - _have_program nvme && _have_modules loop nvme-loop nvmet && \ - _have_configfs + _nvme_requires + _have_modules loop } test_user_io() diff --git a/tests/nvme/030 b/tests/nvme/030 index 94020f47411e..7156cad7b657 100755 --- a/tests/nvme/030 +++ b/tests/nvme/030 @@ -10,9 +10,8 @@ DESCRIPTION="ensure the discovery generation counter is updated appropriately" QUICK=1 requires() { - _have_program nvme && - _have_modules loop nvme-loop nvmet && - _have_configfs + _nvme_requires + _have_modules loop } diff --git a/tests/nvme/031 b/tests/nvme/031 index 892f20bad9a7..7e7ee7327e62 100755 --- a/tests/nvme/031 +++ b/tests/nvme/031 @@ -18,9 +18,8 @@ DESCRIPTION="test deletion of NVMeOF controllers immediately after setup" QUICK=1 requires() { - _have_program nvme && - _have_modules loop nvme-loop nvmet && - _have_configfs + _nvme_requires + _have_modules loop } test() { diff --git a/tests/nvme/032 b/tests/nvme/032 index 0d0d53b325e6..017d4a339971 100755 --- a/tests/nvme/032 +++ b/tests/nvme/032 @@ -11,11 +11,15 @@ . tests/nvme/rc +#restrict test to nvme-pci only +nvme_trtype=pci + DESCRIPTION="test nvme pci adapter rescan/reset/remove during I/O" QUICK=1 CAN_BE_ZONED=1 requires() { + _nvme_requires _have_fio } diff --git a/tests/nvme/rc b/tests/nvme/rc index 6ffa971b4308..320aa4b2b475 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -6,6 +6,25 @@ . common/rc +nvme_trtype=${nvme_trtype:-"loop"} + +_nvme_requires() { + _have_program nvme + case ${nvme_trtype} in + loop) + _have_modules nvmet nvme-core nvme-loop + _have_configfs + ;; + pci) + _have_modules nvme nvme-core + ;; + *) + SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}" + return 1 + esac + return 0 +} + group_requires() { _have_root } From patchwork Tue Aug 11 21:00:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11709695 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 BC6B6109B for ; Tue, 11 Aug 2020 21:01:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 945C020756 for ; Tue, 11 Aug 2020 21:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726179AbgHKVBM (ORCPT ); Tue, 11 Aug 2020 17:01:12 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:45659 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgHKVBL (ORCPT ); Tue, 11 Aug 2020 17:01:11 -0400 Received: by mail-pf1-f194.google.com with SMTP id f193so8265188pfa.12 for ; Tue, 11 Aug 2020 14:01:10 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=sK8T3YT5/vJQKNOfi96qwKKGpK4HInUhYgSH8H49ltk=; b=MOITpBayzF73dPZTp6CU6A0XeGoR5ReH1Rc3e/g1Js8aUFGBP1Hxv81qiLvvv73wdL +YnOvl2sT92kxAU2Vklwn+2RTBHhkKxOQH0kA/XtyPAUdRUQiGN1Mo/k69BlWP5gWOKm rK0hG3PC2ENMnJeew9DceoIhuKqGZ0YMp+4dLJwbT7bW22YmO77ybgHfdJFC6e2H3fGr m1fz6MVqfjNzAB5JtHLi6QGErLToSScNRrD+HA/UtfXzwjF+c76nxT8zHxNV4+JHWSrj C2xKJ//QipNmc7fbHJKvxWGCQpwvESCyup5Lvpo5lXVzp4MPVuHpHE4oW5YclkTyinnA GO7w== X-Gm-Message-State: AOAM530FPXDPVQtTlGih6XxCGmRTZz1Haqz4D+eIOoDZ7FzwCDgIgyE2 ef1W5X0yhiVkpbFPeDtc1i0= X-Google-Smtp-Source: ABdhPJya8bavY/tdTtEzc4mqoRKCZ3AjcrPne+Eyuc7gfodRXXigy8DShMW6pgCn9FsLddTSh3Bglw== X-Received: by 2002:a65:6650:: with SMTP id z16mr2379552pgv.161.1597179669644; Tue, 11 Aug 2020 14:01:09 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:b58b:5460:6ed2:8ff9]) by smtp.gmail.com with ESMTPSA id o17sm59370pgn.73.2020.08.11.14.01.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:01:08 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Chaitanya Kulkarni , Christoph Hellwig , Keith Busch , Bart Van Assche Subject: [PATCH v3 2/7] nvme: consolidate some nvme-cli utility functions Date: Tue, 11 Aug 2020 14:00:57 -0700 Message-Id: <20200811210102.194287-3-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811210102.194287-1-sagi@grimberg.me> References: <20200811210102.194287-1-sagi@grimberg.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Signed-off-by: Sagi Grimberg --- tests/nvme/002 | 2 +- tests/nvme/003 | 4 ++-- tests/nvme/004 | 4 ++-- tests/nvme/005 | 4 ++-- tests/nvme/008 | 4 ++-- tests/nvme/009 | 4 ++-- tests/nvme/010 | 4 ++-- tests/nvme/011 | 4 ++-- tests/nvme/012 | 4 ++-- tests/nvme/013 | 4 ++-- tests/nvme/014 | 4 ++-- tests/nvme/015 | 4 ++-- tests/nvme/016 | 2 +- tests/nvme/017 | 2 +- tests/nvme/018 | 4 ++-- tests/nvme/019 | 4 ++-- tests/nvme/020 | 4 ++-- tests/nvme/021 | 4 ++-- tests/nvme/022 | 4 ++-- tests/nvme/023 | 4 ++-- tests/nvme/024 | 4 ++-- tests/nvme/025 | 4 ++-- tests/nvme/026 | 4 ++-- tests/nvme/027 | 4 ++-- tests/nvme/028 | 4 ++-- tests/nvme/029 | 4 ++-- tests/nvme/031 | 4 ++-- tests/nvme/rc | 31 +++++++++++++++++++++++++++++-- 28 files changed, 80 insertions(+), 53 deletions(-) diff --git a/tests/nvme/002 b/tests/nvme/002 index aaa5ec4d729a..999e222705bf 100755 --- a/tests/nvme/002 +++ b/tests/nvme/002 @@ -31,7 +31,7 @@ test() { _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i" done - nvme discover -t loop | _filter_discovery + _nvme_discover "loop" | _filter_discovery for ((i = iterations - 1; i >= 0; i--)); do _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-$i" diff --git a/tests/nvme/003 b/tests/nvme/003 index fd696d9efe2c..6ea6a23b7942 100755 --- a/tests/nvme/003 +++ b/tests/nvme/003 @@ -29,7 +29,7 @@ test() { _create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}" _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1" - nvme connect -t loop -n nqn.2014-08.org.nvmexpress.discovery + _nvme_connect_subsys "loop" "nqn.2014-08.org.nvmexpress.discovery" # This is ugly but checking for the absence of error messages is ... sleep 10 @@ -42,7 +42,7 @@ test() { echo "Fail" fi - nvme disconnect -n nqn.2014-08.org.nvmexpress.discovery + _nvme_disconnect_subsys "nqn.2014-08.org.nvmexpress.discovery" _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1" _remove_nvmet_subsystem "blktests-subsystem-1" _remove_nvmet_port "${port}" diff --git a/tests/nvme/004 b/tests/nvme/004 index b841a8d4cd87..7ea539fda55e 100755 --- a/tests/nvme/004 +++ b/tests/nvme/004 @@ -33,14 +33,14 @@ test() { "91fdba0d-f87b-4c25-b80f-db7be1418b9e" _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1" - nvme connect -t loop -n blktests-subsystem-1 + _nvme_connect_subsys "loop" "blktests-subsystem-1" local nvmedev nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" - nvme disconnect -n "blktests-subsystem-1" + _nvme_disconnect_subsys "blktests-subsystem-1" _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1" _remove_nvmet_subsystem "blktests-subsystem-1" _remove_nvmet_port "${port}" diff --git a/tests/nvme/005 b/tests/nvme/005 index df0900b372be..d4ce6d703c1b 100755 --- a/tests/nvme/005 +++ b/tests/nvme/005 @@ -33,7 +33,7 @@ test() { "91fdba0d-f87b-4c25-b80f-db7be1418b9e" _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1" - nvme connect -t loop -n blktests-subsystem-1 + _nvme_connect_subsys "loop" "blktests-subsystem-1" local nvmedev nvmedev="$(_find_nvme_loop_dev)" @@ -42,7 +42,7 @@ test() { echo 1 > "/sys/class/nvme/${nvmedev}/reset_controller" - nvme disconnect -d "${nvmedev}" + _nvme_disconnect_ctrl "${nvmedev}" _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-1" _remove_nvmet_port "${port}" diff --git a/tests/nvme/008 b/tests/nvme/008 index f19de17fefac..5ab5c49b2039 100755 --- a/tests/nvme/008 +++ b/tests/nvme/008 @@ -34,7 +34,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -42,7 +42,7 @@ test() { udevadm settle - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/009 b/tests/nvme/009 index 4afbe62864f6..f6b999dea541 100755 --- a/tests/nvme/009 +++ b/tests/nvme/009 @@ -30,7 +30,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -38,7 +38,7 @@ test() { udevadm settle - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/010 b/tests/nvme/010 index 53b97484615f..6caa2d0f813d 100755 --- a/tests/nvme/010 +++ b/tests/nvme/010 @@ -34,7 +34,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -42,7 +42,7 @@ test() { _run_fio_verify_io --size=950m --filename="/dev/${nvmedev}n1" - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/011 b/tests/nvme/011 index a54583d5c582..7a5535982a74 100755 --- a/tests/nvme/011 +++ b/tests/nvme/011 @@ -32,7 +32,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -40,7 +40,7 @@ test() { _run_fio_verify_io --size=950m --filename="/dev/${nvmedev}n1" - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/012 b/tests/nvme/012 index 0049c3d8ceb6..5c3477a16af9 100755 --- a/tests/nvme/012 +++ b/tests/nvme/012 @@ -38,7 +38,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -54,7 +54,7 @@ test() { umount "${mount_dir}" > /dev/null 2>&1 - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/013 b/tests/nvme/013 index 622706ec4088..49784a0d46b5 100755 --- a/tests/nvme/013 +++ b/tests/nvme/013 @@ -35,7 +35,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -51,7 +51,7 @@ test() { umount "${mount_dir}" > /dev/null 2>&1 - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/014 b/tests/nvme/014 index 9517230253ab..a33ff439fb3d 100755 --- a/tests/nvme/014 +++ b/tests/nvme/014 @@ -34,7 +34,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -44,7 +44,7 @@ test() { nvme flush "/dev/${nvmedev}" -n 1 - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/015 b/tests/nvme/015 index 40b850974b43..cb9792e13442 100755 --- a/tests/nvme/015 +++ b/tests/nvme/015 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -41,7 +41,7 @@ test() { nvme flush "/dev/${nvmedev}n1" -n 1 - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/016 b/tests/nvme/016 index e1bad2f81461..1ad744abb9b0 100755 --- a/tests/nvme/016 +++ b/tests/nvme/016 @@ -33,7 +33,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "$port" "${subsys_nqn}" - nvme discover -t loop | _filter_discovery + _nvme_discover "loop" | _filter_discovery _remove_nvmet_subsystem_from_port "${port}" "${subsys_nqn}" _remove_nvmet_port "${port}" diff --git a/tests/nvme/017 b/tests/nvme/017 index 2e6d649f9b65..2507bcd606b7 100755 --- a/tests/nvme/017 +++ b/tests/nvme/017 @@ -36,7 +36,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme discover -t loop | _filter_discovery + _nvme_discover "loop" | _filter_discovery _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_port "${port}" diff --git a/tests/nvme/018 b/tests/nvme/018 index e39613709c90..4863274cc525 100755 --- a/tests/nvme/018 +++ b/tests/nvme/018 @@ -32,7 +32,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -46,7 +46,7 @@ test() { nvme read "/dev/${nvmedev}n1" -s "$sectors" -c 0 -z "$bs" &>"$FULL" \ && echo "ERROR: nvme read for out of range LBA was not rejected" - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/019 b/tests/nvme/019 index 86a2a2945b35..19c5b4755387 100755 --- a/tests/nvme/019 +++ b/tests/nvme/019 @@ -36,7 +36,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -44,7 +44,7 @@ test() { nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}" - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/020 b/tests/nvme/020 index ccadec6a5822..0a817004225a 100755 --- a/tests/nvme/020 +++ b/tests/nvme/020 @@ -32,7 +32,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -40,7 +40,7 @@ test() { nvme dsm "/dev/${nvmedev}" -n 1 -d -s "${sblk_range}" -b "${nblk_range}" - nvme disconnect -n "${subsys_name}" + _nvme_disconnect_subsys "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/021 b/tests/nvme/021 index bbcb9d56a350..ac3cbd17cd03 100755 --- a/tests/nvme/021 +++ b/tests/nvme/021 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -41,7 +41,7 @@ test() { echo "ERROR: device not listed" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/022 b/tests/nvme/022 index 452e7b3d196c..4c91f98734fc 100755 --- a/tests/nvme/022 +++ b/tests/nvme/022 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -41,7 +41,7 @@ test() { echo "ERROR: reset failed" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/023 b/tests/nvme/023 index 2714571d16d9..dcbe821f2709 100755 --- a/tests/nvme/023 +++ b/tests/nvme/023 @@ -34,7 +34,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -44,7 +44,7 @@ test() { echo "ERROR: smart-log bdev-ns failed" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/024 b/tests/nvme/024 index 1f87bd19ec69..0f4bddcb3142 100755 --- a/tests/nvme/024 +++ b/tests/nvme/024 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -40,7 +40,7 @@ test() { if ! nvme smart-log "/dev/${nvmedev}" -n 1 >> "$FULL" 2>&1; then echo "ERROR: smart-log file-ns failed" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/025 b/tests/nvme/025 index 1b9e33351f61..90896d327cff 100755 --- a/tests/nvme/025 +++ b/tests/nvme/025 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -41,7 +41,7 @@ test() { echo "ERROR: effects-log failed" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/026 b/tests/nvme/026 index 21a265a630ba..39cfe12a23c7 100755 --- a/tests/nvme/026 +++ b/tests/nvme/026 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -41,7 +41,7 @@ test() { echo "ERROR: ns-desc failed" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/027 b/tests/nvme/027 index d7d33796e122..5915c336a0cd 100755 --- a/tests/nvme/027 +++ b/tests/nvme/027 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -40,7 +40,7 @@ test() { if ! nvme ns-rescan "/dev/${nvmedev}" >> "$FULL" 2>&1; then echo "ERROR: ns-rescan failed" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/028 b/tests/nvme/028 index 1643857437e8..cf44102b3957 100755 --- a/tests/nvme/028 +++ b/tests/nvme/028 @@ -31,7 +31,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -40,7 +40,7 @@ test() { if ! nvme list-subsys 2>> "$FULL" | grep -q loop; then echo "ERROR: list-subsys" fi - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/029 b/tests/nvme/029 index 9f437285d085..192b5c52168c 100755 --- a/tests/nvme/029 +++ b/tests/nvme/029 @@ -67,7 +67,7 @@ test() { port="$(_create_nvmet_port "loop")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - nvme connect -t loop -n "${subsys_name}" + _nvme_connect_subsys "loop" "${subsys_name}" nvmedev="$(_find_nvme_loop_dev)" cat "/sys/block/${nvmedev}n1/uuid" @@ -81,7 +81,7 @@ test() { test_user_io "$dev" 511 1023 > "$FULL" 2>&1 || echo FAIL test_user_io "$dev" 511 1025 > "$FULL" 2>&1 || echo FAIL - nvme disconnect -n "${subsys_name}" >> "$FULL" 2>&1 + _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" _remove_nvmet_subsystem "${subsys_name}" diff --git a/tests/nvme/031 b/tests/nvme/031 index 7e7ee7327e62..ab17633bc8fc 100755 --- a/tests/nvme/031 +++ b/tests/nvme/031 @@ -41,8 +41,8 @@ test() { for ((i = 0; i < iterations; i++)); do _create_nvmet_subsystem "${subsys}$i" "${loop_dev}" _add_nvmet_subsys_to_port "${port}" "${subsys}$i" - nvme connect -t loop -n "${subsys}$i" - nvme disconnect -n "${subsys}$i" >> "${FULL}" 2>&1 + _nvme_connect_subsys "loop" "${subsys}$i" + _nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys}$i" _remove_nvmet_subsystem "${subsys}$i" done diff --git a/tests/nvme/rc b/tests/nvme/rc index 320aa4b2b475..6d57cf591300 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -64,7 +64,7 @@ _cleanup_nvmet() { transport="$(cat "/sys/class/nvme/${dev}/transport")" if [[ "$transport" == "loop" ]]; then echo "WARNING: Test did not clean up loop device: ${dev}" - nvme disconnect -d "${dev}" + _nvme_disconnect_ctrl "${dev}" fi done @@ -97,6 +97,33 @@ _setup_nvmet() { modprobe nvme-loop } +_nvme_disconnect_ctrl() { + local ctrl="$1" + + nvme disconnect -d ${ctrl} +} + +_nvme_disconnect_subsys() { + local subsysnqn="$1" + + nvme disconnect -n ${subsysnqn} +} + +_nvme_connect_subsys() { + local trtype="$1" + local subsysnqn="$2" + + cmd="nvme connect -t ${trtype} -n ${subsysnqn}" + eval $cmd +} + +_nvme_discover() { + local trtype="$1" + + cmd="nvme discover -t ${trtype}" + eval $cmd +} + _create_nvmet_port() { local trtype="$1" @@ -206,6 +233,6 @@ _filter_discovery() { } _discovery_genctr() { - nvme discover -t loop | + _nvme_discover "loop" | sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p' } From patchwork Tue Aug 11 21:00:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11709697 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 241B5109B for ; Tue, 11 Aug 2020 21:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0641020756 for ; Tue, 11 Aug 2020 21:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726258AbgHKVBO (ORCPT ); Tue, 11 Aug 2020 17:01:14 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:40796 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgHKVBO (ORCPT ); Tue, 11 Aug 2020 17:01:14 -0400 Received: by mail-pf1-f193.google.com with SMTP id k18so8270374pfp.7 for ; Tue, 11 Aug 2020 14:01:12 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=2/vgxZaLBEo3X1GxcTNBOgwFD0GG283ZvcPViq0IECE=; b=qoi7MRmYgk3nX/UZANBlG3DkUSJFb++s5cKQ64z6S36K8b3J1QONV/3hFRT8LdLzkq dnzEPiB/kDxs8P4yF0OR6awjrz28NpL4VSsSlQbEPpDBgAC7wqpQS7f1BvdZybTK8avU SqAUXPo13J80Y7lJ/+EoD0OA5gT0nzGurDqR0Xp3CpM1mE8ju9QDmIlY2qSIPwF7yKH/ xolvujop7968uLhwP6Xz6dpWGwDBz1ua+lOC3EQsj6mQ4syJBukKn+rlExfCzrsncQ0a 2V9dveA8SLd0PAlReO9bim2+NFby76OzEYrPcx7/uH92WBukjpmEnDRaQFdW7885QCYr dTqQ== X-Gm-Message-State: AOAM531K9U4ffNXTywD0uswz5is3LERonuUnE0H9wiYKaCee66koh2rb FzuZzr7V9AJAbiN3nC+bBU8= X-Google-Smtp-Source: ABdhPJxIPcqOmgBkAM7WKypDVOoyeCNQL7N7zS0MvWRL6vFswLFjArPKn9ogqAk6zaR6H5LJiIsK1Q== X-Received: by 2002:a63:4a4c:: with SMTP id j12mr2319996pgl.115.1597179671876; Tue, 11 Aug 2020 14:01:11 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:b58b:5460:6ed2:8ff9]) by smtp.gmail.com with ESMTPSA id o17sm59370pgn.73.2020.08.11.14.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:01:10 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Chaitanya Kulkarni , Christoph Hellwig , Keith Busch , Bart Van Assche Subject: [PATCH v3 3/7] nvme: make tests transport type agnostic Date: Tue, 11 Aug 2020 14:00:58 -0700 Message-Id: <20200811210102.194287-4-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811210102.194287-1-sagi@grimberg.me> References: <20200811210102.194287-1-sagi@grimberg.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Pass in nvme_trtype to common routines that can support multiple transport types. Signed-off-by: Sagi Grimberg --- tests/nvme/002 | 4 ++-- tests/nvme/003 | 4 ++-- tests/nvme/004 | 6 +++--- tests/nvme/005 | 6 +++--- tests/nvme/006 | 2 +- tests/nvme/007 | 2 +- tests/nvme/008 | 6 +++--- tests/nvme/009 | 6 +++--- tests/nvme/010 | 6 +++--- tests/nvme/011 | 6 +++--- tests/nvme/012 | 6 +++--- tests/nvme/013 | 6 +++--- tests/nvme/014 | 6 +++--- tests/nvme/015 | 6 +++--- tests/nvme/016 | 2 +- tests/nvme/017 | 2 +- tests/nvme/018 | 6 +++--- tests/nvme/019 | 6 +++--- tests/nvme/020 | 6 +++--- tests/nvme/021 | 6 +++--- tests/nvme/022 | 6 +++--- tests/nvme/023 | 6 +++--- tests/nvme/024 | 6 +++--- tests/nvme/025 | 6 +++--- tests/nvme/026 | 6 +++--- tests/nvme/027 | 6 +++--- tests/nvme/028 | 8 ++++---- tests/nvme/029 | 6 +++--- tests/nvme/030 | 2 +- tests/nvme/031 | 4 ++-- tests/nvme/rc | 39 ++++++++++++++++++++++++++++++++------- 31 files changed, 110 insertions(+), 85 deletions(-) diff --git a/tests/nvme/002 b/tests/nvme/002 index 999e222705bf..8540623497c7 100755 --- a/tests/nvme/002 +++ b/tests/nvme/002 @@ -21,7 +21,7 @@ test() { local iterations=1000 local port - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" local loop_dev loop_dev="$(losetup -f)" @@ -31,7 +31,7 @@ test() { _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-$i" done - _nvme_discover "loop" | _filter_discovery + _nvme_discover "${nvme_trtype}" | _filter_discovery for ((i = iterations - 1; i >= 0; i--)); do _remove_nvmet_subsystem_from_port "${port}" "blktests-subsystem-$i" diff --git a/tests/nvme/003 b/tests/nvme/003 index 6ea6a23b7942..68f823011d7d 100755 --- a/tests/nvme/003 +++ b/tests/nvme/003 @@ -21,7 +21,7 @@ test() { _setup_nvmet local port - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port "${nvme_trtype}")" local loop_dev loop_dev="$(losetup -f)" @@ -29,7 +29,7 @@ test() { _create_nvmet_subsystem "blktests-subsystem-1" "${loop_dev}" _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1" - _nvme_connect_subsys "loop" "nqn.2014-08.org.nvmexpress.discovery" + _nvme_connect_subsys "${nvme_trtype}" "nqn.2014-08.org.nvmexpress.discovery" # This is ugly but checking for the absence of error messages is ... sleep 10 diff --git a/tests/nvme/004 b/tests/nvme/004 index 7ea539fda55e..af434674beaa 100755 --- a/tests/nvme/004 +++ b/tests/nvme/004 @@ -22,7 +22,7 @@ test() { _setup_nvmet local port - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" truncate -s 1G "$TMPDIR/img" @@ -33,10 +33,10 @@ test() { "91fdba0d-f87b-4c25-b80f-db7be1418b9e" _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1" - _nvme_connect_subsys "loop" "blktests-subsystem-1" + _nvme_connect_subsys ${nvme_trtype} "blktests-subsystem-1" local nvmedev - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/005 b/tests/nvme/005 index d4ce6d703c1b..ff0975ce7c28 100755 --- a/tests/nvme/005 +++ b/tests/nvme/005 @@ -22,7 +22,7 @@ test() { _setup_nvmet local port - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" truncate -s 1G "$TMPDIR/img" @@ -33,10 +33,10 @@ test() { "91fdba0d-f87b-4c25-b80f-db7be1418b9e" _add_nvmet_subsys_to_port "${port}" "blktests-subsystem-1" - _nvme_connect_subsys "loop" "blktests-subsystem-1" + _nvme_connect_subsys ${nvme_trtype} "blktests-subsystem-1" local nvmedev - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" udevadm settle diff --git a/tests/nvme/006 b/tests/nvme/006 index 3f47613d52d2..3f161d08bc22 100755 --- a/tests/nvme/006 +++ b/tests/nvme/006 @@ -29,7 +29,7 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" diff --git a/tests/nvme/007 b/tests/nvme/007 index 0902745a4ab2..b0e61186e886 100755 --- a/tests/nvme/007 +++ b/tests/nvme/007 @@ -28,7 +28,7 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" diff --git a/tests/nvme/008 b/tests/nvme/008 index 5ab5c49b2039..7ffac945a58a 100755 --- a/tests/nvme/008 +++ b/tests/nvme/008 @@ -31,12 +31,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/009 b/tests/nvme/009 index f6b999dea541..9ac5cb479983 100755 --- a/tests/nvme/009 +++ b/tests/nvme/009 @@ -27,12 +27,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/010 b/tests/nvme/010 index 6caa2d0f813d..d90ca9d88053 100755 --- a/tests/nvme/010 +++ b/tests/nvme/010 @@ -31,12 +31,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/011 b/tests/nvme/011 index 7a5535982a74..d8badbc00846 100755 --- a/tests/nvme/011 +++ b/tests/nvme/011 @@ -29,12 +29,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/012 b/tests/nvme/012 index 5c3477a16af9..93b6cfaf4c77 100755 --- a/tests/nvme/012 +++ b/tests/nvme/012 @@ -35,12 +35,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/013 b/tests/nvme/013 index 49784a0d46b5..3bae2f5edb3d 100755 --- a/tests/nvme/013 +++ b/tests/nvme/013 @@ -32,12 +32,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/014 b/tests/nvme/014 index a33ff439fb3d..b61e7182af66 100755 --- a/tests/nvme/014 +++ b/tests/nvme/014 @@ -31,12 +31,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/015 b/tests/nvme/015 index cb9792e13442..05195e3bc598 100755 --- a/tests/nvme/015 +++ b/tests/nvme/015 @@ -28,12 +28,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/016 b/tests/nvme/016 index 1ad744abb9b0..a5ad973dc246 100755 --- a/tests/nvme/016 +++ b/tests/nvme/016 @@ -30,7 +30,7 @@ test() { _create_nvmet_ns "${subsys_nqn}" "${i}" "${loop_dev}" done - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "$port" "${subsys_nqn}" _nvme_discover "loop" | _filter_discovery diff --git a/tests/nvme/017 b/tests/nvme/017 index 2507bcd606b7..67d7ffc72e93 100755 --- a/tests/nvme/017 +++ b/tests/nvme/017 @@ -33,7 +33,7 @@ test() { _create_nvmet_ns "${subsys_name}" "${i}" "${file_path}" done - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" _nvme_discover "loop" | _filter_discovery diff --git a/tests/nvme/018 b/tests/nvme/018 index 4863274cc525..43340d3c4d25 100755 --- a/tests/nvme/018 +++ b/tests/nvme/018 @@ -29,12 +29,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/019 b/tests/nvme/019 index 19c5b4755387..98d82ae21b42 100755 --- a/tests/nvme/019 +++ b/tests/nvme/019 @@ -33,12 +33,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/020 b/tests/nvme/020 index 0a817004225a..2d4c0152bc55 100755 --- a/tests/nvme/020 +++ b/tests/nvme/020 @@ -29,12 +29,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/021 b/tests/nvme/021 index ac3cbd17cd03..03b2ab749052 100755 --- a/tests/nvme/021 +++ b/tests/nvme/021 @@ -28,12 +28,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/022 b/tests/nvme/022 index 4c91f98734fc..977b844ee117 100755 --- a/tests/nvme/022 +++ b/tests/nvme/022 @@ -28,12 +28,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/023 b/tests/nvme/023 index dcbe821f2709..6c3b44174884 100755 --- a/tests/nvme/023 +++ b/tests/nvme/023 @@ -31,12 +31,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/024 b/tests/nvme/024 index 0f4bddcb3142..9b5f6a44a916 100755 --- a/tests/nvme/024 +++ b/tests/nvme/024 @@ -28,12 +28,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/025 b/tests/nvme/025 index 90896d327cff..9f0e9f722a02 100755 --- a/tests/nvme/025 +++ b/tests/nvme/025 @@ -28,12 +28,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/026 b/tests/nvme/026 index 39cfe12a23c7..e60e73b2c26a 100755 --- a/tests/nvme/026 +++ b/tests/nvme/026 @@ -28,12 +28,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/027 b/tests/nvme/027 index 5915c336a0cd..805a3c63eba2 100755 --- a/tests/nvme/027 +++ b/tests/nvme/027 @@ -28,12 +28,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/028 b/tests/nvme/028 index cf44102b3957..c9bd3dde7f20 100755 --- a/tests/nvme/028 +++ b/tests/nvme/028 @@ -28,16 +28,16 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${file_path}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" - if ! nvme list-subsys 2>> "$FULL" | grep -q loop; then + if ! nvme list-subsys 2>> "$FULL" | grep -q ${nvme_trtype}; then echo "ERROR: list-subsys" fi _nvme_disconnect_subsys "${subsys_name}" >> "$FULL" 2>&1 diff --git a/tests/nvme/029 b/tests/nvme/029 index 192b5c52168c..7bf904b16edc 100755 --- a/tests/nvme/029 +++ b/tests/nvme/029 @@ -64,12 +64,12 @@ test() { _create_nvmet_subsystem "${subsys_name}" "${loop_dev}" \ "91fdba0d-f87b-4c25-b80f-db7be1418b9e" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" - _nvme_connect_subsys "loop" "${subsys_name}" + _nvme_connect_subsys ${nvme_trtype} "${subsys_name}" - nvmedev="$(_find_nvme_loop_dev)" + nvmedev="$(_find_nvme_dev)" cat "/sys/block/${nvmedev}n1/uuid" cat "/sys/block/${nvmedev}n1/wwid" diff --git a/tests/nvme/030 b/tests/nvme/030 index 7156cad7b657..220b29f42962 100755 --- a/tests/nvme/030 +++ b/tests/nvme/030 @@ -37,7 +37,7 @@ test() { _setup_nvmet - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" _create_nvmet_subsystem "${subsys}1" "$(losetup -f)" _add_nvmet_subsys_to_port "${port}" "${subsys}1" diff --git a/tests/nvme/031 b/tests/nvme/031 index ab17633bc8fc..001f9d2b0b3a 100755 --- a/tests/nvme/031 +++ b/tests/nvme/031 @@ -36,12 +36,12 @@ test() { loop_dev="$(losetup -f --show "$TMPDIR/img")" - port="$(_create_nvmet_port "loop")" + port="$(_create_nvmet_port ${nvme_trtype})" for ((i = 0; i < iterations; i++)); do _create_nvmet_subsystem "${subsys}$i" "${loop_dev}" _add_nvmet_subsys_to_port "${port}" "${subsys}$i" - _nvme_connect_subsys "loop" "${subsys}$i" + _nvme_connect_subsys ${nvme_trtype} "${subsys}$i" _nvme_disconnect_subsys "${subsys}$i" >> "${FULL}" 2>&1 _remove_nvmet_subsystem_from_port "${port}" "${subsys}$i" _remove_nvmet_subsystem "${subsys}$i" diff --git a/tests/nvme/rc b/tests/nvme/rc index 6d57cf591300..191f0497416a 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -6,6 +6,9 @@ . common/rc +def_traddr="127.0.0.1" +def_adrfam="ipv4" +def_trsvcid="4420" nvme_trtype=${nvme_trtype:-"loop"} _nvme_requires() { @@ -62,8 +65,8 @@ _cleanup_nvmet() { for dev in /sys/class/nvme/nvme*; do dev="$(basename "$dev")" transport="$(cat "/sys/class/nvme/${dev}/transport")" - if [[ "$transport" == "loop" ]]; then - echo "WARNING: Test did not clean up loop device: ${dev}" + if [[ "$transport" == "${nvme_trtype}" ]]; then + echo "WARNING: Test did not clean up ${nvme_trtype} device: ${dev}" _nvme_disconnect_ctrl "${dev}" fi done @@ -87,14 +90,20 @@ _cleanup_nvmet() { shopt -u nullglob trap SIGINT - modprobe -r nvme-loop 2>/dev/null + modprobe -r nvme-${nvme_trtype} 2>/dev/null + if [[ "${nvme_trtype}" != "loop" ]]; then + modprobe -r nvmet-${nvme_trtype} 2>/dev/null + fi modprobe -r nvmet 2>/dev/null } _setup_nvmet() { _register_test_cleanup _cleanup_nvmet modprobe nvmet - modprobe nvme-loop + if [[ "${nvme_trtype}" != "loop" ]]; then + modprobe nvmet-${nvme_trtype} + fi + modprobe nvme-${nvme_trtype} } _nvme_disconnect_ctrl() { @@ -112,20 +121,33 @@ _nvme_disconnect_subsys() { _nvme_connect_subsys() { local trtype="$1" local subsysnqn="$2" + local traddr="${3:-$def_traddr}" + local trsvcid="${4:-$def_trsvcid}" cmd="nvme connect -t ${trtype} -n ${subsysnqn}" + if [[ "${trtype}" != "loop" ]]; then + cmd=$cmd" -a ${traddr} -s ${trsvcid}" + fi eval $cmd } _nvme_discover() { local trtype="$1" + local traddr="${2:-$def_traddr}" + local trsvcid="${3:-$def_trsvcid}" cmd="nvme discover -t ${trtype}" + if [[ "${trtype}" != "loop" ]]; then + cmd=$cmd" -a ${traddr} -s ${trsvcid}" + fi eval $cmd } _create_nvmet_port() { local trtype="$1" + local traddr="${2:-$def_traddr}" + local adrfam="${3:-$def_adrfam}" + local trsvcid="${4:-$def_trsvcid}" local port for ((port = 0; ; port++)); do @@ -136,6 +158,9 @@ _create_nvmet_port() { mkdir "${NVMET_CFS}/ports/${port}" echo "${trtype}" > "${NVMET_CFS}/ports/${port}/addr_trtype" + echo "${traddr}" > "${NVMET_CFS}/ports/${port}/addr_traddr" + echo "${adrfam}" > "${NVMET_CFS}/ports/${port}/addr_adrfam" + echo "${trsvcid}" > "${NVMET_CFS}/ports/${port}/addr_trsvcid" echo "${port}" } @@ -207,13 +232,13 @@ _remove_nvmet_subsystem_from_port() { rm "${NVMET_CFS}/ports/${port}/subsystems/${nvmet_subsystem}" } -_find_nvme_loop_dev() { +_find_nvme_dev() { local dev local transport for dev in /sys/class/nvme/nvme*; do dev="$(basename "$dev")" transport="$(cat "/sys/class/nvme/${dev}/transport")" - if [[ "$transport" == "loop" ]]; then + if [[ "$transport" == "${nvme_trtype}" ]]; then echo "$dev" for ((i = 0; i < 10; i++)); do if [[ -e /sys/block/$dev/uuid && @@ -233,6 +258,6 @@ _filter_discovery() { } _discovery_genctr() { - _nvme_discover "loop" | + _nvme_discover "${nvme_trtype}" | sed -n -e 's/^.*Generation counter \([0-9]\+\).*$/\1/p' } From patchwork Tue Aug 11 21:00:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11709699 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 A9A1614F6 for ; Tue, 11 Aug 2020 21:01:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9371320756 for ; Tue, 11 Aug 2020 21:01:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbgHKVBO (ORCPT ); Tue, 11 Aug 2020 17:01:14 -0400 Received: from mail-pj1-f66.google.com ([209.85.216.66]:54322 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgHKVBO (ORCPT ); Tue, 11 Aug 2020 17:01:14 -0400 Received: by mail-pj1-f66.google.com with SMTP id mt12so46766pjb.4 for ; Tue, 11 Aug 2020 14:01:14 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wu2ghV8/u7ubjX0NqevskKUcN8L5GxZ12zYaXNIR/rs=; b=HKGs8h3DJHTJTF5rUyCeFqoEAzZprozlQ81mpM17aOmwyBPrO8+qkhWcu8dG0osZCk KY8Kk1OjQnt0OWl5ABymHz+FHJCb1SpSSc13pjzFYQooTtNPdexK2ITC58RqLTWDs+jF 3OG6oAqmuiqCC6diDU0nrS4z/VkRujV+R9DbknLuaXF5ch1zp6LcwBU7RKfdTjB65Zcp NgV9BRc6CRKo3n5K6E4ZBsXRYao3EcIGzAkuZM9oo3ALy5QC/sszPsyh7yZn6X35H3YV 11ruHzqWT/j1KpFg4kw0AqTLOc0UqLbwngVbl3/a+WcKZMXX3bgKTMAuE4RAHq7wBUDT kykw== X-Gm-Message-State: AOAM5336T4ATZ1WpyPr6G4f032649hgtdfuCsy6RLGdQ/2ooaWcMfU/+ mRbnJ8Un5Iy/Hl05dGhRdDk= X-Google-Smtp-Source: ABdhPJy1A2fkE0DgHkvpCpLysoGsL3aivBYSh6UivpDO1nkvX8tpZ9hIVvUemIK/Y7u8Y4ZfzNT5nA== X-Received: by 2002:a17:90a:e94c:: with SMTP id kp12mr2643131pjb.115.1597179673316; Tue, 11 Aug 2020 14:01:13 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:b58b:5460:6ed2:8ff9]) by smtp.gmail.com with ESMTPSA id o17sm59370pgn.73.2020.08.11.14.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:01:12 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Chaitanya Kulkarni , Christoph Hellwig , Keith Busch , Bart Van Assche Subject: [PATCH v3 4/7] tests/nvme: restrict tests to specific transports Date: Tue, 11 Aug 2020 14:00:59 -0700 Message-Id: <20200811210102.194287-5-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811210102.194287-1-sagi@grimberg.me> References: <20200811210102.194287-1-sagi@grimberg.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Protect against running tests with the wrong transport type. Most tests cannot have nvme_trtype=nvme and discovery tests expect the $trtype to be written and verified in the .out file. Adding a couple of helpers to restrict the transport types in tests. Signed-off-by: Sagi Grimberg --- tests/nvme/002 | 1 + tests/nvme/003 | 1 + tests/nvme/004 | 1 + tests/nvme/005 | 1 + tests/nvme/006 | 1 + tests/nvme/007 | 1 + tests/nvme/008 | 1 + tests/nvme/009 | 1 + tests/nvme/010 | 1 + tests/nvme/011 | 1 + tests/nvme/012 | 1 + tests/nvme/013 | 1 + tests/nvme/014 | 1 + tests/nvme/015 | 1 + tests/nvme/016 | 1 + tests/nvme/017 | 1 + tests/nvme/018 | 1 + tests/nvme/019 | 1 + tests/nvme/020 | 1 + tests/nvme/021 | 1 + tests/nvme/022 | 1 + tests/nvme/023 | 1 + tests/nvme/024 | 1 + tests/nvme/025 | 1 + tests/nvme/026 | 1 + tests/nvme/027 | 1 + tests/nvme/028 | 1 + tests/nvme/029 | 1 + tests/nvme/030 | 1 + tests/nvme/031 | 1 + tests/nvme/rc | 16 ++++++++++++++++ 31 files changed, 46 insertions(+) diff --git a/tests/nvme/002 b/tests/nvme/002 index 8540623497c7..8cfcb75e5142 100755 --- a/tests/nvme/002 +++ b/tests/nvme/002 @@ -12,6 +12,7 @@ DESCRIPTION="create many subsystems and test discovery" requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_loop } test() { diff --git a/tests/nvme/003 b/tests/nvme/003 index 68f823011d7d..5f695c27fe78 100755 --- a/tests/nvme/003 +++ b/tests/nvme/003 @@ -13,6 +13,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/004 b/tests/nvme/004 index af434674beaa..03ccd1e4e6b4 100755 --- a/tests/nvme/004 +++ b/tests/nvme/004 @@ -14,6 +14,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/005 b/tests/nvme/005 index ff0975ce7c28..7081faebb801 100755 --- a/tests/nvme/005 +++ b/tests/nvme/005 @@ -14,6 +14,7 @@ requires() { _nvme_requires _have_modules loop && \ _have_module_param_value nvme_core multipath Y + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/006 b/tests/nvme/006 index 3f161d08bc22..1137ab9c43fa 100755 --- a/tests/nvme/006 +++ b/tests/nvme/006 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/007 b/tests/nvme/007 index b0e61186e886..106775e65d84 100755 --- a/tests/nvme/007 +++ b/tests/nvme/007 @@ -11,6 +11,7 @@ QUICK=1 requires() { _nvme_requires + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/008 b/tests/nvme/008 index 7ffac945a58a..fbba7ff59aec 100755 --- a/tests/nvme/008 +++ b/tests/nvme/008 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/009 b/tests/nvme/009 index 9ac5cb479983..39a216dc7822 100755 --- a/tests/nvme/009 +++ b/tests/nvme/009 @@ -11,6 +11,7 @@ QUICK=1 requires() { _nvme_requires + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/010 b/tests/nvme/010 index d90ca9d88053..02b653bc993b 100755 --- a/tests/nvme/010 +++ b/tests/nvme/010 @@ -12,6 +12,7 @@ TIMED=1 requires() { _nvme_requires _have_fio _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/011 b/tests/nvme/011 index d8badbc00846..349ac080f58c 100755 --- a/tests/nvme/011 +++ b/tests/nvme/011 @@ -12,6 +12,7 @@ TIMED=1 requires() { _nvme_requires _have_fio + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/012 b/tests/nvme/012 index 93b6cfaf4c77..c64ad491266f 100755 --- a/tests/nvme/012 +++ b/tests/nvme/012 @@ -13,6 +13,7 @@ requires() { _nvme_requires _have_program mkfs.xfs && _have_program fio && \ _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/013 b/tests/nvme/013 index 3bae2f5edb3d..b9452d8061ec 100755 --- a/tests/nvme/013 +++ b/tests/nvme/013 @@ -12,6 +12,7 @@ TIMED=1 requires() { _nvme_requires _have_program mkfs.xfs && _have_fio + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/014 b/tests/nvme/014 index b61e7182af66..40cb1615bef0 100755 --- a/tests/nvme/014 +++ b/tests/nvme/014 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/015 b/tests/nvme/015 index 05195e3bc598..b57680e7286e 100755 --- a/tests/nvme/015 +++ b/tests/nvme/015 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/016 b/tests/nvme/016 index a5ad973dc246..8ba0a895fbff 100755 --- a/tests/nvme/016 +++ b/tests/nvme/016 @@ -10,6 +10,7 @@ DESCRIPTION="create/delete many NVMeOF block device-backed ns and test discovery requires() { _nvme_requires + _require_nvme_trtype_is_loop } test() { diff --git a/tests/nvme/017 b/tests/nvme/017 index 67d7ffc72e93..36b14f677449 100755 --- a/tests/nvme/017 +++ b/tests/nvme/017 @@ -10,6 +10,7 @@ DESCRIPTION="create/delete many file-ns and test discovery" requires() { _nvme_requires + _require_nvme_trtype_is_loop } test() { diff --git a/tests/nvme/018 b/tests/nvme/018 index 43340d3c4d25..e4cd79350971 100755 --- a/tests/nvme/018 +++ b/tests/nvme/018 @@ -13,6 +13,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/019 b/tests/nvme/019 index 98d82ae21b42..a697c3ac3d02 100755 --- a/tests/nvme/019 +++ b/tests/nvme/019 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/020 b/tests/nvme/020 index 2d4c0152bc55..6d7d5c99410d 100755 --- a/tests/nvme/020 +++ b/tests/nvme/020 @@ -11,6 +11,7 @@ QUICK=1 requires() { _nvme_requires + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/021 b/tests/nvme/021 index 03b2ab749052..5a60ad4c8744 100755 --- a/tests/nvme/021 +++ b/tests/nvme/021 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/022 b/tests/nvme/022 index 977b844ee117..2cd224fcfa22 100755 --- a/tests/nvme/022 +++ b/tests/nvme/022 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/023 b/tests/nvme/023 index 6c3b44174884..07b48a3c1bb5 100755 --- a/tests/nvme/023 +++ b/tests/nvme/023 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/024 b/tests/nvme/024 index 9b5f6a44a916..14c331cd377a 100755 --- a/tests/nvme/024 +++ b/tests/nvme/024 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/025 b/tests/nvme/025 index 9f0e9f722a02..21b033c9c2a8 100755 --- a/tests/nvme/025 +++ b/tests/nvme/025 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/026 b/tests/nvme/026 index e60e73b2c26a..77f7043c8e4a 100755 --- a/tests/nvme/026 +++ b/tests/nvme/026 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/027 b/tests/nvme/027 index 805a3c63eba2..f950422824bb 100755 --- a/tests/nvme/027 +++ b/tests/nvme/027 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/028 b/tests/nvme/028 index c9bd3dde7f20..10e13b4de922 100755 --- a/tests/nvme/028 +++ b/tests/nvme/028 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/029 b/tests/nvme/029 index 7bf904b16edc..c871fb48fc0f 100755 --- a/tests/nvme/029 +++ b/tests/nvme/029 @@ -13,6 +13,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test_user_io() diff --git a/tests/nvme/030 b/tests/nvme/030 index 220b29f42962..314f39e93de2 100755 --- a/tests/nvme/030 +++ b/tests/nvme/030 @@ -12,6 +12,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } diff --git a/tests/nvme/031 b/tests/nvme/031 index 001f9d2b0b3a..1df4dfd6cb9a 100755 --- a/tests/nvme/031 +++ b/tests/nvme/031 @@ -20,6 +20,7 @@ QUICK=1 requires() { _nvme_requires _have_modules loop + _require_nvme_trtype_is_fabrics } test() { diff --git a/tests/nvme/rc b/tests/nvme/rc index 191f0497416a..306a12440c20 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -46,6 +46,22 @@ _require_test_dev_is_nvme() { return 0 } +_require_nvme_trtype_is_loop() { + if [[ "${nvme_trtype}" != "loop" ]]; then + SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test" + return 1 + fi + return 0 +} + +_require_nvme_trtype_is_fabrics() { + if [[ "${nvme_trtype}" == "pci" ]]; then + SKIP_REASON="nvme_trtype=${nvme_trtype} is not supported in this test" + return 1 + fi + return 0 +} + _cleanup_nvmet() { local dev local port From patchwork Tue Aug 11 21:01:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11709701 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 035CC13B1 for ; Tue, 11 Aug 2020 21:01:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DE8BB20756 for ; Tue, 11 Aug 2020 21:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726274AbgHKVBQ (ORCPT ); Tue, 11 Aug 2020 17:01:16 -0400 Received: from mail-pf1-f175.google.com ([209.85.210.175]:36149 "EHLO mail-pf1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726255AbgHKVBP (ORCPT ); Tue, 11 Aug 2020 17:01:15 -0400 Received: by mail-pf1-f175.google.com with SMTP id m8so8278987pfh.3 for ; Tue, 11 Aug 2020 14:01:15 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=+tQe9TzFSzp924C10rfbzh+cSEn+WNgbe/z0aeO76DU=; b=YIZVrSO2dH9a2fZy7Z6t5b2qKila8m9PwXxJNq6xZmoDAmHuFKm43hy58lVvRvFJti a9rK0gHzTspdQRCfpw0/mjpUSgPwSWBFzyd9NqD6R5UCtVpSwFr9zLK8S/+5U4BR0aXg 6NZ6WXCgRUBXNQAm6KJGRjvs82J5ylXtRFeovPbtLi8vJUVV4JXgIC7Z1F2zdGlACizL jqEdxQe5ewbCO8Z78BeVfCCtRQ8fYdSPcUPVXqsdlyNCtTQKBMs6yilUZinYEEaPCWZD HJVZRTYugQIRh3jblo3WsS0K9qnFoZ8wl8M5AF4Aveq9SNl6ErvSRvdPZzLrSYkQMNJR 0hvw== X-Gm-Message-State: AOAM530ZeOwtM6CskfI3ZMl/reGILFbe/ByfMX036SsAya9vHPMKtKJh 6wu5GuVOHGWvxsU2siKydpM= X-Google-Smtp-Source: ABdhPJz0IVfqtwXq/pYkI3RFdFDyCJD5oNq5jI4lmtPWYBfIHC9/BQ3wpGyFzuwGenv6U5BYQvrB0A== X-Received: by 2002:a63:ec04:: with SMTP id j4mr2261308pgh.393.1597179675107; Tue, 11 Aug 2020 14:01:15 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:b58b:5460:6ed2:8ff9]) by smtp.gmail.com with ESMTPSA id o17sm59370pgn.73.2020.08.11.14.01.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:01:14 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Chaitanya Kulkarni , Christoph Hellwig , Keith Busch , Bart Van Assche Subject: [PATCH v3 5/7] nvme: support nvme-tcp when runinng tests Date: Tue, 11 Aug 2020 14:01:00 -0700 Message-Id: <20200811210102.194287-6-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811210102.194287-1-sagi@grimberg.me> References: <20200811210102.194287-1-sagi@grimberg.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org run with: nvme_trtype=tcp ./check test/nvme Signed-off-by: Sagi Grimberg --- tests/nvme/rc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index 306a12440c20..3e97801bbb30 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -21,6 +21,10 @@ _nvme_requires() { pci) _have_modules nvme nvme-core ;; + tcp) + _have_modules nvmet nvme-core nvme-tcp nvmet-tcp + _have_configfs + ;; *) SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}" return 1 From patchwork Tue Aug 11 21:01:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11709703 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 79DE2109B for ; Tue, 11 Aug 2020 21:01:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6806A20771 for ; Tue, 11 Aug 2020 21:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726255AbgHKVBS (ORCPT ); Tue, 11 Aug 2020 17:01:18 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:46994 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbgHKVBS (ORCPT ); Tue, 11 Aug 2020 17:01:18 -0400 Received: by mail-pg1-f196.google.com with SMTP id p8so7273026pgn.13 for ; Tue, 11 Aug 2020 14:01:17 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=AHRa+YkmLQcTpMTxlPvWnCrn2hDL5XCMaLx+f7rGfws=; b=CT+vfXgBXHX2Q7QQUJXcsKyt849ljOBKkam8UIxS5kUtiCfD6dnfBTqBzkZu+yeyQy T4S9sn56oXAM5UFxjI/upNQ05HYbPlYtMu6/G12gr9V0Ja4FBtEYKad3i2tcVeqxqQvp Ivr3miKuPIeGnUzdICt787O5Lha/sUB8NujydoW5yNrtXl6EiXIcXk/d62SnvYG9Z52Y sRgcuGlcJIG91ooQg5en4FpSp6hq/1/BqBWsypw/jLB9krKRI25/1BJYt9oPU2EnTJO3 LvpY3Isvq0s3RCtdKnkXHBrShm1KMwm3i+DQ3RpyFaaYeVS66sZwBNBr2YOi6YkSYoCD l28A== X-Gm-Message-State: AOAM530IZq0ebr9xpLY13BD9u45K97Y8VaB190NXNWpA3Vz6eNV9f7zS OnNROqmV2jLcME3DtXDRFJo= X-Google-Smtp-Source: ABdhPJxwUjksoyjNiZXFmx16nWf/elaBbdLSb3p2YNFGJYWBKigmQzttycUYNOleemLlb8mxtDN8Pg== X-Received: by 2002:a65:534c:: with SMTP id w12mr2233622pgr.156.1597179677399; Tue, 11 Aug 2020 14:01:17 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:b58b:5460:6ed2:8ff9]) by smtp.gmail.com with ESMTPSA id o17sm59370pgn.73.2020.08.11.14.01.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:01:16 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Chaitanya Kulkarni , Christoph Hellwig , Keith Busch , Bart Van Assche Subject: [PATCH v3 6/7] common: move module_unload to common Date: Tue, 11 Aug 2020 14:01:01 -0700 Message-Id: <20200811210102.194287-7-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811210102.194287-1-sagi@grimberg.me> References: <20200811210102.194287-1-sagi@grimberg.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org It creates a dependency between multipath-over-rdma and test/nvmeof/rc which is not a natural home for it. Move it to common helpers. Signed-off-by: Sagi Grimberg --- common/rc | 13 +++++++++++++ tests/nvmeof-mp/rc | 13 ------------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/common/rc b/common/rc index 7f02103dc786..cdc0150ea5ea 100644 --- a/common/rc +++ b/common/rc @@ -291,3 +291,16 @@ _filter_xfs_io_error() { _uptime_s() { awk '{ print int($1) }' /proc/uptime } + +# Arguments: module to unload ($1) and retry count ($2). +unload_module() { + local i m=$1 rc=${2:-1} + + [ ! -e "/sys/module/$m" ] && return 0 + for ((i=rc;i>0;i--)); do + modprobe -r "$m" + [ ! -e "/sys/module/$m" ] && return 0 + sleep .1 + done + return 1 +} diff --git a/tests/nvmeof-mp/rc b/tests/nvmeof-mp/rc index e446db297ba1..829b26624b7f 100755 --- a/tests/nvmeof-mp/rc +++ b/tests/nvmeof-mp/rc @@ -145,19 +145,6 @@ remove_mpath_devs() { } &>> "$FULL" } -# Arguments: module to unload ($1) and retry count ($2). -unload_module() { - local i m=$1 rc=${2:-1} - - [ ! -e "/sys/module/$m" ] && return 0 - for ((i=rc;i>0;i--)); do - modprobe -r "$m" - [ ! -e "/sys/module/$m" ] && return 0 - sleep .1 - done - return 1 -} - start_nvme_client() { modprobe nvme-core dyndbg=+pmf && modprobe nvme dyndbg=+pmf && From patchwork Tue Aug 11 21:01:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11709705 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 7D1CE109B for ; Tue, 11 Aug 2020 21:01:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66FFC20756 for ; Tue, 11 Aug 2020 21:01:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726355AbgHKVBU (ORCPT ); Tue, 11 Aug 2020 17:01:20 -0400 Received: from mail-pj1-f48.google.com ([209.85.216.48]:34366 "EHLO mail-pj1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726329AbgHKVBU (ORCPT ); Tue, 11 Aug 2020 17:01:20 -0400 Received: by mail-pj1-f48.google.com with SMTP id c10so1988847pjn.1 for ; Tue, 11 Aug 2020 14:01:20 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=YzAZ2SXXLc7iNppHmhrxi1E4xPI3+ZrsxT2yh+SoN/c=; b=VJVkjHdoufmvxwKaVf5ikHp+I9QPqjKsFiQ+GnJtvGISgkXCt1nGpGZY2YOgVTovqm +rTd3x5RKP8y7nPJqTO3G7GSwAKv5y3DkvpA/VuYsLH7fu/q9k1eFFOuqMwbPRFVytRH TizeGGN0xMKoViNOYYQFRn1q1gu7ahE8FXvaMUzLKr3ThGfO/pARgYj7Rxh5kpfw63Z8 aIa8zMZc1sCchMxYEeh/jEDrevoR9cScLQYrTSArFmtuP3xOY3Q5WAobirzVWs54SyqY M6NEPvs4dzpXJ2DpOWHMyHTMWcRR2tlyYyCxeKfnAopdumHgkhCByhoA/mn6LevEM3hJ TAlQ== X-Gm-Message-State: AOAM530q/OIX6iIn/xIDKuJ7owzXxNvM+4GCykwIvCNXGgEGYV+nl24m aIZgvliVuulJCpaKVoHUm8Q= X-Google-Smtp-Source: ABdhPJxY9sueg5kzkDkt4NCP10V5sw8acM0u87BVwAs9ESkt4Ym5QoHUmynh+dofgCRrexyUD1okyA== X-Received: by 2002:a17:90a:b986:: with SMTP id q6mr3009212pjr.54.1597179679649; Tue, 11 Aug 2020 14:01:19 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:b58b:5460:6ed2:8ff9]) by smtp.gmail.com with ESMTPSA id o17sm59370pgn.73.2020.08.11.14.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2020 14:01:18 -0700 (PDT) From: Sagi Grimberg To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Chaitanya Kulkarni , Christoph Hellwig , Keith Busch , Bart Van Assche Subject: [PATCH v3 7/7] nvme: support rdma transport type Date: Tue, 11 Aug 2020 14:01:02 -0700 Message-Id: <20200811210102.194287-8-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200811210102.194287-1-sagi@grimberg.me> References: <20200811210102.194287-1-sagi@grimberg.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Signed-off-by: Sagi Grimberg --- tests/nvme/rc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index 3e97801bbb30..675acbfa7012 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -5,6 +5,7 @@ # Test specific to NVMe devices . common/rc +. common/multipath-over-rdma def_traddr="127.0.0.1" def_adrfam="ipv4" @@ -25,6 +26,12 @@ _nvme_requires() { _have_modules nvmet nvme-core nvme-tcp nvmet-tcp _have_configfs ;; + rdma) + _have_modules nvmet nvme-core nvme-rdma nvmet-rdma + _have_configfs + _have_program rdma + _have_modules rdma_rxe siw + ;; *) SKIP_REASON="unsupported nvme_trtype=${nvme_trtype}" return 1 @@ -115,6 +122,9 @@ _cleanup_nvmet() { modprobe -r nvmet-${nvme_trtype} 2>/dev/null fi modprobe -r nvmet 2>/dev/null + if [[ "${nvme_trtype}" == "rdma" ]]; then + stop_soft_rdma + fi } _setup_nvmet() { @@ -124,6 +134,11 @@ _setup_nvmet() { modprobe nvmet-${nvme_trtype} fi modprobe nvme-${nvme_trtype} + if [[ "${nvme_trtype}" == "rdma" ]]; then + start_soft_rdma + rdma_intfs=$(rdma_network_interfaces) + def_traddr=$(get_ipv4_addr ${rdma_intfs[0]}) + fi } _nvme_disconnect_ctrl() {