>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. Hence this patch. Cc: Douglas Gilbert <dgilbert@xxxxxxxxxxxx> Cc: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx> Fixes: 64e14ece0700 ("scsi: scsi_debug: Implement ZBC host-aware emulation") Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> --- drivers/scsi/scsi_debug.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 5a8efc328fb5..c5f4af774078 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -304,6 +304,7 @@ struct sdebug_dev_info { unsigned int nr_exp_open; unsigned int nr_closed; unsigned int max_open; + unsigned int rc_basis:2; ktime_t create_ts; /* time since bootup that this device was created */ struct sdeb_zone_state *zstate; }; @@ -1901,6 +1902,8 @@ static int resp_readcap16(struct scsi_cmnd *scp, arr[15] = sdebug_lowest_aligned & 0xff; + arr[12] |= devip->rc_basis << 4; + if (have_dif_prot) { arr[12] = (sdebug_dif - 1) << 1; /* P_TYPE */ arr[12] |= 1; /* PROT_EN */ @@ -5107,10 +5110,12 @@ static int sdebug_device_create_zones(struct sdebug_dev_info *devip) zsp->z_size = min_t(u64, devip->zsize, capacity - zstart); } else if ((zstart & (devip->zsize - 1)) == 0) { - if (devip->zmodel == BLK_ZONED_HM) + if (devip->zmodel == BLK_ZONED_HM) { zsp->z_type = ZBC_ZTYPE_SWR; - else + devip->rc_basis = 1; + } else { zsp->z_type = ZBC_ZTYPE_SWP; + } zsp->z_cond = ZC1_EMPTY; zsp->z_wp = zsp->z_start; zsp->z_size =