Skip to contentSkip to conversation

scsi_lib: rate-limit the error message from failing commands

PATCH Superseded Yi Zou 2 participants 5 messages Mar 5, 2012 – Mar 7, 2012 SCSI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yi Zou

author
#0 lore raw

PATCH 1/1 scsi_lib: rate-limit the error message from failing commands

When performing a cable pull test w/ active stress I/O using fio over a dual port Intel 82599 FCoE CNA, w/ 256LUNs on one port and about 32LUNs on the other, it is observed that the system becomes not usable due to scsi-ml being busy printing the error messages for all the failing commands. I don't believe this problem is specific to FCoE and these commands are anyway failing due to link being down (DID_NO_CONNECT), just rate-limit the messages here to solve this issue.

Cc www.Open-FCoE.org <[email protected]>

---

 drivers/scsi/scsi_lib.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/scsi_lib.c +2 -1
index b2c95db..e2128d9 100644
@@ -934,7 +934,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	case ACTION_FAIL:
 		/* Give up and fail the remainder of the request */
 		scsi_release_buffers(cmd);
-		if (!(req->cmd_flags & REQ_QUIET)) {
+		if (!(req->cmd_flags & REQ_QUIET) &&
+		    printk_ratelimit()) {
 			if (description)
 				scmd_printk(KERN_INFO, cmd, "%s\n",
 					    description);
#1 lore raw
Quoted 10 lines · Yi Zou

When performing a cable pull test w/ active stress I/O using fio over a dual port Intel 82599 FCoE CNA, w/ 256LUNs on one port and about 32LUNs on the other, it is observed that the system becomes not usable due to scsi-ml being busy printing the error messages for all the failing commands. I don't believe this problem is specific to FCoE and these commands are anyway failing due to link being down (DID_NO_CONNECT), just rate-limit the messages here to solve this issue.

Cc www.Open-FCoE.org <[email protected]>

Hi Zou,
you shouldn't use printk_ratelimit .
checkpatch says: WARNING: Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit Tomas

Quoted 24 lines

---

 drivers/scsi/scsi_lib.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/scsi_lib.c +2 -2
index b2c95db..e2128d9 100644
@@ -934,7 +934,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
 	case ACTION_FAIL:
 		/* Give up and fail the remainder of the request */
 		scsi_release_buffers(cmd);
-		if (!(req->cmd_flags & REQ_QUIET)) {
+		if (!(req->cmd_flags & REQ_QUIET) &&
+		    printk_ratelimit()) {
 			if (description)
 				scmd_printk(KERN_INFO, cmd, "%s\n",
 					    description);
 
--

To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw
Quoted 12 lines · Yi Zou
Quoted 2 lines

When performing a cable pull test w/ active stress I/O using fio over a dual port Intel 82599 FCoE CNA, w/ 256LUNs on one port and about

32LUNs

Quoted 2 lines

on the other, it is observed that the system becomes not usable due to scsi-ml being busy printing the error messages for all the failing

commands.

Quoted 4 lines

I don't believe this problem is specific to FCoE and these commands are anyway failing due to link being down (DID_NO_CONNECT), just rate-limit the messages here to solve this issue.

Quoted 7 lines
Quoted 2 lines
Cc www.Open-FCoE.org <[email protected]>

Hi Zou,
you shouldn't use printk_ratelimit . checkpatch says: WARNING: Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit Tomas

Yes, I saw that when I did the checkpatch, but pratek_ratelimit() actually serves the purpose better, as it guards the block of the several scsi related prints that follow, and this works well particularly for this bug. For the worst case, the shared ratelimit surpresses everything here, blk i/o error report would still be able pick up printing something.

If it is desired, which I doubt, I could change all scmd_printk, scsi_print_xxxx calls to use printk_ratelimited(), seems an overkill for this to me. I am open for a better solution.

yi

Quoted 32 lines

drivers/scsi/scsi_lib.c void scsi_io_completion(struct scsi_cmnd *cmd,

Quoted 11 lines

---

 drivers/scsi/scsi_lib.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/scsi_lib.c +0 -0
index b2c95db..e2128d9 100644
@@ -934,7 +934,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd,

unsigned int good_bytes)

Quoted 11 lines
drivers/scsi/scsi_lib.c +2 -2
 	case ACTION_FAIL:
 		/* Give up and fail the remainder of the request */
 		scsi_release_buffers(cmd);
-		if (!(req->cmd_flags & REQ_QUIET)) {
+		if (!(req->cmd_flags & REQ_QUIET) &&
+		    printk_ratelimit()) {
 			if (description)
 				scmd_printk(KERN_INFO, cmd, "%s\n",
 					    description);
 
--
Quoted 1 line

To unsubscribe from this list: send the line "unsubscribe linux-scsi"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 24 lines · Yi
Quoted 11 lines · Yi Zou
Quoted 2 lines

When performing a cable pull test w/ active stress I/O using fio over a dual port Intel 82599 FCoE CNA, w/ 256LUNs on one port and about

32LUNs

Quoted 2 lines

on the other, it is observed that the system becomes not usable due to scsi-ml being busy printing the error messages for all the failing

commands.

Quoted 4 lines

I don't believe this problem is specific to FCoE and these commands are anyway failing due to link being down (DID_NO_CONNECT), just rate-limit the messages here to solve this issue.

Quoted 7 lines
Quoted 2 lines
Cc www.Open-FCoE.org <[email protected]>

Hi Zou,
you shouldn't use printk_ratelimit . checkpatch says: WARNING: Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit Tomas

Yes, I saw that when I did the checkpatch, but pratek_ratelimit() actually serves the purpose better, as it guards the block of the several scsi related prints that follow, and this works well particularly for this bug. For the worst case, the shared ratelimit surpresses everything here, blk i/o error report would still be able pick up printing something.

Quoted 3 lines

If it is desired, which I doubt, I could change all scmd_printk, scsi_print_xxxx calls to use printk_ratelimited(), seems an overkill for this to me. I am open for a better solution.

For a whole block of commands you can use __ratelimit, so something like this were possible:

@@ -20,6 +20,7 @@
#include <linux/delay.h>
#include <linux/hardirq.h>
#include <linux/scatterlist.h>
+#include <linux/ratelimit.h>

#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -745,6 +746,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)

        enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
              ACTION_DELAYED_RETRY} action;
        char *description = NULL;

+ static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
+ DEFAULT_RATELIMIT_BURST);

        if (result) {
                sense_valid = scsi_command_normalize_sense(cmd, &sshdr);
@@ -935,7 +938,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
        case ACTION_FAIL:
                /* Give up and fail the remainder of the request */
                scsi_release_buffers(cmd);
-               if (!(req->cmd_flags & REQ_QUIET)) {
+               if (!(req->cmd_flags & REQ_QUIET) &&  __ratelimit(&rs)) {
                        if (description)
                                scmd_printk(KERN_INFO, cmd, "%s\n",
                                            description);yi
Quoted 30 lines
Quoted 30 lines

drivers/scsi/scsi_lib.c void scsi_io_completion(struct scsi_cmnd *cmd,

Quoted 10 lines

---

 drivers/scsi/scsi_lib.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/scsi_lib.c +0 -0
index b2c95db..e2128d9 100644
@@ -934,7 +934,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd,

unsigned int good_bytes)

Quoted 11 lines
drivers/scsi/scsi_lib.c +2 -2
 	case ACTION_FAIL:
 		/* Give up and fail the remainder of the request */
 		scsi_release_buffers(cmd);
-		if (!(req->cmd_flags & REQ_QUIET)) {
+		if (!(req->cmd_flags & REQ_QUIET) &&
+		    printk_ratelimit()) {
 			if (description)
 				scmd_printk(KERN_INFO, cmd, "%s\n",
 					    description);
 
--
Quoted 1 line

To unsubscribe from this list: send the line "unsubscribe linux-scsi"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#4 lore raw
Quoted 70 lines · Yi
Quoted 5 lines
Quoted 5 lines · Yi Zou
Quoted 2 lines

When performing a cable pull test w/ active stress I/O using fio over a dual port Intel 82599 FCoE CNA, w/ 256LUNs on one port and about

32LUNs

Quoted 1 line

on the other, it is observed that the system becomes not usable due

to

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

scsi-ml being busy printing the error messages for all the failing

commands.

Quoted 1 line

I don't believe this problem is specific to FCoE and these commands

are

Quoted 1 line
Quoted 1 line
Quoted 1 line

anyway failing due to link being down (DID_NO_CONNECT), just rate-

limit

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

the messages here to solve this issue.

Cc www.Open-FCoE.org <[email protected]>

Hi Zou,
you shouldn't use printk_ratelimit . checkpatch says: WARNING: Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit Tomas

Yes, I saw that when I did the checkpatch, but pratek_ratelimit()

actually

Quoted 1 line

serves the purpose better, as it guards the block of the several scsi

related

Quoted 1 line

prints that follow, and this works well particularly for this bug. For

the worst

Quoted 1 line

case, the shared ratelimit surpresses everything here, blk i/o error

report

Quoted 3 lines

would still be able pick up printing something.

If it is desired, which I doubt, I could change all scmd_printk,

scsi_print_xxxx

Quoted 1 line

calls to use printk_ratelimited(), seems an overkill for this to me. I

am open

Quoted 1 line

for a better solution.

For a whole block of commands you can use __ratelimit, so something like this
were possible:

(quoted diff) +3 -0
@@ -20,6 +20,7 @@
 #include <linux/delay.h>
 #include <linux/hardirq.h>
 #include <linux/scatterlist.h>
+#include <linux/ratelimit.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -745,6 +746,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd,
 unsigned int good_bytes)
        enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
              ACTION_DELAYED_RETRY} action;
        char *description = NULL;
+       static DEFINE_RATELIMIT_STATE(rs,  DEFAULT_RATELIMIT_INTERVAL,
+                                               DEFAULT_RATELIMIT_BURST);
 
        if (result) {
                sense_valid = scsi_command_normalize_sense(cmd, &sshdr);
drivers/scsi/scsi_lib.c +1 -1
@@ -935,7 +938,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd,
 unsigned int good_bytes)
        case ACTION_FAIL:
                /* Give up and fail the remainder of the request */
                scsi_release_buffers(cmd);
-               if (!(req->cmd_flags & REQ_QUIET)) {
+               if (!(req->cmd_flags & REQ_QUIET) &&  __ratelimit(&rs)) {
                        if (description)
                                scmd_printk(KERN_INFO, cmd, "%s\n",
Quoted 2 lines

description);yi

This looks better, I will resend the patch, which will be pretty much the same what you have here.

thanks.
yi

Quoted 32 lines
Quoted 22 lines
Quoted 22 lines

drivers/scsi/scsi_lib.c void scsi_io_completion(struct scsi_cmnd *cmd,

Quoted 11 lines

---

 drivers/scsi/scsi_lib.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/scsi_lib.c +0 -0
index b2c95db..e2128d9 100644
@@ -934,7 +934,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd,

unsigned int good_bytes)

Quoted 10 lines
drivers/scsi/scsi_lib.c +2 -1
 	case ACTION_FAIL:
 		/* Give up and fail the remainder of the request */
 		scsi_release_buffers(cmd);
-		if (!(req->cmd_flags & REQ_QUIET)) {
+		if (!(req->cmd_flags & REQ_QUIET) &&
+		    printk_ratelimit()) {
 			if (description)
 				scmd_printk(KERN_INFO, cmd, "%s\n",
 					    description);
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi"

in

Quoted 2 lines
Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html