scsi_mod: Add a new parameter to scsi_mod to control storage logging
Subsystems (2)
PATCH 1/1 scsi_mod: Add a new parameter to scsi_mod to control storage logging
This new parameter storage_quiet_discovery defaults to 0 and behavior is unchanged. If its set to 1 on the kernel line then sd_printk and sdev_printk are disabled for printing. The default logging can be re-enabled any time after boot using /etc/sysctl.conf by setting dev.scsi.storage_quiet_discovery = 0.
systctl -w dev.scsi.storage_quiet_discovery=0 will also change it immediately back to logging.
Users can leave it set to 1 on the kernel line and 0 in the conf file so it changes back to default after rc.sysinit.
This solves the tough problem of systems with 1000's of storage LUNS consuming a system and preventing it from booting due to NMI's and timeouts.
--- Documentation/scsi/scsi-parameters.rst | 16 ++++++++++++++++ drivers/scsi/scsi.c | 6 ++++++ drivers/scsi/scsi_sysctl.c | 5 +++++ drivers/scsi/sd.h | 11 ++++++++--- include/scsi/scsi_device.h | 8 ++++++-- 5 files changed, 41 insertions(+), 5 deletions(-)
Documentation/scsi/scsi-parameters.rst +16 -0
@@ -93,6 +93,22 @@ parameters may be changed at runtime by the command S390-tools package, available for download at https://github.com/ibm-s390-linux/s390-tools/blob/master/scripts/scsi_logging_level + scsi_mod.storage_quiet_discovery= + [SCSI] a parameter to control the printing from + sdev_printk and sd_printk for systems with large + amounts of LUNS. + Defaults to 0 so unchanged behavior. + If scsi_mod.storage_quiet_discovery=1 is added boot line + then the messages are not printed and can be enabled + after boot via + echo 0 > + /sys/module/scsi_mod/parameters/storage_quiet_discovery + Another option is using + sysctl -w dev.scsi.storage_quiet_discovery=0. + Leaving this set to 0 in /etc/sysctl.conf and setting + it to 1 on the kernel line will help for these large + LUN count configurations and ensure its back on after boot. + scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are discovered. async scans them in kernel threads, allowing boot to proceed. none ignores them, expecting
drivers/scsi/scsi.c +6 -0
@@ -86,6 +86,9 @@ unsigned int scsi_logging_level;EXPORT_SYMBOL (scsi_logging_level);#endif +int storage_quiet_discovery =0 ; +EXPORT_SYMBOL (storage_quiet_discovery); +/* * Domain for asynchronous system resume operations. It is marked 'exclusive' * to avoid being included in the async_synchronize_full() that is invoked by
@@ -749,6 +752,9 @@ MODULE_LICENSE("GPL");module_param (scsi_logging_level, int,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (scsi_logging_level,"a bit mask of logging levels" ); +module_param (storage_quiet_discovery, int,S_IRUGO |S_IWUSR ); +MODULE_PARM_DESC (storage_quiet_discovery,"If set to 1 will silence SCSI and \ +ALUA discovery logging on boot" );static int __init init_scsi (void ) {
drivers/scsi/scsi_sysctl.c +5 -0
@@ -18,6 +18,11 @@ static struct ctl_table scsi_table[] = { .maxlen = sizeof(scsi_logging_level), .mode = 0644, .proc_handler = proc_dointvec }, + { .procname = "storage_quiet_discovery", + .data = &storage_quiet_discovery, + .maxlen = sizeof(storage_quiet_discovery), + .mode = 0644, + .proc_handler = proc_dointvec }, { } };
drivers/scsi/sd.h +8 -3
@@ -133,11 +133,16 @@ static inline struct scsi_disk *scsi_disk(struct gendisk *disk) return container_of(disk->private_data, struct scsi_disk, driver); } +extern int storage_quiet_discovery; + #define sd_printk(prefix, sdsk, fmt, a...) \ - (sdsk)->disk ? \ - sdev_prefix_printk(prefix, (sdsk)->device, \ + do { \ + if (!storage_quiet_discovery) \ + (sdsk)->disk ? \ + sdev_prefix_printk(prefix, (sdsk)->device, \ (sdsk)->disk->disk_name, fmt, ##a) : \ - sdev_printk(prefix, (sdsk)->device, fmt, ##a) + sdev_printk(prefix, (sdsk)->device, fmt, ##a); \ + } while (0) #define sd_first_printk(prefix, sdsk, fmt, a...) \ do { \
include/scsi/scsi_device.h +6 -2
@@ -258,8 +258,12 @@ __printf(4, 5) void sdev_prefix_printk(const char *, const struct scsi_device *, const char *, const char *, ...); -#define sdev_printk(l, sdev, fmt, a...) \ - sdev_prefix_printk(l, sdev, NULL, fmt, ##a) +extern int storage_quiet_discovery; + +#define sdev_printk(l, sdev, fmt, a...) ({ \ + if (!storage_quiet_discovery) \ + sdev_prefix_printk(l, sdev, NULL, fmt, ##a); \ + }) __printf(3, 4) voidscmd_printk (const char *,const struct scsi_cmnd *,const char *, ...);
Signature · 1 line
2.27.0
drivers/scsi/sd.h static inline struct scsi_disk *scsi_disk(struct gendisk *disk) · line 145
Quoted 11 lines · Laurence Oberman
#define
sd_printk(prefix, sdsk, fmt, a...)\drivers/scsi/sd.h +6
-3- (sdsk)->disk ? \ - sdev_prefix_printk(prefix, (sdsk)->device, \ + do { \ + if (!storage_quiet_discovery) \ + (sdsk)->disk ? \ + sdev_prefix_printk(prefix, (sdsk)->device, \ (sdsk)->disk->disk_name, fmt, ##a) : \ - sdev_printk(prefix, (sdsk)->device, fmt, ##a) + sdev_printk(prefix, (sdsk)->device, fmt, ##a); \ + } while (0)
The indentation inside the above macro looks odd to me. I guess that you want to avoid deep indentation? Consider using if (...) break; instead to reduce the indentation level. Additionally, please change the ternary operator into an if-condition since the result of the ternary operator is not used. How about rewriting the above macro as follows?
do {
if (storage_quiet_discovery)
break;
if ((sdk)->disk)
[ ... ]
else
[ ... ]
} while (0)Thanks,
Bart.
Quoted 39 lines · Bart Van Assche
Quoted 17 lines · Laurence Oberman
#define
sd_printk(prefix, sdsk, fmt, a...)
\
- (sdsk)->disk ?\(quoted diff) +1
-1- sdev_prefix_printk(prefix, (sdsk)->device, \ + do {\
(quoted diff) +1
-0+ if (!storage_quiet_discovery)\
(quoted diff) +1
-0+ (sdsk)->disk ?\
(quoted diff) +1
-0+ sdev_prefix_printk(prefix, (sdsk)->device, \ (sdsk)->disk->disk_name, fmt, ##a) :\
(quoted diff) +1
-1- sdev_printk(prefix, (sdsk)->device, fmt, ##a) + sdev_printk(prefix, (sdsk)->device, fmt, ##a);\
drivers/scsi/sd.h static inline struct scsi_disk *scsi_disk(struct gendisk *disk) · line 145
Quoted 1 line
drivers/scsi/sd.h +1
-0+ }while (0 )The indentation inside the above macro looks odd to me. I guess that you
want to avoid deep indentation? Consider using if (...) break; instead
to reduce the indentation level. Additionally, please change the ternary
operator into an if-condition since the result of the ternary operator
is not used. How about rewriting the above macro as follows?do { if (storage_quiet_discovery) break; if ((sdk)->disk) [ ... ] else [ ... ] } while (0)
Quoted 4 lines
Thanks,
Bart.
Hi Bart
Yes, Thanks I can try that option for the macro and clean it up. I will wait a bit for others to review so I can attend to all changes at once.
Note that the original version was indented like that too and has the ternary.
See here:
#define sd_printk(prefix, sdsk, fmt,
a...) \
(sdsk)->disk? \
sdev_prefix_printk(prefix, (sdsk)-
Quoted 1 line
device, \
(sdsk)->disk->disk_name, fmt, ##a)
: \
sdev_printk(prefix, (sdsk)->device, fmt, ##a)Quoted 59 lines · Laurence Oberman
Quoted 41 lines · Bart Van Assche
Quoted 18 lines · Laurence Oberman
#define
sd_printk(prefix, sdsk, fmt, a...)\
- (sdsk)->disk ?\(quoted diff) +1
-1- sdev_prefix_printk(prefix, (sdsk)->device, \ + do {\
(quoted diff) +1
-0+ if (!storage_quiet_discovery)\
(quoted diff) +1
-0+ (sdsk)->disk ?\
(quoted diff) +1
-0+ sdev_prefix_printk(prefix, (sdsk)->device, \ (sdsk)->disk->disk_name, fmt, ##a) :\
(quoted diff) +1
-1- sdev_printk(prefix, (sdsk)->device, fmt, ##a) + sdev_printk(prefix, (sdsk)->device, fmt, ##a);\
drivers/scsi/sd.h static inline struct scsi_disk *scsi_disk(struct gendisk *disk) · line 145
Quoted 1 line
drivers/scsi/sd.h +1
-0+ }while (0 )The indentation inside the above macro looks odd to me. I guess that
you
want to avoid deep indentation? Consider using if (...) break; instead
to reduce the indentation level. Additionally, please change the ternary
operator into an if-condition since the result of the ternary operator
is not used. How about rewriting the above macro as follows?do { if (storage_quiet_discovery) break; if ((sdk)->disk) [ ... ] else [ ... ] } while (0)Quoted 4 lines
Thanks,
Bart.
Hi Bart
Yes, Thanks I can try that option for the macro and clean it up. I will wait a bit for others to review so I can attend to all changes at once.Note that the original version was indented like that too and has the ternary.
See here:
#define sd_printk(prefix, sdsk, fmt,a...) \ (sdsk)->disk
Quoted 8 lines
? \
sdev_prefix_printk(prefix, (sdsk)-Quoted 1 line
device, \
(sdsk)->disk->disk_name, fmt, ##a) : \ sdev_printk(prefix, (sdsk)->device, fmt, ##a)
Hi Bart the original macro is the same so I think best not to change it other than the wrapper I added. What are your thoughts.
Gentle ping for any other reviews:
We are actively using this at some customers so it would be good to know if others upstream will NAK this or have any comments.
Sincerely
Laurence Oberman
Quoted 2 lines · Laurence Oberman
Hi Bart the original macro is the same so I think best not to change it other than the wrapper I added. What are your thoughts.
Hi Laurence,
Since the current definition is not optimal from a source code readability standpoint and since this patch changes the sd_printk() definition I think this is a great opportunity to improve that definition. Please note that I don't have a strong opinion about this.
Bart.
John Pittman
Reviewed-byGood morning Laurence. I guess we still need Martin's opinion, but considering how many customers I've had to help get past this, I'd welcome an easy way out. Thanks.
Quoted 14 lines · Bart Van Assche
Quoted 2 lines · Laurence Oberman
Hi Bart the original macro is the same so I think best not to change it other than the wrapper I added. What are your thoughts.
Hi Laurence,
Since the current definition is not optimal from a source code readability standpoint and since this patch changes the
sd_printk()definition I think this is a great opportunity to improve that definition. Please note that I don't have a strong opinion about this.Bart.
Quoted 122 lines · Laurence Oberman
This new parameter
storage_quiet_discoverydefaults to 0 and behavior is unchanged. If its set to 1 on the kernel line thensd_printkandsdev_printkare disabled for printing. The default logging can be re-enabled any time after boot using/etc/sysctl.confby setting dev.scsi.storage_quiet_discovery = 0.
systctl -w dev.scsi.storage_quiet_discovery=0 will also change it immediately back to logging.
Users can leave it set to 1 on the kernel line and 0 in the conf file so it changes back to default after rc.sysinit.
This solves the tough problem of systems with 1000's of storage LUNS consuming a system and preventing it from booting due to NMI's and timeouts.Signed-off-by Laurence Oberman <[email protected]>--- Documentation/scsi/scsi-parameters.rst | 16 ++++++++++++++++ drivers/scsi/scsi.c | 6 ++++++ drivers/scsi/scsi_sysctl.c | 5 +++++ drivers/scsi/sd.h | 11 ++++++++--- include/scsi/scsi_device.h | 8 ++++++-- 5 files changed, 41 insertions(+), 5 deletions(-)Documentation/scsi/scsi-parameters.rst +16
-0@@ -93,6 +93,22 @@ parameters may be changed at runtime by the command S390-tools package, available for download at https://github.com/ibm-s390-linux/s390-tools/blob/master/scripts/scsi_logging_level + scsi_mod.storage_quiet_discovery= + [SCSI] a parameter to control the printing from + sdev_printk and sd_printk for systems with large + amounts of LUNS. + Defaults to 0 so unchanged behavior. + If scsi_mod.storage_quiet_discovery=1 is added boot line + then the messages are not printed and can be enabled + after boot via + echo 0 > + /sys/module/scsi_mod/parameters/storage_quiet_discovery + Another option is using + sysctl -w dev.scsi.storage_quiet_discovery=0. + Leaving this set to 0 in /etc/sysctl.conf and setting + it to 1 on the kernel line will help for these large + LUN count configurations and ensure its back on after boot. + scsi_mod.scan= [SCSI] sync (default) scans SCSI busses as they are discovered. async scans them in kernel threads, allowing boot to proceed. none ignores them, expectingdrivers/scsi/scsi.c +6
-0@@ -86,6 +86,9 @@ unsigned int scsi_logging_level;EXPORT_SYMBOL (scsi_logging_level);#endif +int storage_quiet_discovery =0 ; +EXPORT_SYMBOL (storage_quiet_discovery); +/* * Domain for asynchronous system resume operations. It is marked 'exclusive' * to avoid being included in the async_synchronize_full() that is invoked by @@ -749,6 +752,9 @@ MODULE_LICENSE("GPL");module_param (scsi_logging_level, int,S_IRUGO |S_IWUSR );MODULE_PARM_DESC (scsi_logging_level,"a bit mask of logging levels" ); +module_param (storage_quiet_discovery, int,S_IRUGO |S_IWUSR ); +MODULE_PARM_DESC (storage_quiet_discovery,"If set to 1 will silence SCSI and \ +ALUA discovery logging on boot" );static int __init init_scsi (void ) {drivers/scsi/scsi_sysctl.c +5
-0@@ -18,6 +18,11 @@ static struct ctl_table scsi_table[] = { .maxlen = sizeof(scsi_logging_level), .mode = 0644, .proc_handler = proc_dointvec }, + { .procname = "storage_quiet_discovery", + .data = &storage_quiet_discovery, + .maxlen = sizeof(storage_quiet_discovery), + .mode = 0644, + .proc_handler = proc_dointvec }, { } };drivers/scsi/sd.h +8
-3@@ -133,11 +133,16 @@ static inline struct scsi_disk *scsi_disk(struct gendisk *disk) return container_of(disk->private_data, struct scsi_disk, driver); } +extern int storage_quiet_discovery; + #define sd_printk(prefix, sdsk, fmt, a...) \ - (sdsk)->disk ? \ - sdev_prefix_printk(prefix, (sdsk)->device, \ + do { \ + if (!storage_quiet_discovery) \ + (sdsk)->disk ? \ + sdev_prefix_printk(prefix, (sdsk)->device, \ (sdsk)->disk->disk_name, fmt, ##a) : \ - sdev_printk(prefix, (sdsk)->device, fmt, ##a) + sdev_printk(prefix, (sdsk)->device, fmt, ##a); \ + } while (0) #define sd_first_printk(prefix, sdsk, fmt, a...) \ do { \include/scsi/scsi_device.h +0
-1@@ -258,8 +258,12 @@ __printf(4, 5) void sdev_prefix_printk(const char *, const struct scsi_device *, const char *, const char *, ...); -#define sdev_printk(l, sdev, fmt, a...) \
include/scsi/scsi_device.h __printf(4, 5) void · line 269
Quoted 10 lines
include/scsi/scsi_device.h +6
-1- sdev_prefix_printk(l, sdev, NULL, fmt, ##a) +extern int storage_quiet_discovery; + +#define sdev_printk(l, sdev, fmt, a...) ({ \ + if (!storage_quiet_discovery) \ + sdev_prefix_printk(l, sdev, NULL, fmt, ##a); \ + }) __printf(3, 4) voidscmd_printk (const char *,const struct scsi_cmnd *,const char *, ...);