Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp524738rwr; Thu, 4 May 2023 06:30:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7GyQ5kxYMQRLtmwzLPn0EURSrGsHvcpduzF3G5L8ieOo4qehbxLorXFvv5wtZopXy/BK+f X-Received: by 2002:a05:6a21:328c:b0:f2:b0:68e8 with SMTP id yt12-20020a056a21328c00b000f200b068e8mr2767288pzb.3.1683207036490; Thu, 04 May 2023 06:30:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683207036; cv=none; d=google.com; s=arc-20160816; b=hc+c1gkq7VcAoaGlnk90d01gyErOaMzrXeuNU2i1GhBpHM+OtbnGLorT52V5mtWmKb TBONtPUg9WyueSd17mi3DimkexvpY0IqZQAVw2kBfwJNvys/oOgSULi28x0ci5T5xAU6 MrJ8keUxCAZUamYX1WhoDSic4yIms/KOnhXB5hU65NAloNmy8suQ5jnrLGQu+xI501DN 3Z8uTtW451Bu6Dx7eA8hvwHsoohK8GilmMXcvirNyI5A733c4+h5w6f0KCWiRiqOs++y xTXpz5a+G4QXwPY9ODGZyHmFYEuTwv1yBmUY3X4nuLBalZk66T9RwRCwWxp9EwIvAzTs 3dHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=b0SOIrYW3c1fYA7x6YF4LwaHyHVs3tFrR6ahz1Tl1EE=; b=W34pvfpW3eLGkS6RdD513WnTLkvl669NQPMNPa5jtIz7rPQUj8srUF77mjOoKzyc/B KjgzR61InZwkkMQJYdDldQFz2tc0Js/Qs5gMoqcr1MPxSXbCvNAf/4sIa1fquCYOb1TE 1K0oKkcFTMaSZdwQXSgUYUDyaB47bilhaWJScaJKYnBhVNb0UTGO+X7Ao8ZnnlLEz13y UlJwxqbSviDaMEjhOLlz93CHVzBoduPQDbiUIJpy7lNnGnfFcxkXyTFJeUfXUW3bpiJ/ SzTZyiEN+BTOLpWeDOjWcGVRCeMrkwXosfOD27H5nG3aug8v5BgMKcAs6CZyYwOtJbJX 778w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 126-20020a630484000000b004fb95253a18si36566109pge.376.2023.05.04.06.30.18; Thu, 04 May 2023 06:30:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230475AbjEDM4W (ORCPT + 99 others); Thu, 4 May 2023 08:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbjEDM4V (ORCPT ); Thu, 4 May 2023 08:56:21 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16CAB59FD; Thu, 4 May 2023 05:56:18 -0700 (PDT) Received: from kwepemm600012.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QBtxk3G1xzpSvY; Thu, 4 May 2023 20:52:10 +0800 (CST) Received: from [10.174.178.220] (10.174.178.220) 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.23; Thu, 4 May 2023 20:56:13 +0800 Message-ID: <0423d1a9-e707-c94d-9a35-8c4304aa4b35@huawei.com> Date: Thu, 4 May 2023 20:56:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 0/6] scsi:scsi_debug: Add error injection for single device Content-Language: en-US To: , "James E . J . Bottomley" , "Martin K . Petersen" , , CC: , References: <20230428013320.347050-1-haowenchao2@huawei.com> <585941de-3e17-d5aa-311b-17773c6fbf1f@interlog.com> From: "haowenchao (C)" In-Reply-To: <585941de-3e17-d5aa-311b-17773c6fbf1f@interlog.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.220] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600012.china.huawei.com (7.193.23.74) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/5/3 7:52, Douglas Gilbert wrote: > On 2023-04-27 21:33, Wenchao Hao wrote: >> The original error injection mechanism was based on scsi_host which >> could not inject fault for a single SCSI device. >> >> This patchset provides the ability to inject errors for a single >> SCSI device. Now we supports inject timeout errors, queuecommand >> errors, and hostbyte, driverbyte, statusbyte, and sense data for >> specific SCSI Command. >> >> The first two patch add an debugfs interface to add and inquiry single >> device's error injection info; the third patch defined how to remove >> an injection which has been added. The following 3 patches use the >> injection info and generate the related error type. >> >> V2: >>    - Using debugfs rather than sysfs attribute interface to manage error >> >> Wenchao Hao (6): >>    scsi:scsi_debug: create scsi_debug directory in the debugfs filesystem >>    scsi:scsi_debug: Add interface to manage single device's error inject >>    scsi:scsi_debug: Define grammar to remove added error injection >>    scsi:scsi_debug: timeout command if the error is injected >>    scsi:scsi_debug: Return failed value if the error is injected >>    scsi:scsi_debug: set command's result and sense data if the error is >>      injected >> >>   drivers/scsi/scsi_debug.c | 318 ++++++++++++++++++++++++++++++++++++++ >>   1 file changed, 318 insertions(+) > > Been playing around with this patchset and it seems to work as expected. Took me > a while to work my way through interface description at the beginning of >   [PATCH v2 2/6] scsi:scsi_debug: Add interface to manage single device's error inject > > so I cut and paste it into my scsi_debug.html page and did some work on it, see: >    https://doug-gilbert.github.io/scsi_debug.html > > There is a new chapter titled: Per device error injection > Kept the ASCII art so it could be ported back to [PATCH v2 2/6]'s description > if Wenchao is agreeable. > Thank you a lot, I would update the patch's description in next version. > So for the whole series: >   Acked-by: Douglas Gilbert > > > One suggestion for later work: perhaps the Command opcode field could be > expanded to: x8[,x16] so optionally a Service Action (in hex) could be > given (e.g. '9e,10' for the READ CAPACITY (16) command). > > Doug Gilbert > > Would you help me to check if my understanding is correct: Define Command opcode as x16, split this 16bit as two parts, one for actually SCSI Command opcode,, another one for Service Action. If so, it would make this interface complex to use. I want to make it easy and we do not need to calculate data. I think there are other methods to support specify a Service Action: method1. Redefine the General rule format and append Service Action to SCSI command opcode as following: +--------+------+-------------------------------------------------------+ | Column | Type | Description | +--------+------+-------------------------------------------------------+ | 1 | u8 | Error code | | | | 0: timeout SCSI command | | | | 1: fail queuecommand, make queuecommand return | | | | given value | | | | 2: fail command, finish command with SCSI status, | | | | sense key and ASC/ASCQ values | +--------+------+-------------------------------------------------------+ | 2 | s32 | Error count | | | | 0: this rule will be ignored | | | | positive: the rule will always take effect | | | | negative: the rule takes effect n times where -n is | | | | the value given. Ignored after n times | +--------+------+-------------------------------------------------------+ | 3 | x8 | SCSI command opcode, 0xff for all commands | +--------+------+-------------------------------------------------------+ | 4 | x8 | specify a Service Action, 0xff for all commands | +--------+------+-------------------------------------------------------+ | ... | xxx | Error type specific fields | +--------+------+-------------------------------------------------------+ method2. define new Error code for commands which need a Service Action, for example: define Error code 3 as the following format to timeout a command commands which need a Service Action: +--------+------+-------------------------------------------------------+ | Column | Type | Description | +--------+------+-------------------------------------------------------+ | 1 | u8 | Fix to 3 | +--------+------+-------------------------------------------------------+ | 2 | s32 | Error count | | | | 0: this rule will be ignored | | | | positive: the rule will always take effect | | | | negative: the rule takes effect n times where -n is | | | | the value given. Ignored after n times | +--------+------+-------------------------------------------------------+ | 3 | x8 | SCSI command opcode, 0xff for all commands | +--------+------+-------------------------------------------------------+ | 4 | x8 | specify a Service Action, 0xff for all commands | +--------+------+-------------------------------------------------------+ We can inject timeout error for the READ CAPACITY (16) command with following: echo "3 -10 0x9e 0x10" > ${error}