Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3519733pxf; Mon, 15 Mar 2021 11:21:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfoo6eGxaGtuIqx7MHUJINE4xllGuxoZlxNSTibT9m20Gtj0+F6pAqrulKCq5BQnK5ppSQ X-Received: by 2002:a05:6402:38f:: with SMTP id o15mr31039637edv.361.1615832513516; Mon, 15 Mar 2021 11:21:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832513; cv=none; d=google.com; s=arc-20160816; b=oFDrIShdAO6fk7RLhnB+kTTnZrdy5+nDf6LpzPEc0ZF7+nwRF/8TlYmWpDc4bysmMd GSKyL7p6qNm/It5LtAwB+pEsgGWcrg08fXCY6KI34BCoK+vSWWlHkgE3yKI2aVPnf35s FJygSzuL2fL+ZZ1Gqo4q1HqsMIlaV8b9KvqaD4CWh3WzotlhLc/dBtrTUOaUEA/cdHMJ fV71kzwQXwuwUGifQu+N5cbSi/zPhpxcg7hlucktaiXGoOdi7CbIwZlTpIGgveuqbbgz PQ4/6Y0jflO9HJrfadqfxy6YHjtNi2nYfd4YegwaCIkz8ZGHLY9CXLNPIMf+GmvjGyM8 bJCA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yCTwqkZvdOOwsDv8lIQf9i3ZoZjqL4SRxaUjrPUBhcs=; b=mSTNbwfviLiU99iRTBJOyvkVF5kfPXfj38QIZ0t+2hZTBLvH4cofq1OQ7uQBZ739L1 sFDmkrfzmBKxqC8jwWM2lPIvP777EoaB8mCfjMfUu5BMmtS8+na6s/xv+JIUrxJAo5ZW MJTTQVm8f42WKk6JlM0thoJPnecmviqqEVTx5n6nMPfvc/B6O5YOYroiw6WH9dQHh2GX dvIg9Ox9Nwd2csqUCsAp/YHFP5OhOfAifuFhqKySWq098ke5X6zioRE7UlT8I4xvHitA j8qglodIp2Ikq8Cdmf9me4huQXqRGyYzdDsxRKbrGL9D3fZPIzB5XXMg5EmF0IckeKz3 b3MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gzdNQi84; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si12637177edn.523.2021.03.15.11.21.31; Mon, 15 Mar 2021 11:21:53 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=gzdNQi84; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237565AbhCOOSn (ORCPT + 99 others); Mon, 15 Mar 2021 10:18:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:36788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232702AbhCON7e (ORCPT ); Mon, 15 Mar 2021 09:59:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 49A6B64F3E; Mon, 15 Mar 2021 13:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816751; bh=ogN7FbTujMMFv4mgK0Dnig98Hq/8MoXgI0/Jw4hM0sY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gzdNQi844eUZdVRVC2prAFhOEpX+Su7geQWAGDCcYBy53xJGtHZYe9sMpyhGvrbuz 3CtJvj3OAUQB9xSrTb4Xz4NX2CO6HbmOfOAXyUnY1+bDd9x5grT73htN/NVi1lTHJt nvdv7JmoKjih3y39MRqm5bV85Y4YtprYY0dyGx60= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lee Duncan , Mike Christie , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 085/168] scsi: libiscsi: Fix iscsi_prep_scsi_cmd_pdu() error handling Date: Mon, 15 Mar 2021 14:55:17 +0100 Message-Id: <20210315135553.178288834@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Mike Christie [ Upstream commit d28d48c699779973ab9a3bd0e5acfa112bd4fdef ] If iscsi_prep_scsi_cmd_pdu() fails we try to add it back to the cmdqueue, but we leave it partially setup. We don't have functions that can undo the pdu and init task setup. We only have cleanup_task which can clean up both parts. So this has us just fail the cmd and go through the standard cleanup routine and then have the SCSI midlayer retry it like is done when it fails in the queuecommand path. Link: https://lore.kernel.org/r/20210207044608.27585-2-michael.christie@oracle.com Reviewed-by: Lee Duncan Signed-off-by: Mike Christie Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/libiscsi.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index a14057c67a12..c5b7d18513b6 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c @@ -1532,14 +1532,9 @@ static int iscsi_data_xmit(struct iscsi_conn *conn) } rc = iscsi_prep_scsi_cmd_pdu(conn->task); if (rc) { - if (rc == -ENOMEM || rc == -EACCES) { - spin_lock_bh(&conn->taskqueuelock); - list_add_tail(&conn->task->running, - &conn->cmdqueue); - conn->task = NULL; - spin_unlock_bh(&conn->taskqueuelock); - goto done; - } else + if (rc == -ENOMEM || rc == -EACCES) + fail_scsi_task(conn->task, DID_IMM_RETRY); + else fail_scsi_task(conn->task, DID_ABORT); spin_lock_bh(&conn->taskqueuelock); continue; -- 2.30.1