@@ -4476,8 +4476,10 @@ static int resp_report_zones(struct scsi_cmnd *scp,
u64 lba, zs_lba;
u8 *arr = NULL, *desc;
u8 *cmd = scp->cmnd;
- struct sdeb_zone_state *zsp = NULL;
+ struct sdeb_zone_state *zsp = NULL, *first_reported_zone = NULL;
struct sdeb_store_info *sip = devip2sip(devip, false);
+ /* 1: all zones in the response have the same type and length. */
+ u8 same = 1;
if (!sdebug_dev_is_zoned(devip)) {
mk_sense_invalid_opcode(scp);
@@ -4571,6 +4573,13 @@ static int resp_report_zones(struct scsi_cmnd *scp,
goto fini;
}
+ if (first_reported_zone) {
+ if (zsp->z_type != first_reported_zone->z_type ||
+ zsp->z_size != first_reported_zone->z_size)
+ same = 0;
+ } else {
+ first_reported_zone = zsp;
+ }
if (nrz < rep_max_zones) {
/* Fill zone descriptor */
desc[0] = zsp->z_type;
@@ -4592,6 +4601,8 @@ static int resp_report_zones(struct scsi_cmnd *scp,
/* Report header */
/* Zone list length. */
put_unaligned_be32(nrz * RZONES_DESC_HD, arr + 0);
+ /* SAME field. */
+ arr[4] = same;
/* Maximum LBA */
put_unaligned_be64(sdebug_capacity - 1, arr + 8);
/* Zone starting LBA granularity. */
Provide information to the SCSI initiator about whether or not all examined zones have the same zone type and zone length. From the description of the SAME field in ZBC-1: * 0: The zone type and zone length in each zone descriptor may be different. * 1: The zone type and zone length in each zone descriptor are equal to the zone type and zone length indicated in the first zone descriptor in the zone descriptor list. Cc: Douglas Gilbert <dgilbert@interlog.com> Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/scsi/scsi_debug.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)