mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* scsi: Add diagnostic log for scsi device reset
@ 2021-01-07 11:43 lijinlin
  2021-01-07 16:49 ` James Bottomley
  0 siblings, 1 reply; 2+ messages in thread
From: lijinlin @ 2021-01-07 11:43 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, jejb, martin.petersen; +Cc: linfeilong, liuzhiqiang26

From: lijinlin <lijinlin3@huawei.com>

For enhancing diagnosis capability when scsi device reset,we direct print
these logs which are infrequently printed, and add disk name to logs.

logs as follow:
[  550.268049] sd 3:0:0:0: [sdc] Sending device reset
[  550.268053] sd 3:0:0:0: [sdc] Sending target reset
[  550.268055] sd 3:0:0:0: [sdc] Sending bus reset
[  550.268056] sd 3:0:0:0: [sdc] Sending host reset

Signed-off-by: lijinlin <lijinlin3@huawei.com>
---
 drivers/scsi/scsi_error.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index f11f51e..3e62ade 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1507,9 +1507,10 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
 		if (!bdr_scmd)
 			continue;
 
-		SCSI_LOG_ERROR_RECOVERY(3,
+		if (bdr_scmd->request && bdr_scmd->request->rq_disk)
 			sdev_printk(KERN_INFO, sdev,
-				     "%s: Sending BDR\n", current->comm));
+				     "[%s] Sending device reset\n",
+				     bdr_scmd->request->rq_disk->disk_name);
 		rtn = scsi_try_bus_device_reset(bdr_scmd);
 		if (rtn == SUCCESS || rtn == FAST_IO_FAIL) {
 			if (!scsi_device_online(sdev) ||
@@ -1570,10 +1571,10 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost,
 		scmd = list_entry(tmp_list.next, struct scsi_cmnd, eh_entry);
 		id = scmd_id(scmd);
 
-		SCSI_LOG_ERROR_RECOVERY(3,
-			shost_printk(KERN_INFO, shost,
-				     "%s: Sending target reset to target %d\n",
-				     current->comm, id));
+		if (scmd->device && scmd->request && scmd->request->rq_disk)
+			sdev_printk(KERN_INFO, scmd->device,
+				     "[%s] Sending target reset\n",
+				     scmd->request->rq_disk->disk_name);
 		rtn = scsi_try_target_reset(scmd);
 		if (rtn != SUCCESS && rtn != FAST_IO_FAIL)
 			SCSI_LOG_ERROR_RECOVERY(3,
@@ -1644,10 +1645,11 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
 
 		if (!chan_scmd)
 			continue;
-		SCSI_LOG_ERROR_RECOVERY(3,
-			shost_printk(KERN_INFO, shost,
-				     "%s: Sending BRST chan: %d\n",
-				     current->comm, channel));
+		if (chan_scmd->device && chan_scmd->request
+			&& chan_scmd->request->rq_disk)
+			sdev_printk(KERN_INFO, chan_scmd->device,
+				     "[%s] Sending bus reset\n",
+				     chan_scmd->request->rq_disk->disk_name);
 		rtn = scsi_try_bus_reset(chan_scmd);
 		if (rtn == SUCCESS || rtn == FAST_IO_FAIL) {
 			list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
@@ -1688,11 +1690,10 @@ static int scsi_eh_host_reset(struct Scsi_Host *shost,
 		scmd = list_entry(work_q->next,
 				  struct scsi_cmnd, eh_entry);
 
-		SCSI_LOG_ERROR_RECOVERY(3,
-			shost_printk(KERN_INFO, shost,
-				     "%s: Sending HRST\n",
-				     current->comm));
-
+		if (scmd->device && scmd->request && scmd->request->rq_disk)
+			sdev_printk(KERN_INFO, scmd->device,
+				     "[%s] Sending host reset\n",
+				     scmd->request->rq_disk->disk_name);
 		rtn = scsi_try_host_reset(scmd);
 		if (rtn == SUCCESS) {
 			list_splice_init(work_q, &check_list);
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: scsi: Add diagnostic log for scsi device reset
  2021-01-07 11:43 scsi: Add diagnostic log for scsi device reset lijinlin
@ 2021-01-07 16:49 ` James Bottomley
  0 siblings, 0 replies; 2+ messages in thread
From: James Bottomley @ 2021-01-07 16:49 UTC (permalink / raw)
  To: lijinlin, linux-scsi, linux-kernel, martin.petersen
  Cc: linfeilong, liuzhiqiang26

On Thu, 2021-01-07 at 19:43 +0800, lijinlin wrote:
[...]
> -		SCSI_LOG_ERROR_RECOVERY(3,
> +		if (bdr_scmd->request && bdr_scmd->request->rq_disk)
>  			sdev_printk(KERN_INFO, sdev,
> -				     "%s: Sending BDR\n", current-
> >comm));
> +				     "[%s] Sending device reset\n",
> +				     bdr_scmd->request->rq_disk-
> >disk_name);

Not everything is a SCSI disk.  If we apply this patch, we lose traces
for any non-disk device that get reset ... for tapes this can be really
important to know.

James



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-07 16:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 11:43 scsi: Add diagnostic log for scsi device reset lijinlin
2021-01-07 16:49 ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®