Re: çå: Re: [PATCH] scsi: Replace sdev_printk with printk_deferred to avoid

From: Sergey Senozhatsky
Date: Tue Mar 27 2018 - 22:44:34 EST


On (03/28/18 10:29), wen.yang99@xxxxxxxxxx wrote:
> Hello Bart,
>
> We have a detailed discussion of the problem.
> Sergey Senozhatsky, Petr and many people have made a lot of efforts about
> it.
> Please see this link:
> https://bugzilla.kernel.org/show_bug.cgi?id=199003
>
> 1, Petr suggests that it should be modified in this way:
> IMHO, printing the same message so many times is useless. Therefore
> some throttling would make sense. If we want to keep sdev_printk(),

The thing with retelimiting is that - yes, we do less printks but we still
do them under queue spin_lock.

So I was thinking about something like below [a quick-n-dirty workaround]

---

drivers/scsi/scsi_lib.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0dfec0dedd5e..6c930fbdd24c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1825,9 +1825,13 @@ static void scsi_request_fn(struct request_queue *q)
break;

if (unlikely(!scsi_device_online(sdev))) {
+ scsi_kill_request(req, q);
+ spin_unlock_irq(q->queue_lock);
+
sdev_printk(KERN_ERR, sdev,
"rejecting I/O to offline device\n");
- scsi_kill_request(req, q);
+
+ spin_lock_irq(q->queue_lock);
continue;
}