From patchwork Tue Jan 30 09:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1107220dyb; Tue, 30 Jan 2024 01:54:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBkEPdVbnkvgRt4NAsv2uzYPmquqendo9SQX+/1IDoNj7LnsD5dkZmUAE2hQyE7AllcWhC X-Received: by 2002:a17:906:f9c3:b0:a30:8d46:4cac with SMTP id lj3-20020a170906f9c300b00a308d464cacmr5635724ejb.67.1706608452581; Tue, 30 Jan 2024 01:54:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608452; cv=pass; d=google.com; s=arc-20160816; b=lj8rPcDzFbwLGopAB8eWa/kh8x8Wo7qGX5WgstgOc35TQSS5bI9SI1cr47nPBvYBgm kN0MFHW0TMvK4wSHVdSxPakPI7P63q70JFNrOupzMwpllYuU5VDhK/rLskerweucSIM4 hxbVZAKTBhrVPqDsQ78uuSyFCOZnnSTaaPrOnLgwVROncRPBFk51GSQCmijKBUZl6n4+ wT5csEIFSoQlwKzDNlfCtm95B90wmvt7E3oiOqYvhnd/kPPGga9fSpBHccT2Ai8XvWzc UbPpNhkcVBzDnU/0PXRMRP/NkYjOj2GvV2XmBZ5BN7oyxcMvavW3fWMXDsB2rgP7vQh7 fRFA== ARC-Message-Signature: i=2; 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=BSvgt35Kdc/PmYUOYaVWdJvvCorFPrHxhpJEVx5L1LU=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=JzkH6zBOKZY+Xj6dFuVWjM3OTadArz9ajnNjZSLGctnoPPFP1oZkQQO2GRfm5/FQGc wsPZezM4CcZDDRj5tuTwayF6r5fbSvhfyUoaDc5l6iDJtn1JMPzOgsu7e28WP4uDyQ2j CN+U+yBXJnkbSSnA8k7/iO2tVwKR+RXh8ThS5HKKCPJOjd01vY84Ly9lqUcqj8ebeEQ0 n8Y0aGQjwZgp34honSjT4XS5m29stwTFg+t6O4K4ID9vwIowkWSfqiWn1KoTm4AonLI5 y/Yywxu2R6RucSTHpDOsfJpEz74sxPpmxxJYNcOyNEYtsVpF4G99Ei0reUVlGTtQvLpe Z6KA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d7-20020a170906344700b00a2cf514f465si4434908ejb.245.2024.01.30.01.54.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:54:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44312-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 35D9B1F2276C for ; Tue, 30 Jan 2024 09:54:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E38816A341; Tue, 30 Jan 2024 09:49:58 +0000 (UTC) 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 565BF679FF for ; Tue, 30 Jan 2024 09:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; cv=none; b=XY/rSwVkiH10EazlLGPBJq8PFp638eDqIHX0UGqtc1uYtBXulmY3mgMGPXrT0uWcN40ivxfsxG/SczR0BpQmt75F2+xUCO9jG6GnRVmy+YfS+qAaBfvyRI0/5FK/8HZeWGIPAmkI2xjDU0pBQRAaC3pHH2pP8SjtBTW9vZmQ4oo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; c=relaxed/simple; bh=CHEe3BgyB5vNBsrIi37+8+stLpieh300FXdpijsIshU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h5KRCNhTMwu/005J70/JzPCgB4VhvzYNcRhZLrmdhOmrdPA3UsGzjPNEZdAlqYlu200DpR5uVaVXpyCejy42ZWCe8R1dDZ17khwJ6gcUHF16BiecBQzeKVE/mZvG55E8yxrpYNS8E4NyYMA7E7jyPWYJh/DF4m2G9XZXfZGjj0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 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 A3F601F842; Tue, 30 Jan 2024 09:49:53 +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 9155E13462; Tue, 30 Jan 2024 09:49:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id X/UIIkHGuGWZbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:53 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 09/12] nvmet-fc: abort command when there is no binding Date: Tue, 30 Jan 2024 10:49:35 +0100 Message-ID: <20240130094938.1575-10-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-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: Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: A3F601F842 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508664742900378 X-GMAIL-MSGID: 1789508664742900378 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. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner --- 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 fe3246024836..c80b8a066fd1 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1099,6 +1099,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; @@ -2514,8 +2517,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));