From patchwork Tue Jul 17 13:31:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10529411 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 43F036020A for ; Tue, 17 Jul 2018 13:31:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44D752924E for ; Tue, 17 Jul 2018 13:31:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 38C63291AB; Tue, 17 Jul 2018 13:31:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE2422924A for ; Tue, 17 Jul 2018 13:31:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731526AbeGQOEK (ORCPT ); Tue, 17 Jul 2018 10:04:10 -0400 Received: from mx2.suse.de ([195.135.220.15]:35454 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731580AbeGQOEK (ORCPT ); Tue, 17 Jul 2018 10:04:10 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 48A33AFC2; Tue, 17 Jul 2018 13:31:27 +0000 (UTC) From: Hannes Reinecke To: Omar Sandoval Cc: Christoph Hellwig , Sagi Grimberg , Keith Busch , linux-nvme@lists.infradead.org, linux-block@vger.kernel.org, Hannes Reinecke , Hannes Reinecke Subject: [PATCH 1/2] blktests: enable ANA support Date: Tue, 17 Jul 2018 15:31:17 +0200 Message-Id: <20180717133118.39026-2-hare@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20180717133118.39026-1-hare@suse.de> References: <20180717133118.39026-1-hare@suse.de> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update nvme functions to support ANA. Signed-off-by: Hannes Reinecke --- tests/nvme/rc | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/tests/nvme/rc b/tests/nvme/rc index fb5dbdf..116661d 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -27,7 +27,7 @@ group_device_requires() { _test_dev_is_nvme } -NVMET_CFS="/sys/kernel/config/nvmet/" +NVMET_CFS="/sys/kernel/config/nvmet" _test_dev_is_nvme() { if ! readlink -f "$TEST_DEV_SYSFS/device" | grep -q nvme; then @@ -49,6 +49,7 @@ _create_nvmet_port() { mkdir "${NVMET_CFS}/ports/${port}" echo "${trtype}" > "${NVMET_CFS}/ports/${port}/addr_trtype" + echo "${port}" > "${NVMET_CFS}/ports/${port}/addr_traddr" echo "${port}" } @@ -58,6 +59,39 @@ _remove_nvmet_port() { rmdir "${NVMET_CFS}/ports/${port}" } +_create_nvmet_anagroup() { + local port="$1" + local port_cfs="${NVMET_CFS}/ports/${port}" + local grpid + + for ((grpid = 1; ; grpid++)); do + if [[ ! -e "${port_cfs}/ana_groups/${grpid}" ]]; then + break + fi + done + + mkdir "${port_cfs}/ana_groups/${grpid}" + + echo "${grpid}" +} + +_remove_nvmet_anagroup() { + local port="$1" + local grpid="$2" + local ana_cfs="${NVMET_CFS}/ports/${port}/ana_groups/${grpid}" + + rmdir "${ana_cfs}" +} + +_set_nvmet_anagroup_state() { + local port="$1" + local grpid="$2" + local state="$3" + local ana_cfs="${NVMET_CFS}/ports/${port}/ana_groups/${grpid}" + + echo "${state}" > "${ana_cfs}/ana_state" +} + _create_nvmet_ns() { local nvmet_subsystem="$1" local nsid="$2" @@ -65,14 +99,22 @@ _create_nvmet_ns() { local uuid="00000000-0000-0000-0000-000000000000" local subsys_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" local ns_path="${subsys_path}/namespaces/${nsid}" + local ana_grpid - if [[ $# -eq 4 ]]; then + if [[ $# -ge 4 ]]; then uuid="$4" fi + if [[ $# -eq 5 ]]; then + ana_grpid="$5" + fi + mkdir "${ns_path}" printf "%s" "${blkdev}" > "${ns_path}/device_path" printf "%s" "${uuid}" > "${ns_path}/device_uuid" + if [ -n "${ana_grpid}" ] ; then + printf "%s" "${ana_grpid}" > "${ns_path}/ana_grpid" + fi printf 1 > "${ns_path}/enable" } @@ -80,11 +122,12 @@ _create_nvmet_subsystem() { local nvmet_subsystem="$1" local blkdev="$2" local uuid=$3 + local ana_grpid=$4 local cfs_path="${NVMET_CFS}/subsystems/${nvmet_subsystem}" mkdir -p "${cfs_path}" echo 1 > "${cfs_path}/attr_allow_any_host" - _create_nvmet_ns "${nvmet_subsystem}" "1" "${blkdev}" "${uuid}" + _create_nvmet_ns "${nvmet_subsystem}" "1" "${blkdev}" "${uuid}" "${ana_grpid}" } _remove_nvmet_ns() {