[v2,2/6] Revert "target: Fix sbc_parse_verify bytchk = 0 handling"
diff mbox

Message ID 20170510203736.12462-3-bart.vanassche@sandisk.com
State New, archived
Headers show

Commit Message

Bart Van Assche May 10, 2017, 8:37 p.m. UTC
Since commit d7d40280f868 breaks sbc_parse_verify(), revert it.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: David Disseldorp <ddiss@suse.de>
---
 drivers/target/target_core_sbc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Patch
diff mbox

diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 2cc8753eacad..a0ad618f1b1a 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -836,8 +836,10 @@  sbc_check_dpofua(struct se_device *dev, struct se_cmd *cmd, unsigned char *cdb)
  * @cmd:     (in)  structure that describes the SCSI command to be parsed.
  * @sectors: (out) Number of logical blocks on the storage medium that will be
  *           affected by the SCSI command.
+ * @bufflen: (out) Expected length of the SCSI Data-Out buffer.
  */
-static sense_reason_t sbc_parse_verify(struct se_cmd *cmd, unsigned int *sectors)
+static sense_reason_t sbc_parse_verify(struct se_cmd *cmd, int *sectors,
+				       u32 *bufflen)
 {
 	struct se_device *dev = cmd->se_dev;
 	u8 *cdb = cmd->t_task_cdb;
@@ -869,7 +871,10 @@  static sense_reason_t sbc_parse_verify(struct se_cmd *cmd, unsigned int *sectors
 
 	switch (bytchk) {
 	case 0:
+		*bufflen = 0;
+		break;
 	case 1:
+		*bufflen = sbc_get_size(cmd, *sectors);
 		cmd->se_cmd_flags |= SCF_SCSI_DATA_CDB;
 		break;
 	default:
@@ -962,7 +967,7 @@  sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
 		break;
 	case WRITE_VERIFY:
 	case WRITE_VERIFY_16:
-		ret = sbc_parse_verify(cmd, &sectors);
+		ret = sbc_parse_verify(cmd, &sectors, &size);
 		if (ret)
 			return ret;
 		cmd->execute_cmd = sbc_execute_rw;
@@ -1164,7 +1169,7 @@  sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
 		break;
 	case VERIFY:
 	case VERIFY_16:
-		ret = sbc_parse_verify(cmd, &sectors);
+		ret = sbc_parse_verify(cmd, &sectors, &size);
 		if (ret)
 			return ret;
 		cmd->execute_cmd = sbc_emulate_noop;