From patchwork Thu Sep 3 23:53:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11755563 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 A204191F for ; Thu, 3 Sep 2020 23:53:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D5002083B for ; Thu, 3 Sep 2020 23:53:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729468AbgICXxy (ORCPT ); Thu, 3 Sep 2020 19:53:54 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38543 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728015AbgICXxx (ORCPT ); Thu, 3 Sep 2020 19:53:53 -0400 Received: by mail-wr1-f67.google.com with SMTP id g4so4946254wrs.5 for ; Thu, 03 Sep 2020 16:53:50 -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=7ub0Y3FnpAu3+m+90OvoGZcXT6a2cMjL2UkvmPpWQ8U=; b=FUANRtvKx8/UTMyegmwp8QRDdgCeKG1+iLtGxypbe5blvy0bU/KNc7w3GT/GfxJIMu vFKv0fr6i3mSK7uYpV8pWPXobwu0flzxvUKGBbnXy5sgsegxmEL1rhE3W3/rcVaAlnKY bEESrYpY/VMH2FBDKF9ltvlxizzoLdy/Gt0Nu2SkSwcb49sRU1DHsLOcXjI+6AYgAZ88 +E3Sn3sSJ8Si2duTv7K4Y6dOXmg+kjPXTeAirJRCpK1q+ig29xTkblJkpjEc50JSWJ2v mrIbieOo3j7fk4Lf7OWNWRL40NarDIMmpjHqP9S3495eGoJ9fqZ6BLx0rV5sPSKFscpS b7BQ== X-Gm-Message-State: AOAM532kXhNvpdmAsSBksex5a0Ne3JFL1KXJ+fkoYb0Py65wcP5NCP1A GrL2uEtk66BjALVizoDksNykF7/cz/4yCw== X-Google-Smtp-Source: ABdhPJz3v6cWWkbCY7RKvaE56lwaecjkokFlYpJMhZtvP91WunMw9K2zOI7RZ18UYUMpNC9Alu2MAA== X-Received: by 2002:a5d:510d:: with SMTP id s13mr4860002wrt.177.1599177228883; Thu, 03 Sep 2020 16:53:48 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:79a5:e112:bd7c:4b29]) by smtp.gmail.com with ESMTPSA id u17sm7024992wmm.4.2020.09.03.16.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 16:53:48 -0700 (PDT) From: Sagi Grimberg To: linux-block@vger.kernel.org, Omar Sandoval Cc: linux-nvme@lists.infradead.org, Logan Gunthorpe , Chaitanya Kulkarni , Keith Busch , Christoph Hellwig Subject: [PATCH v7 1/7] nvme: consolidate nvme requirements based on transport type Date: Thu, 3 Sep 2020 16:53:31 -0700 Message-Id: <20200903235337.527880-2-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903235337.527880-1-sagi@grimberg.me> References: <20200903235337.527880-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 325f2b656613..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 && _have_program nvme + _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 Thu Sep 3 23:53:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11755565 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 2C23191F for ; Thu, 3 Sep 2020 23:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 073EE2083B for ; Thu, 3 Sep 2020 23:53:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729472AbgICXx4 (ORCPT ); Thu, 3 Sep 2020 19:53:56 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:36424 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgICXxz (ORCPT ); Thu, 3 Sep 2020 19:53:55 -0400 Received: by mail-wm1-f68.google.com with SMTP id z9so4483077wmk.1 for ; Thu, 03 Sep 2020 16:53:53 -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=Du+i9HgkXJlhLhZnQGYzI3XIgLUDpLhD/BA4KY8VIPM=; b=R+JNyNxgA02ye6g5k6Q/na9DxfcwK+G06boQz6EvWZmhKXj4ZdTYDY7iMkZLgExtuK NAyklyz0kblc0hLedk5X9K1YqQ382rHM1TgMkhnVb8yKj+wNIKp31DGALuZ+r6mx2jNa Hay21rzuiPL/zWREJiqywG/aNqk5jLwGJglON01xoFGQ8zQFSANmdYvirk937PKMbX5k wEHtLFZIJ7aCvdK+C9hyhcDMCvmKFP+0iH/kNk5EGGg0aDb3omZ0aUuYRia8BUQTcNZb y4246YC36Vb7g891MkU9Y3lDJmKiqarG4naCfECODC+cWpbV8fRKsBab0pN5ES8ZNGIp tJPA== X-Gm-Message-State: AOAM531+w0NkfU45kuucMKhfJ6MtrZ9RAxaYm1F+3wYJS78/ndbW+o2x D6J8I6DH3uLP32bQfUMf02NYBeMuUJhQMA== X-Google-Smtp-Source: ABdhPJxv7sUxT3XR7cNiPRH5eaGxwlw8mwOWzfRzCgByq8jz/hmsYxY0oUPCN+uTtKJQWVR+Densuw== X-Received: by 2002:a1c:ba0b:: with SMTP id k11mr4373676wmf.20.1599177232115; Thu, 03 Sep 2020 16:53:52 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:79a5:e112:bd7c:4b29]) by smtp.gmail.com with ESMTPSA id u17sm7024992wmm.4.2020.09.03.16.53.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 16:53:51 -0700 (PDT) From: Sagi Grimberg To: linux-block@vger.kernel.org, Omar Sandoval Cc: linux-nvme@lists.infradead.org, Logan Gunthorpe , Chaitanya Kulkarni , Keith Busch , Christoph Hellwig Subject: [PATCH v7 2/7] nvme: consolidate some nvme-cli utility functions Date: Thu, 3 Sep 2020 16:53:32 -0700 Message-Id: <20200903235337.527880-3-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903235337.527880-1-sagi@grimberg.me> References: <20200903235337.527880-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 Reviewed-by: Chaitanya Kulkarni --- 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..92779e8d28ca 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..83d1b2ff9cb0 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..1a3eedd634cf 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..f26adebe1b3b 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..91673974ecaa 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..ec586ec08780 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..e8055541746a 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..7e89c8e7b38e 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..72cf93210bb9 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..d70bd02df666 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..2d83c4258f2a 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..118a261f3845 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..a2b22adfc6b9 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..7ec146ec7414 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..2dee7d190006 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..58ee7c916f9d 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..2615ab6b74b0 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..33f66c975553 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..e223107a226b 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..190bac07dae6 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..62c07478e8ce 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..d760430518df 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..40e894f89578 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..23feabf9f871 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..bb67249c2947 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..184a2f177d2d 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..7053553cb837 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..e02cb3c346ee 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" + + ARGS=(-t "${trtype}" -n "${subsysnqn}") + nvme connect "${ARGS[@]}" +} + +_nvme_discover() { + local trtype="$1" + + ARGS=(-t "${trtype}") + nvme discover "${ARGS[@]}" +} + _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 Thu Sep 3 23:53:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11755567 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 40756618 for ; Thu, 3 Sep 2020 23:54:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13B342083B for ; Thu, 3 Sep 2020 23:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729486AbgICXyA (ORCPT ); Thu, 3 Sep 2020 19:54:00 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45823 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728015AbgICXyA (ORCPT ); Thu, 3 Sep 2020 19:54:00 -0400 Received: by mail-wr1-f67.google.com with SMTP id x14so4903149wrl.12 for ; Thu, 03 Sep 2020 16:53:56 -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=bwNyTbPODwR3Q0/eLegXXd8A0YuC7dwJ2GXECJRtIhk=; b=K6NGXFMzyUwHvTSlys6tFJKW1XC3JnElDGwCXUL0VPwsxx/dg3dY2hXtyM0Lf75kIj EiOD9bt0CP/Zw9uNxEFuue1qaqJKfYq0ctMw1If2W8FfAyYrXrTYsfkUcgPvcPAV3Cvd JHvD6Z1Z3y6GMexLQ6uGAWg11PHsUVZHWRI0/EO4gNDcYndXYUq0hSABH/grP9qPvuHM Q3uPwIkCFdxpLoXW9UZ9k7LuMKGYSNmdrIxHUC8nm9vlLssZ3ORqwdEMrdBqn5boURIJ eRZ7hdHZt+zRTuNdA2AluFePv0eztlNVEBy5Sum8RfES2aAxVfAYBTbSW8Wj9KG5j8fK AuYA== X-Gm-Message-State: AOAM532UGqQeqpLQYFv7mqc0/bgE1VG/WMsQWHbwChdffHYMVAV9iXuW wU3Y0fzmQ+dfHP5DB1J6wHocIxb07006fQ== X-Google-Smtp-Source: ABdhPJzsrSqm/7x2qrpel8qz+Ew8IvlLbp10f9tu6l3tO8swj53kswOeLmoUzLjNKs0PZKWuzyu7BQ== X-Received: by 2002:a5d:460c:: with SMTP id t12mr4783911wrq.225.1599177234876; Thu, 03 Sep 2020 16:53:54 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:79a5:e112:bd7c:4b29]) by smtp.gmail.com with ESMTPSA id u17sm7024992wmm.4.2020.09.03.16.53.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 16:53:54 -0700 (PDT) From: Sagi Grimberg To: linux-block@vger.kernel.org, Omar Sandoval Cc: linux-nvme@lists.infradead.org, Logan Gunthorpe , Chaitanya Kulkarni , Keith Busch , Christoph Hellwig Subject: [PATCH v7 3/7] nvme: make tests transport type agnostic Date: Thu, 3 Sep 2020 16:53:33 -0700 Message-Id: <20200903235337.527880-4-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903235337.527880-1-sagi@grimberg.me> References: <20200903235337.527880-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 Reviewed-by: Chaitanya Kulkarni --- 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 92779e8d28ca..955f68da026a 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 83d1b2ff9cb0..654ff776f6f9 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 1a3eedd634cf..0a62e3448e7b 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 f26adebe1b3b..e97287a96a4e 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..8fe95461e6cc 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..e712026ba373 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 91673974ecaa..cb36442bda18 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 ec586ec08780..6abca757b4e6 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 e8055541746a..903da818b5ac 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 7e89c8e7b38e..4060e6278d44 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 72cf93210bb9..dd8bceca5373 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 d70bd02df666..059d608a892f 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 2d83c4258f2a..192322862072 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 118a261f3845..353445ad31b9 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 a2b22adfc6b9..f829dedf7baa 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 7ec146ec7414..e552af17ccb9 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 2dee7d190006..73703a286ff8 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 58ee7c916f9d..8ccfface176e 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 2615ab6b74b0..7861d47513e5 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 33f66c975553..52d14f0490b1 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 e223107a226b..111dec92f791 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 190bac07dae6..31f77ff07055 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 62c07478e8ce..5a30b08b9d8e 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 d760430518df..b7903d6ad8f2 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 40e894f89578..721d486bc7de 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 23feabf9f871..6be7d0492d37 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 bb67249c2947..2d89c8fa35de 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 184a2f177d2d..0bface97ccd5 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..91c042ab6b0b 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 7053553cb837..3faa4c171cc8 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 e02cb3c346ee..621686abf80a 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}" ARGS=(-t "${trtype}" -n "${subsysnqn}") + if [[ "${trtype}" != "loop" ]]; then + ARGS+=(-a "${traddr}" -s "${trsvcid}") + fi nvme connect "${ARGS[@]}" } _nvme_discover() { local trtype="$1" + local traddr="${2:-$def_traddr}" + local trsvcid="${3:-$def_trsvcid}" ARGS=(-t "${trtype}") + if [[ "${trtype}" != "loop" ]]; then + ARGS+=(-a "${traddr}" -s "${trsvcid}") + fi nvme discover "${ARGS[@]}" } _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 Thu Sep 3 23:53:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11755569 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 C3A6591F for ; Thu, 3 Sep 2020 23:54:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACE8D20797 for ; Thu, 3 Sep 2020 23:54:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729455AbgICXyB (ORCPT ); Thu, 3 Sep 2020 19:54:01 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:34474 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgICXyA (ORCPT ); Thu, 3 Sep 2020 19:54:00 -0400 Received: by mail-wm1-f68.google.com with SMTP id c19so6356284wmd.1 for ; Thu, 03 Sep 2020 16:53:58 -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=xQUN6zpWEGOqZyKKHh5hpGo+MltMHq3JbKrE77JajnI=; b=gRm21Ysz4QvkS6A/20FwQNWF3s+xOXBXLKwES+A17QvXuXqOoAFxa1CurLm8tzT/ip AG4CvwrbWU/ib/l2wGikTfbOjVqTsIfseHhmqcmR3OYaT36OekncejOeY06z6WbKimxF Y+ERVNFI13wjTvYxa9njiwbV3A0ChiFAYiVdD6+66XTGO26hAkBnYZziPVP5KqM6Dxi9 GAXsOhrMmudoSVHaFzSozG6qYzOZz/M91kSJaqbRs6qNogjNa0Hm579vQqGL9I3uzAEE ZnRYjRH0xpUhHUSZuGTm+rJDOfdMJxWS9stckTPJY3kdTp/4I2+cJPtt3I5aIkU6c5fH vMIQ== X-Gm-Message-State: AOAM530YeGHLw2tjRELk4cWwcfnP7nGfs2Les4yeEFVmD0Lnj1/k9F0A ZvEejoepD7sAf9aDhWHhkDiaiX05BVInVA== X-Google-Smtp-Source: ABdhPJyll6o53H0wVqhzjHYboqXl/ltfnZFmtoA9XFr15pDSkQqz3LpenZy8P2yePNuYRLFnAcTrIw== X-Received: by 2002:a1c:a911:: with SMTP id s17mr4835616wme.77.1599177237344; Thu, 03 Sep 2020 16:53:57 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:79a5:e112:bd7c:4b29]) by smtp.gmail.com with ESMTPSA id u17sm7024992wmm.4.2020.09.03.16.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 16:53:56 -0700 (PDT) From: Sagi Grimberg To: linux-block@vger.kernel.org, Omar Sandoval Cc: linux-nvme@lists.infradead.org, Logan Gunthorpe , Chaitanya Kulkarni , Keith Busch , Christoph Hellwig Subject: [PATCH v7 4/7] tests/nvme: restrict tests to specific transports Date: Thu, 3 Sep 2020 16:53:34 -0700 Message-Id: <20200903235337.527880-5-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903235337.527880-1-sagi@grimberg.me> References: <20200903235337.527880-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 Reviewed-by: Chaitanya Kulkarni --- 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 955f68da026a..ca11c11c9a09 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 654ff776f6f9..101c1841c6df 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 0a62e3448e7b..dfca79aab20c 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 e97287a96a4e..0d5801868bc0 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 8fe95461e6cc..9230dc6ed902 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 e712026ba373..d53100f3ff7b 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 cb36442bda18..8616617ad398 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 6abca757b4e6..e91d79065cb1 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 903da818b5ac..9d96d7803be3 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 4060e6278d44..06dc568fb6ea 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 dd8bceca5373..8110430e49d4 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 059d608a892f..176b11b9ccb5 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 192322862072..e3c70364e332 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 353445ad31b9..46fa4f605749 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 f829dedf7baa..4eba30223a08 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 e552af17ccb9..f2a95cf276cb 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 73703a286ff8..6d7934d09d99 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 8ccfface176e..486b5acff713 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 7861d47513e5..c8053f440e2e 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 52d14f0490b1..f543a1d8fd92 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 111dec92f791..e824ed31f6f0 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 31f77ff07055..bdef3dc8abca 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 5a30b08b9d8e..78f779e8a08a 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 b7903d6ad8f2..223430965d7e 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 721d486bc7de..7f82284d9c57 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 6be7d0492d37..da96e6c5008d 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 2d89c8fa35de..f826b67623f1 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 0bface97ccd5..5bed9b8e70ae 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 91c042ab6b0b..37df902da895 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 3faa4c171cc8..36263ca2379c 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 621686abf80a..3b8754669af7 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 Thu Sep 3 23:53:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11755571 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 C64C2618 for ; Thu, 3 Sep 2020 23:54:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A58362078E for ; Thu, 3 Sep 2020 23:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729495AbgICXyD (ORCPT ); Thu, 3 Sep 2020 19:54:03 -0400 Received: from mail-wm1-f43.google.com ([209.85.128.43]:53388 "EHLO mail-wm1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728015AbgICXyB (ORCPT ); Thu, 3 Sep 2020 19:54:01 -0400 Received: by mail-wm1-f43.google.com with SMTP id u18so4454394wmc.3 for ; Thu, 03 Sep 2020 16:54:00 -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=Iuto2pxfODOk9zAl9MpiH41FtDUvxGxjWYhRICRrL4Y=; b=kbD8qmINCotwgjaofYwwZKMsrrjb8dn7jry/MEjfsEOS9I4Jy72oQHcclCOVgKdFDw j1dfcRfG+4qyxC6vmCTv/MRo7IZwZ2aS5vZdgFw2ChThz66I9CYzCDeJZ35QiNato9Nu ovNJVq0KfvVRuaZ3Em3EDrJ5YOKJpjb6cGGnfGlCp4FJV5XBCkc395ArM6PZ8xlq6BEG EIDJ+m65gbiWxojr7PYlSTC/zGvyPu1V2pOOdxs796/WGUQFnWJjmj75ahOocqt4cDMr IpoZh00cTeEH9NA9ghtzUqB4ICuZvpKXMneSNbzdi+lhsVoWCAj08SzOV+YV/Vxb/DHR ugdg== X-Gm-Message-State: AOAM533qUnR2QRh4Q6xS+bkvYBdoyEZiFzb9PgtxfjlHopK1zNyOU6Tk u7/+w/hj2gA66C50aP2In5LkAh5Fe8CbCA== X-Google-Smtp-Source: ABdhPJzP5enYrr9v2JKs6+l576WmBa5UTPasfbquiO07LvKGOUgc1eeI3A6E8sP8EvjMl1RHXfQxjw== X-Received: by 2002:a1c:7907:: with SMTP id l7mr4730403wme.89.1599177240135; Thu, 03 Sep 2020 16:54:00 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:79a5:e112:bd7c:4b29]) by smtp.gmail.com with ESMTPSA id u17sm7024992wmm.4.2020.09.03.16.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 16:53:59 -0700 (PDT) From: Sagi Grimberg To: linux-block@vger.kernel.org, Omar Sandoval Cc: linux-nvme@lists.infradead.org, Logan Gunthorpe , Chaitanya Kulkarni , Keith Busch , Christoph Hellwig Subject: [PATCH v7 5/7] nvme: support nvme-tcp when runinng tests Date: Thu, 3 Sep 2020 16:53:35 -0700 Message-Id: <20200903235337.527880-6-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903235337.527880-1-sagi@grimberg.me> References: <20200903235337.527880-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 nvme Signed-off-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni --- tests/nvme/rc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index 3b8754669af7..8df00e7d15d0 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 Thu Sep 3 23:53:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11755573 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 86326618 for ; Thu, 3 Sep 2020 23:54:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DF6320797 for ; Thu, 3 Sep 2020 23:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgICXyF (ORCPT ); Thu, 3 Sep 2020 19:54:05 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:42842 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgICXyE (ORCPT ); Thu, 3 Sep 2020 19:54:04 -0400 Received: by mail-wr1-f66.google.com with SMTP id c18so4919413wrm.9 for ; Thu, 03 Sep 2020 16:54:03 -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=E4766iF8tGytH+Vfs6i3/U2RwWmzQyiBC+bGyaYv3Kg=; b=Kzc9eVbNvCNSB2oh4vDBorE4NEWz9Dh3+rpXE0VdXXoAt+XHNwHMV+m1Lt5LvkTReL y5lAxqmjrUZiAfHpXN2rw0gz2GZZq85KorVIHKD5dk3/Ze0z8SBhMbpD4cRiZl3mSFn7 8ndgzBkWF+F95kRbwFGhzLoOrzt5mOL7GUKQ+VfqhlTJYzGXoy0LFOG7Iwijw5jIbfcq UsUx4RGG2JN041hxo3jSD1be5+Xz88JT/+gml7q5CxS233n5zGrosM/ApXlrJ6uZhbAL x1oa+xO3Nmlt359ZVgl6urYDaqXn7PO2avenjCn5dPKB9XM+/S2uQurKNeSywcNIm8aH ZrsQ== X-Gm-Message-State: AOAM532/dqFWRZbbSU4XZWnYwyXW5WCbdXKMZH/u5u1MCQVjCjZs+3lR kxhA2FAPqsgLez/y+ea+RgDxPAx6tBRPDA== X-Google-Smtp-Source: ABdhPJz9wmNhEgElMHthJYRKXZb/0dVNl4i6PMis1ISMWyfAJycy+sQwiYvzl1r4Q9BtwymoHqNVpQ== X-Received: by 2002:adf:db88:: with SMTP id u8mr4752891wri.184.1599177242817; Thu, 03 Sep 2020 16:54:02 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:79a5:e112:bd7c:4b29]) by smtp.gmail.com with ESMTPSA id u17sm7024992wmm.4.2020.09.03.16.54.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 16:54:02 -0700 (PDT) From: Sagi Grimberg To: linux-block@vger.kernel.org, Omar Sandoval Cc: linux-nvme@lists.infradead.org, Logan Gunthorpe , Chaitanya Kulkarni , Keith Busch , Christoph Hellwig Subject: [PATCH v7 6/7] common: move module_unload to common Date: Thu, 3 Sep 2020 16:53:36 -0700 Message-Id: <20200903235337.527880-7-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903235337.527880-1-sagi@grimberg.me> References: <20200903235337.527880-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 (and test/srp/rc) which is not a natural home for it. Move it to common helpers. Signed-off-by: Sagi Grimberg Reviewed-by: Chaitanya Kulkarni --- common/rc | 13 +++++++++++++ tests/nvmeof-mp/rc | 13 ------------- tests/srp/rc | 13 ------------- 3 files changed, 13 insertions(+), 26 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 b95adf047a2f..d7a7c878fb19 100755 --- a/tests/nvmeof-mp/rc +++ b/tests/nvmeof-mp/rc @@ -149,19 +149,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 && diff --git a/tests/srp/rc b/tests/srp/rc index 72a3bca3b44d..7fc094b8267f 100755 --- a/tests/srp/rc +++ b/tests/srp/rc @@ -321,19 +321,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 -} - # Load the SRP initiator driver with kernel module parameters $1..$n. start_srp_ini() { modprobe scsi_transport_srp || return $? From patchwork Thu Sep 3 23:53:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 11755575 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 5EDDD618 for ; Thu, 3 Sep 2020 23:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 426CE206B7 for ; Thu, 3 Sep 2020 23:54:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729498AbgICXyI (ORCPT ); Thu, 3 Sep 2020 19:54:08 -0400 Received: from mail-wm1-f54.google.com ([209.85.128.54]:53402 "EHLO mail-wm1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725782AbgICXyH (ORCPT ); Thu, 3 Sep 2020 19:54:07 -0400 Received: by mail-wm1-f54.google.com with SMTP id u18so4454523wmc.3 for ; Thu, 03 Sep 2020 16:54:06 -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=ltrSPPPBq2iV3S6trqwPo1lDRT0G76ooyJTQrnxziqc=; b=e65dQfYxVDYKxJE9D5CriK1+ONvQ7mDPn4lDbSw8kqIqr220Zki+wlQnAKZor8kapT /Xefq/4hwp52wRcX1uavC6cUpmF3KpTEl9z1RHpo/rAg88G7MFBTu4gsCG/cCkTBRA6s iMiy/laqtXkIqt5IELpAnVFraxkS43V2uyrNHge0V5oVh7kS1NG3WbqPA2tfok7pN4fs zScCi5veoB+Avzp7LSrCyYwguxuJdRpOcBAcNb5GHorsMmNeP18akw2kowjv7Q6BqxEv uztq/ic0iQL0a0A5gqC9Ix11M+R6RiJVpxmHjVAIf7orO+IvFoRHy4u/naIX/pZwTHiH Nmnw== X-Gm-Message-State: AOAM530P49ZgtYbzfRcyo1aZB1QR5OsXnOuBLHzt1utX3kG+vXRgXIAF Y3O18xmZh5B/yOFpF5+Tk7EIa9ny8vFOqA== X-Google-Smtp-Source: ABdhPJw7v5uApg6WNJrp3X9k/6FVzz/5nWXQhmx8P+LLD2jwXHGIQXfpMI2sU8EKSHH3jyWD2nu7pw== X-Received: by 2002:a1c:5581:: with SMTP id j123mr4881341wmb.11.1599177245452; Thu, 03 Sep 2020 16:54:05 -0700 (PDT) Received: from localhost.localdomain ([2601:647:4802:9070:79a5:e112:bd7c:4b29]) by smtp.gmail.com with ESMTPSA id u17sm7024992wmm.4.2020.09.03.16.54.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 16:54:05 -0700 (PDT) From: Sagi Grimberg To: linux-block@vger.kernel.org, Omar Sandoval Cc: linux-nvme@lists.infradead.org, Logan Gunthorpe , Chaitanya Kulkarni , Keith Busch , Christoph Hellwig Subject: [PATCH v7 7/7] nvme: support rdma transport type Date: Thu, 3 Sep 2020 16:53:37 -0700 Message-Id: <20200903235337.527880-8-sagi@grimberg.me> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200903235337.527880-1-sagi@grimberg.me> References: <20200903235337.527880-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 Reviewed-by: Chaitanya Kulkarni --- tests/nvme/rc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index 8df00e7d15d0..4c5b2e8edf0d 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 || _have_modules 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,16 @@ _setup_nvmet() { modprobe nvmet-"${nvme_trtype}" fi modprobe nvme-"${nvme_trtype}" + if [[ "${nvme_trtype}" == "rdma" ]]; then + start_soft_rdma + for i in $(rdma_network_interfaces) + do + ipv4_addr=$(get_ipv4_addr "$i") + if [ -n "${ipv4_addr}" ]; then + def_traddr=${ipv4_addr} + fi + done + fi } _nvme_disconnect_ctrl() {