public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] scsi: Check the SPC version in sd_read_cpr
@ 2024-07-20 15:00 Yohan Joung
  2024-07-23  0:49 ` Martin K. Petersen
  0 siblings, 1 reply; 4+ messages in thread
From: Yohan Joung @ 2024-07-20 15:00 UTC (permalink / raw)
  To: James.Bottomley, martin.petersen; +Cc: linux-scsi, Yohan Joung

Add SPC version verification to avoid unnecessary inquiry command

Signed-off-by: Yohan Joung <yohan.joung@sk.com>
---
 drivers/scsi/sd.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6203915945a4..9d71ad24d8e3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3413,11 +3413,16 @@ static inline sector_t sd64_to_sectors(struct scsi_disk *sdkp, u8 *buf)
 static void sd_read_cpr(struct scsi_disk *sdkp)
 {
 	struct blk_independent_access_ranges *iars = NULL;
+	struct scsi_device *sdev = sdkp->device;
 	unsigned char *buffer = NULL;
 	unsigned int nr_cpr = 0;
 	int i, vpd_len, buf_len = SD_BUF_SIZE;
 	u8 *desc;
 
+	/* Support for CPR was defined in SPC-5. */
+	if (sdev->scsi_level < SCSI_SPC_5)
+		return;
+
 	/*
 	 * We need to have the capacity set first for the block layer to be
 	 * able to check the ranges.
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] scsi: Check the SPC version in sd_read_cpr
  2024-07-20 15:00 [PATCH v1] scsi: Check the SPC version in sd_read_cpr Yohan Joung
@ 2024-07-23  0:49 ` Martin K. Petersen
  2024-07-23  0:57   ` Damien Le Moal
  2024-07-23  2:08   ` Damien Le Moal
  0 siblings, 2 replies; 4+ messages in thread
From: Martin K. Petersen @ 2024-07-23  0:49 UTC (permalink / raw)
  To: Yohan Joung
  Cc: James.Bottomley, martin.petersen, linux-scsi, Yohan Joung,
	Damien Le Moal


Yohan,

> Add SPC version verification to avoid unnecessary inquiry command

Are you experiencing an actual error condition as a result of this
INQUIRY operation?

Devices often adopt new protocol features prior to the spec being
finalized. Therefore we generally use INQUIRY to discover capabilities
rather than relying on the reported spec compliance.

> +	/* Support for CPR was defined in SPC-5. */
> +	if (sdev->scsi_level < SCSI_SPC_5)
> +		return;
> +

I'm OK with the change but I'll defer to Damien as to whether this is an
acceptable heuristic.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] scsi: Check the SPC version in sd_read_cpr
  2024-07-23  0:49 ` Martin K. Petersen
@ 2024-07-23  0:57   ` Damien Le Moal
  2024-07-23  2:08   ` Damien Le Moal
  1 sibling, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2024-07-23  0:57 UTC (permalink / raw)
  To: Martin K. Petersen, Yohan Joung; +Cc: James.Bottomley, linux-scsi, Yohan Joung

On 7/23/24 09:49, Martin K. Petersen wrote:
> 
> Yohan,
> 
>> Add SPC version verification to avoid unnecessary inquiry command
> 
> Are you experiencing an actual error condition as a result of this
> INQUIRY operation?
> 
> Devices often adopt new protocol features prior to the spec being
> finalized. Therefore we generally use INQUIRY to discover capabilities
> rather than relying on the reported spec compliance.
> 
>> +	/* Support for CPR was defined in SPC-5. */
>> +	if (sdev->scsi_level < SCSI_SPC_5)
>> +		return;
>> +
> 
> I'm OK with the change but I'll defer to Damien as to whether this is an
> acceptable heuristic.

If this is solving an issue with an ATA device managed by libata, we can handle
that in libata. Otherwise, if this is an ATA device connected to a SAS HBA or a
SAS drive, then the issue could be with the HBA.

I missed this patch so I am not aware of the actual issue this is trying to solve...

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v1] scsi: Check the SPC version in sd_read_cpr
  2024-07-23  0:49 ` Martin K. Petersen
  2024-07-23  0:57   ` Damien Le Moal
@ 2024-07-23  2:08   ` Damien Le Moal
  1 sibling, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2024-07-23  2:08 UTC (permalink / raw)
  To: Martin K. Petersen, Yohan Joung; +Cc: James.Bottomley, linux-scsi, Yohan Joung

On 7/23/24 09:49, Martin K. Petersen wrote:
> 
> Yohan,
> 
>> Add SPC version verification to avoid unnecessary inquiry command
> 
> Are you experiencing an actual error condition as a result of this
> INQUIRY operation?
> 
> Devices often adopt new protocol features prior to the spec being
> finalized. Therefore we generally use INQUIRY to discover capabilities
> rather than relying on the reported spec compliance.
> 
>> +	/* Support for CPR was defined in SPC-5. */
>> +	if (sdev->scsi_level < SCSI_SPC_5)
>> +		return;
>> +
> 
> I'm OK with the change but I'll defer to Damien as to whether this is an
> acceptable heuristic.

By the way, that may not be adequate as ATA devices that implement CPR may
advertise an ACS version that does not translate to SPC-5, which is exactly the
point you said.

-- 
Damien Le Moal
Western Digital Research


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-07-23  2:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-20 15:00 [PATCH v1] scsi: Check the SPC version in sd_read_cpr Yohan Joung
2024-07-23  0:49 ` Martin K. Petersen
2024-07-23  0:57   ` Damien Le Moal
2024-07-23  2:08   ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox