Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp518814lqp; Wed, 12 Jun 2024 08:19:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtPbdG4Z097o3nUkNehYe9VdceBokJoH7yd6hNhvZFe3W+0TkgIwqVqZgt7XtL0Ms41jwcdfMD8mhpbzqdagyDjqqd4fLPXYwSlmPlaQ== X-Google-Smtp-Source: AGHT+IExoH3F6JgfOHmPaCksmPQJ2TQ6Xo57u4zFvESdvT4mKfothjJPOPdG5OJK42MbtdooezjO X-Received: by 2002:a17:90a:8998:b0:2c2:e33c:e0c7 with SMTP id 98e67ed59e1d1-2c32b469e35mr8517138a91.3.1718205589531; Wed, 12 Jun 2024 08:19:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718205589; cv=pass; d=google.com; s=arc-20160816; b=JOWAIbeEXBwtl3TZlV5PQ5iRoNPkFVCVIGmOb3yhO8JY12PDppFpd7mjnxlIT8/uiW D3SiqC6wr7nh84bFidVZ/LxeWUNnJK4Of84+tFvnezRhX9o3rYLNmlzvbdZ1iPXYTZPh H47c1R0gopMd/XVnhtxcj4XSZtDNWm0SxvWEs7WeYDzXrA5UB8vSmJPcIO0HsvShzB22 0PaNxpNEXvhc9HHQZh4sHGifZkB+Yskhlh1SPoQq9K+4x9Ljn8xVdp7xE9qTKGF2qqFl Ot2RcUWp6NS3f2gTWVR645moeUwD/Fr+LMVl5vABh6Pi63j0XhBtCINXg7wrHfOmwBvO FUFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=XHQXmqxHeWpd8OXnf/8HM51by6gwtLJcxhrxbZ3GwFA=; fh=4JpYorXNMK/p/rF09/wolDXhjFlfu0I5aRpS+MNqCUM=; b=f5/H3JpI3aaqLl7rC3IT312U3tvCayAM1wAzubOnhurhr1Icgfmq3m+hZQOEeOSEyg wGC8HwVosRUF9ZwBeO//LQGKjHHcPWy3h7mMoBNwvGn30321Zazu8O3GmvDa3cxpgdkR TuKE5byFfacTZvn7BAGUngjubz37MBKaMjYyewqotsYd9y9Inyj0JoaDhwcX63z/ImfI GhFHFuOXa1qsxQjg/uECn1ONQmruDpBDxyOGJRc1ls5G7oc6GW90G0f0jOq1s0g612lm /2gkt9fyFPlYbjWBBXOavEGg7xTie35apV8/SdGwT82OYVhHBedhfuoq1tHLXcnpzbGs bDNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SdBt74Ka; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-211769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c4a76e46f9si1717370a91.147.2024.06.12.08.19.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 08:19:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SdBt74Ka; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-211769-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 59D19288346 for ; Wed, 12 Jun 2024 15:14:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 230A1181307; Wed, 12 Jun 2024 15:13:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SdBt74Ka" Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 E2A3017F504; Wed, 12 Jun 2024 15:13:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718205184; cv=none; b=TxLOCN862KLWr442vL5xdXUH0rdQ81Gdnw6wzTm/zhTIVcX3lWNHhPPwE8Jzl19C0p//PkAVSMIyKesLQGEdmB9LelOp+SGmOAu1a7DHCZmcAWkw9UOzHlHKC4oYiVt/LeMbht7EywgkDbJglK6NNgR9Q61Plv/4sRYW71MPyCM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718205184; c=relaxed/simple; bh=CI3a4ZTH6QkNb6fo8QvVrdnNkzWsdTGrepojuhjTqcg=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=eGrV1p5+a8G/4QvejpAEHfmilOFurabcTFBNwIIpdkohy2gruf74kO8F2SIt+shoBnKS609A1Zc3ZoHX7qK01gIBi+qmOAisbE9rH1BA10V1UuzXuHjMu2bIqBhq3LBCn6WBxQBOSKN/v26kqsGnttl8B22atkg6TcoD3CaOavo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SdBt74Ka; arc=none smtp.client-ip=209.85.160.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-4415e623653so4632791cf.1; Wed, 12 Jun 2024 08:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718205182; x=1718809982; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=XHQXmqxHeWpd8OXnf/8HM51by6gwtLJcxhrxbZ3GwFA=; b=SdBt74KapjbuSKBX7YwpNEAXKm3gUpfJFyGuE5v9YAEVrYDctykXGsBEXoZSuKgcYc M+ZGEzcxOFX5GQcmCWqKMSS1drco3GyphI5wYO+w8j/cMlwsIkj4jSTWxMeZdI5K1D8D 87u/qjFCA/pbKAJznJe41F94OG+WuzWGoTOIH5sr9mJTsSL0n6q3zX9ByQZd/HYAXbXP UHK1sV8fKAU6I7YmBQe+btnLdKbBOHxBsnKoankODLMS48swxIfpQxI2NrZtKRmBv15p 3WuKSZIRrdkfSpe6cbQVBezb/1pin57YvKnL+UdTXB1sQG1FJek7PPDoFxVu9tTRF+zu MLmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718205182; x=1718809982; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XHQXmqxHeWpd8OXnf/8HM51by6gwtLJcxhrxbZ3GwFA=; b=utFVhfPj+dXDfEJEYGVxNUmlzXUeR1I1wsL5GXATmhCQxKpWy55QmBufTK7c92+fLj 4zeg7uwdL/U7Ao4XvIqJpl4E4KvIPlmfGpTuxd0M2Sgef9TgWvghyaEZzDytvyc/f1uQ dUUicufAqTUNNoAxk7hpCZtbvL4ujSAvhkEoZsmxshgHIiIzYMDdvitiRZPdKCL91mdy Ra8S5TV8V4M9+hoB9+Rl7pMcE0KM0oCry/rk4ZqFFrVsl09CziwjHfn1LyceM6z30Syk Ei0v0Mw0VKHfcdhseKmHN/dH7aaYtn4eV0wf+gG7QcXrbDl6SxQqGZbdmk393ZPx0UEX Zz3w== X-Forwarded-Encrypted: i=1; AJvYcCVGEXCxiM1f++kTqWlWRd8rF2aOaPLVs+BuaA41V3/7qKADqXvCky2r/sdLx+clc7Jg/j5uprwCc48nQC6ooJTDZhYSynj/K8Pq1AZnBKe+QFO51HImfsaFXQgrxEb3t/iy/j8L5EmF7Q== X-Gm-Message-State: AOJu0Yyk9t09yTdjXTQCQuWE13jPJ1hghtg8bWCMlQqteuSg9uhdq8zo 9YyjDCNUMRYPLUJ0fVkefXN9E71xeANTePLA/2VxuINqLeZcbbFI X-Received: by 2002:a05:622a:148c:b0:43f:ee8c:b2e with SMTP id d75a77b69052e-44159b68890mr34943721cf.29.1718205181674; Wed, 12 Jun 2024 08:13:01 -0700 (PDT) Received: from [0.0.0.0] (97.64.23.41.16clouds.com. [97.64.23.41]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4403895aa9asm56189961cf.7.2024.06.12.08.12.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Jun 2024 08:13:01 -0700 (PDT) Message-ID: <68b4dbc5-18ee-4dc7-85da-dd420df9bf16@gmail.com> Date: Wed, 12 Jun 2024 23:12:56 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 2/3] scsi: scsi_error: Fix wrong statistic when print error info To: Hannes Reinecke , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240605091731.3111195-1-haowenchao22@gmail.com> <20240605091731.3111195-3-haowenchao22@gmail.com> <15f0fb9b-3b30-413d-9f30-81c246b6bae1@suse.de> Content-Language: en-US From: Wenchao Hao In-Reply-To: <15f0fb9b-3b30-413d-9f30-81c246b6bae1@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 6/12/24 4:34 PM, Hannes Reinecke wrote: > On 6/5/24 11:17, Wenchao Hao wrote: >> shost_for_each_device() would skip devices which is in progress of >> removing, so commands of these devices would be ignored in >> scsi_eh_prt_fail_stats(). >> >> Fix this issue by using shost_for_each_device_include_deleted() >> to iterate devices in scsi_eh_prt_fail_stats(). >> >> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") >> Signed-off-by: Wenchao Hao >> --- >>   drivers/scsi/scsi_error.c | 2 +- >>   1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c >> index 612489afe8d2..a61fd8af3b1f 100644 >> --- a/drivers/scsi/scsi_error.c >> +++ b/drivers/scsi/scsi_error.c >> @@ -409,7 +409,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost, >>       int cmd_cancel = 0; >>       int devices_failed = 0; >>   -    shost_for_each_device(sdev, shost) { >> +    shost_for_each_device_include_deleted(sdev, shost) { >>           list_for_each_entry(scmd, work_q, eh_entry) { >>               if (scmd->device == sdev) { >>                   ++total_failures; > > That is wrong. We should rather add a failure counter to the SCSI host, and have the scsi device increase it every time a failure occurs. > Then we can avoid this loop completely. > This function would print the total failure commands and the number of device like following: scsi host4: Total of 3 commands on 2 devices require eh work Just add a failure counter to the SCSI host can not record the number of devices. > Cheers, > > Hannes