diff mbox series

scsi: sd: only print initial write protect status if enabled

Message ID 20210716193140.25591-1-jpittman@redhat.com
State New
Headers show
Series scsi: sd: only print initial write protect status if enabled | expand

Commit Message

John Pittman July 16, 2021, 7:31 p.m. UTC
Having a write protect status of zero is generally the assumed
state when a scsi attached disk is presented to the kernel. For
this reason, only print the state of write protect if it is
enabled. If the user needs the write protect status, sysfs can
easily be checked after boot. As an additional positive
consequence, this change will decrease the chattiness of scsi
scan logging which has been shown to overwhelm systems when
thousands of sd devices are attached.

Signed-off-by: John Pittman <jpittman@redhat.com>
Reviewed-by: Laurence Oberman <loberman@redhat.com>
---
 drivers/scsi/sd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index b8d55af763f9..30c549cdf35f 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2702,8 +2702,8 @@  sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
 		sdkp->write_prot = ((data.device_specific & 0x80) != 0);
 		set_disk_ro(sdkp->disk, sdkp->write_prot);
 		if (sdkp->first_scan || old_wp != sdkp->write_prot) {
-			sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n",
-				  sdkp->write_prot ? "on" : "off");
+			if (sdkp->write_prot)
+				sd_printk(KERN_NOTICE, sdkp, "Write Protect is on");
 			sd_printk(KERN_DEBUG, sdkp, "Mode Sense: %4ph\n", buffer);
 		}
 	}