From nobody Mon Feb 9 16:17:29 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28E73CA0FE1 for ; Fri, 1 Sep 2023 09:43:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349065AbjIAJnR (ORCPT ); Fri, 1 Sep 2023 05:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348950AbjIAJmv (ORCPT ); Fri, 1 Sep 2023 05:42:51 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D3611708; Fri, 1 Sep 2023 02:42:23 -0700 (PDT) Received: from kwepemm600012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RcY184S2czrSMV; Fri, 1 Sep 2023 17:40:28 +0800 (CST) Received: from build.huawei.com (10.175.101.6) by kwepemm600012.china.huawei.com (7.193.23.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 1 Sep 2023 17:42:09 +0800 From: Wenchao Hao To: "James E . J . Bottomley" , "Martin K . Petersen" , CC: Hannes Reinecke , , , , Wenchao Hao Subject: [RFC PATCH v2 18/19] scsi: virtio_scsi: Add param to control LUN based error handle Date: Fri, 1 Sep 2023 17:41:26 +0800 Message-ID: <20230901094127.2010873-19-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230901094127.2010873-1-haowenchao2@huawei.com> References: <20230901094127.2010873-1-haowenchao2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600012.china.huawei.com (7.193.23.74) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add new param lun_eh to control if enable LUN based error handler, since virtio_scsi did not define other further reset callbacks, it is not necessary to fallback to further recover any more, so set the LUN error handler with fallback set to 0. Signed-off-by: Wenchao Hao --- drivers/scsi/virtio_scsi.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index bd5633667d01..7bf4a34cdd20 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include =20 @@ -37,6 +38,10 @@ #define VIRTIO_SCSI_EVENT_LEN 8 #define VIRTIO_SCSI_VQ_BASE 2 =20 +static bool lun_eh; +module_param(lun_eh, bool, 0444); +MODULE_PARM_DESC(lun_eh, "LUN based error handle (def=3D0)"); + /* Command queue element */ struct virtio_scsi_cmd { struct scsi_cmnd *sc; @@ -679,9 +684,18 @@ static int virtscsi_device_alloc(struct scsi_device *s= device) */ sdevice->sdev_bflags =3D BLIST_TRY_VPD_PAGES; =20 + if (lun_eh) + return scsi_device_setup_eh(sdevice, 0); + return 0; } =20 +static void virtscsi_device_destroy(struct scsi_device *sdevice) +{ + if (lun_eh) + return scsi_device_clear_eh(sdevice); +} + =20 /** * virtscsi_change_queue_depth() - Change a virtscsi target's queue depth @@ -757,7 +771,7 @@ static const struct scsi_host_template virtscsi_host_te= mplate =3D { .eh_device_reset_handler =3D virtscsi_device_reset, .eh_timed_out =3D virtscsi_eh_timed_out, .slave_alloc =3D virtscsi_device_alloc, - + .slave_destroy =3D virtscsi_device_destroy, .dma_boundary =3D UINT_MAX, .map_queues =3D virtscsi_map_queues, .track_queue_depth =3D 1, --=20 2.35.3