From nobody Thu Oct 2 18:19:18 2025 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BEAD522DF9E; Sun, 14 Sep 2025 10:11:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.32 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757844688; cv=none; b=CcBasS393uahtuo5WpDK0GZsetFpg77RBjNgz2YScBBPc+qKWFbEb1ED9axTQrtoFnT4dMeWhtZfxa47PfTRk8u1cMvpM2fNuuzwjM9NjLTnq/1KCIhf3kRX3TpgTzDXOyXpQGEe34EkieUhmsxmJV4qgIotfZLxiXNJV8uBtvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757844688; c=relaxed/simple; bh=wgQ3RYY9DNiXsBqjzIz+5B5okUFc/bdGT33SjQ1d4kY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=meHbKn2tAPt+0Wp6aEyiO8Wti3QbZEHmn1/xP3TgRfYUdDaXluYN8KWCMT0hjLlCmwzsCrCFTTtY2cuOOvfNmNdi85xDqLBafqd/75/tr54rTyqBUJaqqtZ86/TApguyDIEnfcFQiKDOtwDdo/gPwYgo9B66QgjqB/9DX2kImX8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; arc=none smtp.client-ip=45.249.212.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4cPkVh1svQz27j5N; Sun, 14 Sep 2025 18:12:28 +0800 (CST) Received: from kwepemk500001.china.huawei.com (unknown [7.202.194.86]) by mail.maildlp.com (Postfix) with ESMTPS id 715971402CA; Sun, 14 Sep 2025 18:11:18 +0800 (CST) Received: from localhost.localdomain (10.175.104.170) by kwepemk500001.china.huawei.com (7.202.194.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Sun, 14 Sep 2025 18:11:17 +0800 From: JiangJianJun To: , , CC: , , , , , , Subject: [RFC PATCH v4 4/9] scsi: scsi_error: Add helper scsi_eh_sdev_stu to do START_UNIT Date: Sun, 14 Sep 2025 18:41:40 +0800 Message-ID: <20250914104145.2239901-5-jiangjianjun3@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20250914104145.2239901-1-jiangjianjun3@huawei.com> References: <17230842-0a7a-403e-abc7-a15e3aa5d424@suse.de> <20250914104145.2239901-1-jiangjianjun3@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk500001.china.huawei.com (7.202.194.86) Content-Type: text/plain; charset="utf-8" From: Wenchao Hao Add helper function scsi_eh_sdev_stu() to perform START_UNIT and check if to finish some error commands. This is preparation for a genernal LUN based error handle strategy and did not change original logic. Signed-off-by: Wenchao Hao Co-developed-by: JiangJianJun Signed-off-by: JiangJianJun --- drivers/scsi/scsi_error.c | 50 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 80a85b387068..a1b700dbb0ec 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1559,6 +1559,31 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd) return 1; } =20 +static int scsi_eh_sdev_stu(struct scsi_cmnd *scmd, + struct list_head *work_q, + struct list_head *done_q) +{ + struct scsi_device *sdev =3D scmd->device; + struct scsi_cmnd *next; + + SCSI_LOG_ERROR_RECOVERY(3, sdev_printk(KERN_INFO, sdev, + "%s: Sending START_UNIT\n", current->comm)); + + if (scsi_eh_try_stu(scmd)) { + SCSI_LOG_ERROR_RECOVERY(3, sdev_printk(KERN_INFO, sdev, + "%s: START_UNIT failed\n", current->comm)); + return 0; + } + + if (!scsi_device_online(sdev) || !scsi_eh_tur(scmd)) + list_for_each_entry_safe(scmd, next, work_q, eh_entry) + if (scmd->device =3D=3D sdev && + scsi_eh_action(scmd, SUCCESS) =3D=3D SUCCESS) + scsi_eh_finish_cmd(scmd, done_q); + + return list_empty(work_q); +} + /** * scsi_eh_stu - send START_UNIT if needed * @shost: &scsi host being recovered. @@ -1573,7 +1598,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost, struct list_head *work_q, struct list_head *done_q) { - struct scsi_cmnd *scmd, *stu_scmd, *next; + struct scsi_cmnd *scmd, *stu_scmd; struct scsi_device *sdev; =20 shost_for_each_device(sdev, shost) { @@ -1596,26 +1621,9 @@ static int scsi_eh_stu(struct Scsi_Host *shost, if (!stu_scmd) continue; =20 - SCSI_LOG_ERROR_RECOVERY(3, - sdev_printk(KERN_INFO, sdev, - "%s: Sending START_UNIT\n", - current->comm)); - - if (!scsi_eh_try_stu(stu_scmd)) { - if (!scsi_device_online(sdev) || - !scsi_eh_tur(stu_scmd)) { - list_for_each_entry_safe(scmd, next, - work_q, eh_entry) { - if (scmd->device =3D=3D sdev && - scsi_eh_action(scmd, SUCCESS) =3D=3D SUCCESS) - scsi_eh_finish_cmd(scmd, done_q); - } - } - } else { - SCSI_LOG_ERROR_RECOVERY(3, - sdev_printk(KERN_INFO, sdev, - "%s: START_UNIT failed\n", - current->comm)); + if (scsi_eh_sdev_stu(stu_scmd, work_q, done_q)) { + scsi_device_put(sdev); + break; } } =20 --=20 2.33.0