Skip to content

Commit ecb8c25

Browse files
bvanasschemartinkpetersen
authored andcommitted
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. Cc: Douglas Gilbert <dgilbert@interlog.com> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com> Suggested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20221102193248.3177608-1-bvanassche@acm.org Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 5d7bebf commit ecb8c25

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,6 +1899,13 @@ static int resp_readcap16(struct scsi_cmnd *scp,
18991899
arr[14] |= 0x40;
19001900
}
19011901

1902+
/*
1903+
* Since the scsi_debug READ CAPACITY implementation always reports the
1904+
* total disk capacity, set RC BASIS = 1 for host-managed ZBC devices.
1905+
*/
1906+
if (devip->zmodel == BLK_ZONED_HM)
1907+
arr[12] |= 1 << 4;
1908+
19021909
arr[15] = sdebug_lowest_aligned & 0xff;
19031910

19041911
if (have_dif_prot) {

0 commit comments

Comments
 (0)