Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp1433517pxu; Thu, 8 Oct 2020 11:20:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxov/MyHQM4GBa2ps0YwIGOB4s4W681eUrO/P7fV7WkkEvWyW/9MDuB8roOSvdNMdhhzUvr X-Received: by 2002:a17:906:e10e:: with SMTP id gj14mr10548606ejb.134.1602181216766; Thu, 08 Oct 2020 11:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602181216; cv=none; d=google.com; s=arc-20160816; b=CM4c4RIUxkmywO2+bjIpczK1A/9fZHpypXoZjx1eZ3iN3RLF73f5Gxa8SkC87er2SI eIlLXE2RrBls6/XzGLG599FKPtxzv2aDQ2aaUnQnaGIwejh9he45EpZ13xbTsv9tevHm 1qSwlX9TQe8IqJ8hzZNHHFL6G0IsbbukwX5dNbra3qgIRgqbaTtAGuJLzYsLt0ucDbZi X4uoB/WoqMOCWwexO0vO4HdLS8P/O/ZAis3XcqzGnvzlJUjLHGnxGbfcwvDRFEI1C+mr DUuQMFS+9pgjXZXAkqF8QKiM6F9bQPZZr3Jz+XP2LTO0jGwSJ38E72kgUZYXfffrnIVd t96w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:cc:to:from:dkim-signature; bh=Q/NKCn8cpUBMyzr61SmefQR3jE4zs7Vhct3Ys5N6EOQ=; b=swuLHuD7LuMhhAtSbE54XXpKcTC5mPADvbOyeZBNMDxw6BIEzq9lfi+1S5MMHgGICE D9evFEavlaSbfivYNoB8f+7INFwgfUiHKlrGSFsjWHDa7Tsaoi/zlmboTFFDW2R99HgF RzZkj4OQW3i7izy8gZ9XPJKWJ3WfhuyA2bJmpSv5G8BRw8CU88sKShv7fh7qwrvUFi2L pC+TLtdoezwJW1SN66paRMRRYAeprFoFBzycIXkm5Hl6dWhuhO+gB8VDgD58yXG6ZeSs o+9cNxpVa3HHqz2DxdXv2E05eqa2m6Nd/Ay/R7gAOi08TQmUaJ8qBplOkjbCTCmfLKib 21GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@deltatee.com header.s=20200525 header.b=LT9egte0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ba11si4368141edb.378.2020.10.08.11.19.51; Thu, 08 Oct 2020 11:20:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@deltatee.com header.s=20200525 header.b=LT9egte0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731298AbgJHQkv (ORCPT + 99 others); Thu, 8 Oct 2020 12:40:51 -0400 Received: from ale.deltatee.com ([204.191.154.188]:48872 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731063AbgJHQkj (ORCPT ); Thu, 8 Oct 2020 12:40:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Q/NKCn8cpUBMyzr61SmefQR3jE4zs7Vhct3Ys5N6EOQ=; b=LT9egte0+0Y8oXUezjbF+UuN5b 9JhGOnRRHBbusFBbHU8arfLRVYsK29K+ZHnCCMTbvQsdRzRreU1bsE5buBXp0ujSLwr397/6FK0cQ SZVIXRgS8Md8J157a7kaznTlwKjxM6gmA3A01bOYee1Kv7ONAXVAIJrwp6kGeEPcoTkEDMPjtrlwP iL6onpVgKs+ppIhT9UOSwEL9WLUqr5eJNPu81c1sjcJVUmarJChQNQU6zzBf3EAQzUfN61LiFWgQY MpGJ3fPKctQg932XkOyDFimDNPYQUKDmtGJcw/lgXP5HQlW9ulTsWbS+pU1803sw3HCEvz+qT0XtA eRCucJsA==; Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kQYy5-0000if-G0; Thu, 08 Oct 2020 10:40:38 -0600 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.92) (envelope-from ) id 1kQYxz-0003HU-AP; Thu, 08 Oct 2020 10:40:31 -0600 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Omar Sandoval Cc: Sagi Grimberg , Chaitanya Kulkarni , Stephen Bates , Logan Gunthorpe Date: Thu, 8 Oct 2020 10:40:18 -0600 Message-Id: <20201008164024.12546-6-logang@deltatee.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201008164024.12546-1-logang@deltatee.com> References: <20201008164024.12546-1-logang@deltatee.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, osandov@osandov.com, sagi@grimberg.me, Chaitanya.Kulkarni@wdc.com, sbates@raithlin.com, logang@deltatee.com X-SA-Exim-Mail-From: gunthorp@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, MYRULES_NO_TEXT autolearn=no autolearn_force=no version=3.4.2 Subject: [PATCH blktests v3 05/11] nvme: Add common helpers for passthru tests X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add some simple helpers to setup a passthru target that passes through to a nvme test device. Signed-off-by: Logan Gunthorpe --- tests/nvme/rc | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index dfa57a299625..f0b6f360da8c 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -73,6 +73,16 @@ _require_nvme_trtype_is_fabrics() { return 0 } +_test_dev_nvme_ctrl() { + local dev=$(cat "${TEST_DEV_SYSFS}/device/dev") + + echo "/dev/char/${dev}" +} + +_test_dev_nvme_nsid() { + cat "${TEST_DEV_SYSFS}/nsid" +} + _cleanup_nvmet() { local dev local port @@ -257,6 +267,27 @@ _remove_nvmet_subsystem() { rmdir "${subsys_path}" } +_create_nvmet_passthru() { + local nvmet_subsystem="$1" + local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" + local passthru_path="${subsys_path}/passthru" + + mkdir -p "${subsys_path}" + echo 1 > "${subsys_path}/attr_allow_any_host" + + echo "$(_test_dev_nvme_ctrl)" > "${passthru_path}/device_path" + echo 1 > "${passthru_path}/enable" +} + +_remove_nvmet_passhtru() { + local nvmet_subsystem="$1" + local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" + local passthru_path="${subsys_path}/passthru" + + echo 0 > "${passthru_path}/enable" + rmdir "${subsys_path}" +} + _add_nvmet_subsys_to_port() { local port="$1" local nvmet_subsystem="$2" @@ -292,6 +323,50 @@ _find_nvme_dev() { done } +_find_nvme_passthru_loop_dev() { + local subsys=$1 + local nsid + local dev + + dev=$(_find_nvme_dev "${subsys}") + nsid=$(_test_dev_nvme_nsid) + echo "/dev/${dev}n${nsid}" +} + +_nvmet_passthru_target_setup() { + local subsys_name=$1 + + _create_nvmet_passthru "${subsys_name}" + port="$(_create_nvmet_port "loop")" + _add_nvmet_subsys_to_port "${port}" "${subsys_name}" + + echo "$port" +} + +_nvmet_passthru_target_connect() { + local trtype=$1 + local subsys_name=$2 + + _nvme_connect_subsys "${trtype}" "${subsys_name}" + nsdev=$(_find_nvme_passthru_loop_dev "${subsys_name}") + + # The following tests can race with the creation + # of the device so ensure the block device exists + # before continuing + while [ ! -b "${nsdev}" ]; do sleep 1; done + + echo "${nsdev}" +} + +_nvmet_passthru_target_cleanup() { + local port=$1 + local subsys_name=$2 + + _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" + _remove_nvmet_port "${port}" + _remove_nvmet_passhtru "${subsys_name}" +} + _filter_discovery() { sed -n -r -e "s/Generation counter [0-9]+/Generation counter X/" \ -e '/Discovery Log Number|Log Entry|trtype|subnqn/p' -- 2.20.1