From: Konstantin Khorenko <khore...@virtuozzo.com>

Don't flood logs with messages like
"sd 1:0:0:0: rejecting I/O to offline device".

On one hand this flooding is not useful for investigations,
on anothre hand it can make serial console to feed up.

https://jira.sw.ru/browse/PSBM-100118

Signed-off-by: Konstantin Khorenko <khore...@virtuozzo.com>

(cherry-picked from vz7 commit 734978dda643 ("scsi: ratelimit messages about
rejected I/O"))

https://jira.sw.ru/browse/PSBM-127849
Signed-off-by: Valeriy Vdovin <valeriy.vdo...@virtuozzo.com>

gorcunov@:
 - (cherry-picked from commit 75fde78a1d9 ("scsi: ratelimit messages about
   rejected I/O")
 - the name of routine has been changed to scsi_device_state_check
   so had to apply the commit manually

Signed-off-by: Cyrill Gorcunov <gorcu...@virtuozzo.com>
---
 drivers/scsi/scsi_lib.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 7456a26aef51..632a1cddbf22 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1178,6 +1178,8 @@ static blk_status_t scsi_setup_scsi_cmnd(struct 
scsi_device *sdev,
 static blk_status_t
 scsi_device_state_check(struct scsi_device *sdev, struct request *req)
 {
+       static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 10);
+
        switch (sdev->sdev_state) {
        case SDEV_CREATED:
                return BLK_STS_OK;
@@ -1190,8 +1192,10 @@ scsi_device_state_check(struct scsi_device *sdev, struct 
request *req)
                 */
                if (!sdev->offline_already) {
                        sdev->offline_already = true;
-                       sdev_printk(KERN_ERR, sdev,
-                                   "rejecting I/O to offline device\n");
+                       if (__ratelimit(&ratelimit)) {
+                               sdev_printk(KERN_ERR, sdev,
+                                       "rejecting I/O to offline device\n");
+                       }
                }
                return BLK_STS_IOERR;
        case SDEV_DEL:
@@ -1199,8 +1203,10 @@ scsi_device_state_check(struct scsi_device *sdev, struct 
request *req)
                 * If the device is fully deleted, we refuse to
                 * process any commands as well.
                 */
-               sdev_printk(KERN_ERR, sdev,
-                           "rejecting I/O to dead device\n");
+               if (__ratelimit(&ratelimit)) {
+                       sdev_printk(KERN_ERR, sdev,
+                               "rejecting I/O to dead device\n");
+               }
                return BLK_STS_IOERR;
        case SDEV_BLOCK:
        case SDEV_CREATED_BLOCK:
-- 
2.31.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to