From patchwork Mon Dec 18 15:31:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 180539 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1347494dyi; Mon, 18 Dec 2023 08:07:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IF3JdA/QFQa4a9gG+LxqAyL6vkqFnjneLrhd8Z4SVL1uXxk3kwcE2DA27y/YRmWHEAn4TwO X-Received: by 2002:a81:8743:0:b0:5d7:1940:53cc with SMTP id x64-20020a818743000000b005d7194053ccmr13850991ywf.68.1702915661125; Mon, 18 Dec 2023 08:07:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702915661; cv=none; d=google.com; s=arc-20160816; b=SLxOzUxHPvp2VIckqRwhoCkAogBG7unfjPXnQZU3OeQZYajJk8xpB6Q6pednYujyGC cBDohNIzgjEt1CzmzXydfEFJRtD0iDG/iCuizkGF+6bLe6ErZkJN14XoYYY5dVnQDcb0 xC6Z4z6pegDYZikPQn4c1OwFPKnSLPDOOhbnocvfvNBf4u2e3LEyiSKmBK/06hA7pq3w K70rvM1cRH7YL4yH0v3MzgE6whY7g0/8mnyXmmMpQ8HC5x0j7B2X/K92cQx+pq3+u33P a7sry1toZFRMP8+MaxUIqHuxX5SmCHw4HUDN7CCvu3koRFV2VblD+BtFRN7gOT9hJibH 6zMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=mOtf+QZDvmrKDTXJ4FRCySwcKfTtKvHv8paQJexeOGI=; fh=3QIVKsEmsld8rvcEkMSr/XDw53o2lrGJeYcvS7FhzFk=; b=niF2E53X60YtYTy1B/a4NiRY74s74pTb8T9GxAIm+FzJCyAOLw69M4o1jbLPYrEz0z 9L/UoZhgANGZqTZmlkvZcDKJ4twPTs/pql3dZ4afUxsBwIAZ7iu/ljixFHyoOTzsfsbQ OXX/Ina6Cy0aHs4H57PBk5yeNXEWGDGZu7Kwgogjzwrkr7BV0KzbBQZIayroNLFxE2LX SDft3pMrbL5Ma46N6pMM5AJHXufnLbKT06t6QPTmqHwFReD2Z8jjnhQfOIUdKbqcmqHt XJwTDR53DuwSshSk032hDzwf59uiDVXmahjPct8jsUG1+c0guDAmfxEf7bl5HvM0AilD vq8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4026-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4026-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u64-20020a0deb43000000b005e3e633e6e4si2436516ywe.542.2023.12.18.08.07.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 08:07:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-4026-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-4026-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-4026-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DE9CE1C258E4 for ; Mon, 18 Dec 2023 16:07:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 484237609B; Mon, 18 Dec 2023 16:02:55 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 425DF49897 for ; Mon, 18 Dec 2023 16:02:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 8145E1FD4D; Mon, 18 Dec 2023 16:02:50 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 7349013BC8; Mon, 18 Dec 2023 16:02:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id WUMpGyptgGUABAAAn2gu4w (envelope-from ); Mon, 18 Dec 2023 16:02:50 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Keith Busch , James Smart , Hannes Reinecke , Daniel Wagner Subject: [PATCH v3 13/16] nvmet-fc: abort command if when there is binding Date: Mon, 18 Dec 2023 16:31:01 +0100 Message-ID: <20231218153105.12717-14-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231218153105.12717-1-dwagner@suse.de> References: <20231218153105.12717-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] Authentication-Results: smtp-out2.suse.de; none X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 8145E1FD4D X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785636492453177644 X-GMAIL-MSGID: 1785636492453177644 WHen the target port has not active port binding, there is no point in trying to process the command as it has to fail anyway. Instead adding checks to all commands abort the command early. Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/target/fc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 47cecc8c72b2..663c51c9fe53 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1101,6 +1101,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) int idx; bool needrandom = true; + if (!tgtport->pe) + return NULL; + assoc = kzalloc(sizeof(*assoc), GFP_KERNEL); if (!assoc) return NULL; @@ -2520,8 +2523,9 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, fod->req.cmd = &fod->cmdiubuf.sqe; fod->req.cqe = &fod->rspiubuf.cqe; - if (tgtport->pe) - fod->req.port = tgtport->pe->port; + if (!tgtport->pe) + goto transport_error; + fod->req.port = tgtport->pe->port; /* clear any response payload */ memset(&fod->rspiubuf, 0, sizeof(fod->rspiubuf));