[PATCH] scsi: sd: only print initial write protect status if enabled

DORMANTno replies REVIEWED: 1 (0M)

From: John Pittman <hidden>
Date: 2021-07-16 19:31:50
Subsystem: scsi subsystem, the rest · Maintainers: "James E.J. Bottomley", "Martin K. Petersen", Linus Torvalds

1 review trailer.

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 <redacted>
Reviewed-by: Laurence Oberman <redacted>
---
 drivers/scsi/sd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
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);
 		}
 	}
-- 
2.17.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help