Skip to contentSkip to conversation

scsi: scsi_debug: Make the READ CAPACITY response compliant with ZBC

PATCH Applied Bart Van Assche 4 participants 4 messages Nov 2, 2022 – Nov 8, 2022 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 scsi: scsi_debug: Make the READ CAPACITY response compliant with ZBC

From ZBC-1:
* RC BASIS = 0: The RETURNED LOGICAL BLOCK ADDRESS field indicates the highest LBA of a contiguous range of zones that are not sequential write required zones starting with the first zone.
* RC BASIS = 1: The RETURNED LOGICAL BLOCK ADDRESS field indicates the LBA of the last logical block on the logical unit.

The current scsi_debug READ CAPACITY response does not comply with the above if there are one or more sequential write required zones. SCSI initiators need a way to retrieve the largest valid LBA from SCSI devices. Reporting the largest valid LBA if there are one or more sequential zones requires to set the RC BASIS field in the READ CAPACITY response to one. Hence this patch.

---
Changes between v2 and v3: elaborated the comment added by this patch.

Changes between v1 and v2: simplified this patch as suggested by Damien.

 drivers/scsi/scsi_debug.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/scsi/scsi_debug.c +7 -0
index 697fc57bc711..629853662b82 100644
@@ -1899,6 +1899,13 @@ static int resp_readcap16(struct scsi_cmnd *scp,
 			arr[14] |= 0x40;
 	}
 
+	/*
+	 * Since the scsi_debug READ CAPACITY implementation always reports the
+	 * total disk capacity, set RC BASIS = 1 for host-managed ZBC devices.
+	 */
+	if (devip->zmodel == BLK_ZONED_HM)
+		arr[12] |= 1 << 4;
+
 	arr[15] = sdebug_lowest_aligned & 0xff;
 
 	if (have_dif_prot) {
Reviewed-by on v3 1/1
#1 lore raw
Quoted 34 lines · Bart Van Assche

From ZBC-1:
* RC BASIS = 0: The RETURNED LOGICAL BLOCK ADDRESS field indicates the highest LBA of a contiguous range of zones that are not sequential write required zones starting with the first zone.
* RC BASIS = 1: The RETURNED LOGICAL BLOCK ADDRESS field indicates the LBA of the last logical block on the logical unit.

The current scsi_debug READ CAPACITY response does not comply with the above if there are one or more sequential write required zones. SCSI initiators need a way to retrieve the largest valid LBA from SCSI devices. Reporting the largest valid LBA if there are one or more sequential zones requires to set the RC BASIS field in the READ CAPACITY response to one. Hence this patch.

---
Changes between v2 and v3: elaborated the comment added by this patch.

Changes between v1 and v2: simplified this patch as suggested by Damien.

 drivers/scsi/scsi_debug.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/scsi/scsi_debug.c +0 -0
index 697fc57bc711..629853662b82 100644
@@ -1899,6 +1899,13 @@ static int resp_readcap16(struct scsi_cmnd *scp,
 			arr[14] |= 0x40;
 	}
 

drivers/scsi/scsi_debug.c static int resp_readcap16(struct scsi_cmnd *scp, · line 1911

Quoted 10 lines
drivers/scsi/scsi_debug.c +7 -0
+	/*
+	 * Since the scsi_debug READ CAPACITY implementation always reports the
+	 * total disk capacity, set RC BASIS = 1 for host-managed ZBC devices.
+	 */
+	if (devip->zmodel == BLK_ZONED_HM)
+		arr[12] |= 1 << 4;
+
 	arr[15] = sdebug_lowest_aligned & 0xff;
 
 	if (have_dif_prot) {
Signature · 2 lines
Damien Le Moal
Western Digital Research
Acked-by on v3 1/1
#2 lore raw
In reply to Bart Van Assche
Quoted 14 lines · Bart Van Assche
Quoted 1 line

From ZBC-1:

* RC BASIS = 0: The RETURNED LOGICAL BLOCK ADDRESS field indicates the highest LBA of a contiguous range of zones that are not sequential write required zones starting with the first zone.
* RC BASIS = 1: The RETURNED LOGICAL BLOCK ADDRESS field indicates the LBA of the last logical block on the logical unit.

The current scsi_debug READ CAPACITY response does not comply with the above if there are one or more sequential write required zones. SCSI initiators need a way to retrieve the largest valid LBA from SCSI devices. Reporting the largest valid LBA if there are one or more sequential zones requires to set the RC BASIS field in the READ CAPACITY response to one. Hence this patch.

Quoted 4 lines
Quoted 26 lines

---
Changes between v2 and v3: elaborated the comment added by this patch.

Changes between v1 and v2: simplified this patch as suggested by Damien.

  drivers/scsi/scsi_debug.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/scsi/scsi_debug.c +7 -0
index 697fc57bc711..629853662b82 100644
@@ -1899,6 +1899,13 @@ static int resp_readcap16(struct scsi_cmnd *scp,
  			arr[14] |= 0x40;
  	}
 
+	/*
+	 * Since the scsi_debug READ CAPACITY implementation always reports the
+	 * total disk capacity, set RC BASIS = 1 for host-managed ZBC devices.
+	 */
+	if (devip->zmodel == BLK_ZONED_HM)
+		arr[12] |= 1 << 4;
+
  	arr[15] = sdebug_lowest_aligned & 0xff;
 
  	if (have_dif_prot) {
#3 lore raw
In reply to Bart Van Assche
Quoted 8 lines · Bart Van Assche

From ZBC-1:
* RC BASIS = 0: The RETURNED LOGICAL BLOCK ADDRESS field indicates the highest LBA of a contiguous range of zones that are not sequential write required zones starting with the first zone.
* RC BASIS = 1: The RETURNED LOGICAL BLOCK ADDRESS field indicates the LBA of the last logical block on the logical unit.

[...]

Applied to 6.1/scsi-fixes, thanks!

[1/1] scsi: scsi_debug: Make the READ CAPACITY response compliant with ZBC

      https://git.kernel.org/mkp/scsi/c/ecb8c2580d37
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering