]> Git Repo - linux.git/commitdiff
scsi: scsi_debug: Make the READ CAPACITY response compliant with ZBC
authorBart Van Assche <[email protected]>
Wed, 2 Nov 2022 19:32:48 +0000 (12:32 -0700)
committerMartin K. Petersen <[email protected]>
Tue, 8 Nov 2022 02:07:52 +0000 (02:07 +0000)
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.

Cc: Douglas Gilbert <[email protected]>
Cc: Damien Le Moal <[email protected]>
Suggested-by: Damien Le Moal <[email protected]>
Signed-off-by: Bart Van Assche <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Damien Le Moal <[email protected]>
Acked-by: Douglas Gilbert <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
drivers/scsi/scsi_debug.c

index 697fc57bc711fb0e8492234c5cf65ac90d80b9c9..629853662b820f6e271e435517bde3f908dbf715 100644 (file)
@@ -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) {
This page took 0.072641 seconds and 4 git commands to generate.