[PATCH 1/3] scsi_debug: Set the SAME field in the REPORT ZONES response

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
Cc: Damien Le Moal <damien.lemoal@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
---
 drivers/scsi/scsi_debug.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index b8a76b89f85a..5a8efc328fb5 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -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. */



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux