From patchwork Fri Aug 18 14:15:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 136109 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp1953186vqi; Sat, 19 Aug 2023 03:49:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKFRkCX5KDf+1bcNScwfXYLItL2RTBBWRkzkAa68XBAm71qgGJygDI/9N1ef1yyOxLX5Zr X-Received: by 2002:a05:6a20:4308:b0:140:6fa9:7001 with SMTP id h8-20020a056a20430800b001406fa97001mr1517006pzk.40.1692442180816; Sat, 19 Aug 2023 03:49:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692442180; cv=none; d=google.com; s=arc-20160816; b=mnCif0Ob9ApaN6JGTG1lZv2lEFYFLqK/AWj/Sqsw+u3Hid4HPLUk6mM9SPAreP0lgg YpwJs7s9rdCeJ9XTD+Fc4KUpmKjDlxUdlxWQhIdwQlk2GJZ22cmG6u6R9FNiA3GxVEpS QgNIeNXEd5gsW5c8u8A8uGBp4vYfH94rJg5EcZba3vsekgssqarfSeRJHtgQRRdHoqT6 O3yyCJpo1p0JEYG/ZRgwSW8atRAdkUKGIvnX7lWIAhSFJL43MSMY0pnubcZUZMTTM0VF HbfHr5GaH6KHp+3/lSrQaKomRPyLxSLBpNZ1elYTEd7QnTfm7FLOXPUl3izKjiIVqcx4 XXGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=fBFsEI0/jrPBLLtbeuavruB1PrzH5cauI3y9s1NHi6I=; fh=5/fIvtJngQ8ihVP2sAeVzT9qd73jZSUbSdvYI+8XWPk=; b=Pq4eFonhHh9xt0UDyA0iIxdYif744wEfGAmBThnUBT3wVU7q7UeI/Jxdg5mAZPGEY4 /gETwWwoke0FQ+niru+DymB7dT7udQEjjtsuHwIhtXqdYGfO40HB2qbpgOwmpcSv+1q1 eCn2uw064ST/ac587wqOum22PsreVoycpDlAHBtiRvo19tgwhT7NCGmMLYeMImaI0zYz +DtReE0UO20u8tQbyKuxW/3Qv7PGo0ZiyFjEX/R7jKlnOBbc+Zi2mzwfFSjksZchEdpD BVjZdwXXIr8mYj3ltecR+DMFy+0P2EBFQgppO9ghUPNMryz+LGiZcyXDShFtZpHJQBeU hYhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=NL5BgYi7; dkim=neutral (no key) header.i=@suse.de header.b=NCxsre0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z25-20020a634c19000000b005644828f3dcsi3150530pga.164.2023.08.19.03.49.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 03:49:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=NL5BgYi7; dkim=neutral (no key) header.i=@suse.de header.b=NCxsre0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBFBB54706; Sat, 19 Aug 2023 01:32:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377702AbjHROQW (ORCPT + 99 others); Fri, 18 Aug 2023 10:16:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377687AbjHROPu (ORCPT ); Fri, 18 Aug 2023 10:15:50 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D34A3C3F; Fri, 18 Aug 2023 07:15:46 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3DC421F8AC; Fri, 18 Aug 2023 14:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692368145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fBFsEI0/jrPBLLtbeuavruB1PrzH5cauI3y9s1NHi6I=; b=NL5BgYi75+jWolN2aiQ57XHRy2xhqKOUS8csGmT3Jt2IzHiSzRUo3rZNpmXtGLBqSjsi1R zuN9JXS0pShhU283vlnIQT1Ele5ADz56+aKK38woLo0NgRFTdPXmHcwwbCT+eombTSPUWh mdpEI6L85HmVW9pKFB4T8fDWRtnDba8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692368145; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fBFsEI0/jrPBLLtbeuavruB1PrzH5cauI3y9s1NHi6I=; b=NCxsre0lJQTNOQW4oUEDcAS+2mcYnucIYl0ePmCLZcMS2ysIyuaFXXxOqqcR6bIGASLBic UwH0N3Dm/ZMA8iBQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 30F7E13441; Fri, 18 Aug 2023 14:15:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /fn0CxF932SdOwAAMHmgww (envelope-from ); Fri, 18 Aug 2023 14:15:45 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Chaitanya Kulkarni , Shin'ichiro Kawasaki , Hannes Reinecke , Sagi Grimberg , Jason Gunthorpe , Daniel Wagner Subject: [PATCH blktests v2 2/3] nvme/{033,034,035,036,37}: drop port handle between passthru target setup and cleanup Date: Fri, 18 Aug 2023 16:15:36 +0200 Message-ID: <20230818141537.22332-3-dwagner@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230818141537.22332-1-dwagner@suse.de> References: <20230818141537.22332-1-dwagner@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774654252039315613 X-GMAIL-MSGID: 1774654252039315613 The passthru nvmet setup and cleanup helpers are using the port as handle to track resources. Instead returning the port from the setup call, we figure out in the cleanup code which resources have been allocated. This avoids passing around awkward handles. Signed-off-by: Daniel Wagner --- tests/nvme/033 | 5 ++--- tests/nvme/034 | 5 ++--- tests/nvme/035 | 5 ++--- tests/nvme/036 | 5 ++--- tests/nvme/037 | 5 ++--- tests/nvme/rc | 30 ++++++++++++++++++++++++------ 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/tests/nvme/033 b/tests/nvme/033 index d924883460c2..6cc4f57e6d60 100755 --- a/tests/nvme/033 +++ b/tests/nvme/033 @@ -50,16 +50,15 @@ test_device() { _setup_nvmet local nsdev - local port - port=$(_nvmet_passthru_target_setup "${def_subsysnqn}") + _nvmet_passthru_target_setup "${def_subsysnqn}" nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}") compare_dev_info "${nsdev}" _nvme_disconnect_subsys "${def_subsysnqn}" - _nvmet_passthru_target_cleanup "${port}" "${def_subsysnqn}" + _nvmet_passthru_target_cleanup "${def_subsysnqn}" echo "Test complete" } diff --git a/tests/nvme/034 b/tests/nvme/034 index e79eef5e756d..3bd1c3ad2f61 100755 --- a/tests/nvme/034 +++ b/tests/nvme/034 @@ -21,15 +21,14 @@ test_device() { local ctrldev local nsdev - local port - port=$(_nvmet_passthru_target_setup "${def_subsysnqn}") + _nvmet_passthru_target_setup "${def_subsysnqn}" nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}") _run_fio_verify_io --size="${nvme_img_size}" --filename="${nsdev}" _nvme_disconnect_subsys "${def_subsysnqn}" - _nvmet_passthru_target_cleanup "${port}" "${def_subsysnqn}" + _nvmet_passthru_target_cleanup "${def_subsysnqn}" echo "Test complete" } diff --git a/tests/nvme/035 b/tests/nvme/035 index f0dfc92ceeea..712fe1dbcfb8 100755 --- a/tests/nvme/035 +++ b/tests/nvme/035 @@ -27,15 +27,14 @@ test_device() { local ctrldev local nsdev - local port - port=$(_nvmet_passthru_target_setup "${def_subsysnqn}") + _nvmet_passthru_target_setup "${def_subsysnqn}" nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}") _xfs_run_fio_verify_io "${nsdev}" "${nvme_img_size}" _nvme_disconnect_subsys "${def_subsysnqn}" - _nvmet_passthru_target_cleanup "${port}" "${def_subsysnqn}" + _nvmet_passthru_target_cleanup "${def_subsysnqn}" echo "Test complete" } diff --git a/tests/nvme/036 b/tests/nvme/036 index 61b9e2309da7..89ccd256a67c 100755 --- a/tests/nvme/036 +++ b/tests/nvme/036 @@ -19,9 +19,8 @@ test_device() { _setup_nvmet local ctrldev - local port - port=$(_nvmet_passthru_target_setup "${def_subsysnqn}") + _nvmet_passthru_target_setup "${def_subsysnqn}" nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" "${def_subsysnqn}") ctrldev=$(_find_nvme_dev "${def_subsysnqn}") @@ -31,7 +30,7 @@ test_device() { fi _nvme_disconnect_subsys "${def_subsysnqn}" - _nvmet_passthru_target_cleanup "${port}" "${def_subsysnqn}" + _nvmet_passthru_target_cleanup "${def_subsysnqn}" echo "Test complete" } diff --git a/tests/nvme/037 b/tests/nvme/037 index 5a78444b7e78..a2815b3ff2d7 100755 --- a/tests/nvme/037 +++ b/tests/nvme/037 @@ -20,15 +20,14 @@ test_device() { local subsys="blktests-subsystem-" local iterations=10 local ctrldev - local port for ((i = 0; i < iterations; i++)); do - port=$(_nvmet_passthru_target_setup "${subsys}${i}") + _nvmet_passthru_target_setup "${subsys}${i}" nsdev=$(_nvmet_passthru_target_connect "${nvme_trtype}" \ "${subsys}${i}") _nvme_disconnect_subsys "${subsys}${i}" >>"${FULL}" 2>&1 - _nvmet_passthru_target_cleanup "${port}" "${subsys}${i}" + _nvmet_passthru_target_cleanup "${subsys}${i}" done echo "Test complete" diff --git a/tests/nvme/rc b/tests/nvme/rc index 0b964e99efd8..b6f06be75ca1 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -712,6 +712,19 @@ _remove_nvmet_subsystem_from_port() { rm "${NVMET_CFS}/ports/${port}/subsystems/${nvmet_subsystem}" } +_get_nvmet_ports() { + local nvmet_subsystem="$1" + local -n nvmet_ports="$2" + local cfs_path="${NVMET_CFS}/ports" + local sarg + + sarg="s;^${cfs_path}/\([0-9]\+\)/subsystems/${nvmet_subsystem}$;\1;p" + + for path in "${cfs_path}/"*"/subsystems/${nvmet_subsystem}"; do + nvmet_ports+=("$(echo "${path}" | sed -n -s "${sarg}")") + done +} + _set_nvmet_hostkey() { local nvmet_hostnqn="$1" local nvmet_hostkey="$2" @@ -781,13 +794,12 @@ _find_nvme_passthru_loop_dev() { _nvmet_passthru_target_setup() { local subsys_name=$1 + local port _create_nvmet_passthru "${subsys_name}" port="$(_create_nvmet_port "${nvme_trtype}")" _add_nvmet_subsys_to_port "${port}" "${subsys_name}" _create_nvmet_host "${subsys_name}" "${def_hostnqn}" - - echo "$port" } _nvmet_passthru_target_connect() { @@ -806,11 +818,17 @@ _nvmet_passthru_target_connect() { } _nvmet_passthru_target_cleanup() { - local port=$1 - local subsys_name=$2 + local subsys_name=$1 + local ports + local port + + _get_nvmet_ports "${subsys_name}" ports + + for port in "${ports[@]}"; do + _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" + _remove_nvmet_port "${port}" + done - _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}" - _remove_nvmet_port "${port}" _remove_nvmet_passhtru "${subsys_name}" _remove_nvmet_host "${def_hostnqn}" }