diff mbox series

scsi: sd: Make sd_spinup_disk less noisy

Message ID a2d0a249-6035-9697-626a-e14ec50ef6ee@gmail.com (mailing list archive)
State Accepted
Headers show
Series scsi: sd: Make sd_spinup_disk less noisy | expand

Commit Message

Heiner Kallweit Sept. 11, 2021, 12:11 p.m. UTC
For my personal taste sd_spinup_disk() is a little bit noisy after
848ade90ba9c ("scsi: sd: Do not exit sd_spinup_disk() quietly").

scsi 0:0:0:0: Direct-Access     Multiple Card  Reader     1.00 PQ: 0 ANSI: 0
sd 0:0:0:0: Attached scsi generic sg0 type 0
sd 0:0:0:0: [sda] Media removed, stopped polling
sd 0:0:0:0: [sda] Media removed, stopped polling
sd 0:0:0:0: [sda] Attached SCSI removable disk
sd 0:0:0:0: [sda] Media removed, stopped polling

There's not really a benefit in printing the same message multiple
times. Therefore print it only if media_present was set before.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/scsi/sd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Bart Van Assche Sept. 11, 2021, 9:38 p.m. UTC | #1
On 9/11/21 05:11, Heiner Kallweit wrote:
> For my personal taste sd_spinup_disk() is a little bit noisy after
> 848ade90ba9c ("scsi: sd: Do not exit sd_spinup_disk() quietly").

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Martin K. Petersen Sept. 14, 2021, 4:40 a.m. UTC | #2
On Sat, 11 Sep 2021 14:11:59 +0200, Heiner Kallweit wrote:

> For my personal taste sd_spinup_disk() is a little bit noisy after
> 848ade90ba9c ("scsi: sd: Do not exit sd_spinup_disk() quietly").
> 
> scsi 0:0:0:0: Direct-Access     Multiple Card  Reader     1.00 PQ: 0 ANSI: 0
> sd 0:0:0:0: Attached scsi generic sg0 type 0
> sd 0:0:0:0: [sda] Media removed, stopped polling
> sd 0:0:0:0: [sda] Media removed, stopped polling
> sd 0:0:0:0: [sda] Attached SCSI removable disk
> sd 0:0:0:0: [sda] Media removed, stopped polling
> 
> [...]

Applied to 5.15/scsi-fixes, thanks!

[1/1] scsi: sd: Make sd_spinup_disk less noisy
      https://git.kernel.org/mkp/scsi/c/4521428c4811
diff mbox series

Patch

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index cbd9999f9..af7e7b0da 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2124,6 +2124,8 @@  sd_spinup_disk(struct scsi_disk *sdkp)
 		retries = 0;
 
 		do {
+			bool media_was_present = sdkp->media_present;
+
 			cmd[0] = TEST_UNIT_READY;
 			memset((void *) &cmd[1], 0, 9);
 
@@ -2138,7 +2140,8 @@  sd_spinup_disk(struct scsi_disk *sdkp)
 			 * with any more polling.
 			 */
 			if (media_not_present(sdkp, &sshdr)) {
-				sd_printk(KERN_NOTICE, sdkp, "Media removed, stopped polling\n");
+				if (media_was_present)
+					sd_printk(KERN_NOTICE, sdkp, "Media removed, stopped polling\n");
 				return;
 			}