• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to enable additional scsi logging in CentOS/RHEL

By admin

Question: How to turn on scsi extended debug messages? What are the field/flag definitions of scsi_logging_level?

Additional scsi logging messages can be enabled by writing to /proc/sys/dev/scsi/logging_level either via use of the echo or preferably the sysctl command. The kernel parameter consists of ten packed fields, each 3 bits in length. Each field can have a value of 0 to 7. The higher the field’s value, the more verbose the logging of messages associated with that field type.

NOTE: Turning on high levels of extended logging and/or multiple types of extended logging can slow down system performance, especially during boot and shutdown. Unless needed, avoid turning on scsi logging during boot up.

Run Time

1. Enable :

# sysctl -q -w dev.scsi.logging_level=[N]

or

# echo [N] > /proc/sys/dev/scsi/logging_level

Where N specifies which fields to enable and at what level of verbosity.

2. Disable:

# sysctl -q -w dev.scsi.logging_level=0

or

# echo 0 > /proc/sys/dev/scsi/logging_level

Boot Time

Enable (CentOS/RHEL 5)

1. Modify /etc/modprobe.conf with “options scsi_mod scsi_logging_level=N“.

2. Rebuild the initrd image file to pick up the new /etc/modprobe.conf file.

CentOS / RHEL 5 : How to rebuild Initial Ramdisk Image

3. Edit the boot line in /boot/grub/grub.conf, remove ‘quiet‘ if present, add either ‘debug‘ or ‘loglevel=10‘ (they both do the same thing). Also add ‘log_buf_len=8M‘ to increase the kernel’s log fifo size since the additional logging will be creating a lot more messages.

4. Reboot and capture the messages output.

# shutdown -r now

Enable (CentOS/RHEL 6)

1. Edit the boot line in /boot/grub/grub.conf and add “scsi_logging_level=N“.

2. Edit the boot line and remove ‘quiet‘ if present, add either ‘debug‘ or ‘loglevel=10‘ (they both do the same thing). Also add ‘log_buf_len=8M‘ to increase the kernel’s log fifo size since the additional logging will be creating a lot more messages.

3. Reboot and capture the messages output:

# shutdown -r now

Enable (CentOS/RHEL 7 & 8)

1. Edit the “GRUB_CMDLINE_LINUX” line in /etc/default/grub and add “scsi_logging_level=N“.

2. Edit the “GRUB_CMDLINE_LINUX” line and remove ‘quiet‘ if present, add either ‘debug‘ or ‘loglevel=10‘(they both do the same thing). Also add ‘log_buf_len=8M‘ to increase the kernel’s log fifo size since the additional logging will be creating a lot more messages.

3. Changes to /etc/default/grub requires rebuilding of grub.cfg file.

# grub2-mkconfig -o /boot/grub2/grub.cfg

4. Reboot and capture the messages output.

# shutdown -r now

What the above flags do is to up the scsi extended logging level to include lots of info upon errors and timeouts and during scan processing plus upon any io completing off the high level queue. To manually create a mask value, please refer scsi_logging.h and choose which fields you would like to enable.

/*
* This defines the scsi logging feature. It is a means by which the user
* can select how much information they get about various goings on, and it
* can be really useful for fault tracing. The logging word is divided into
* 8 nibbles, each of which describes a loglevel. The division of things is
* somewhat arbitrary, and the division of the word could be changed if it
* were really needed for any reason. The numbers below are the only place
* where these are specified. For a first go-around, 3 bits is more than
* enough, since this gives 8 levels of logging (really 7, since 0 is always
* off).
*/
#define SCSI_LOG_ERROR_SHIFT 0
#define SCSI_LOG_TIMEOUT_SHIFT 3
#define SCSI_LOG_SCAN_SHIFT 6
#define SCSI_LOG_MLQUEUE_SHIFT 9
#define SCSI_LOG_MLCOMPLETE_SHIFT 12
#define SCSI_LOG_LLQUEUE_SHIFT 15
#define SCSI_LOG_LLCOMPLETE_SHIFT 18
#define SCSI_LOG_HLQUEUE_SHIFT 21
#define SCSI_LOG_HLCOMPLETE_SHIFT 24
#define SCSI_LOG_IOCTL_SHIFT 27
#define SCSI_LOG_ERROR_BITS 3 /* additional logging associated with errors and recovery */
#define SCSI_LOG_TIMEOUT_BITS 3 /* additional logging associated with command timeouts */
#define SCSI_LOG_SCAN_BITS 3 /* additional logging associated with device scans and discovery */
#define SCSI_LOG_MLQUEUE_BITS 3 /* additional logging associated with mid-level command queueing */
#define SCSI_LOG_MLCOMPLETE_BITS 3 /* additional logging associated with mid-level command completions */
#define SCSI_LOG_LLQUEUE_BITS 3 /* additional logging associated with low-level command queueing */
#define SCSI_LOG_LLCOMPLETE_BITS 3 /* additional logging associated with low-level command completions */
#define SCSI_LOG_HLQUEUE_BITS 3 /* additional logging associated with hi-level command queueing */
#define SCSI_LOG_HLCOMPLETE_BITS 3 /* additional logging associated with hi-level command completions */
#define SCSI_LOG_IOCTL_BITS 3 /* additional logging associated with ioctl (typ: non-data commands) */
extern unsigned int scsi_logging_level;

To turn on maximum logging associated with ioctls and errors for example, an octal value of 7000000007 (0x38000007) would be set via ‘sysctl -q -w dev.scsi.logging_level=0x38000007‘. Conversely, if ‘sysctl -q dev.scsi.logging_level’ was used to query the current set value and was returned 402653425 (0x180000F1 or octal 3000000361), then currently the field masks have ioctl=3, scan=3, timeout=6, and error=1 values set.

Filed Under: CentOS/RHEL 5, CentOS/RHEL 6, CentOS/RHEL 7, CentOS/RHEL 8, Linux

Some more articles you might also be interested in …

  1. How to set udev rule for setting the disk permission on ASM disks when using multipath on CentOS/RHEL 6
  2. RHEL 7 – RHCSA Notes : Configure a system to use time services
  3. How to enable bind query logging to find out Who’s Querying a Name Server
  4. Change default kernel (boot with old kernel) in CentOS/RHEL/OEL 5 and 6
  5. How to Move Swap From Disk Partition to LVM Volume in Linux
  6. Can’t start X11 applications after “su” or “su -” to another user
  7. Linux OS Service ‘cpuspeed’
  8. How to find if NUMA configuration is enabled or disabled?
  9. Understanding DM-multipath deamon (multipathd)
  10. How to Create yum Repository in CentOS/RHEL

You May Also Like

Primary Sidebar

Recent Posts

  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • How to Capture More Logs in /var/log/dmesg for CentOS/RHEL
  • Unable to Start RDMA Services on CentOS/RHEL 7
  • How to rename a KVM VM with virsh
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary