scsi: sd: Make sd_spinup_disk() less noisy

sd_spinup_disk() is a little bit noisy after commit 848ade90ba ("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 previously set.

Link: https://lore.kernel.org/r/a2d0a249-6035-9697-626a-e14ec50ef6ee@gmail.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Heiner Kallweit 2021-09-11 14:11:59 +02:00 committed by Martin K. Petersen
parent 1cbc9ad3ee
commit 4521428c48
1 changed files with 4 additions and 1 deletions

View File

@ -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;
}