All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: target-devel@vger.kernel.org, linux-scsi@vger.kernel.org,
	"Nicholas A . Bellinger" <nab@linux-iscsi.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	Hannes Reinecke <hare@suse.de>,
	Bart Van Assche <bart.vanassche@sandisk.com>
Subject: [PATCH 4/5] target: user: Fix sense data handling
Date: Wed, 28 Jun 2017 14:58:59 +0900	[thread overview]
Message-ID: <20170628055900.22889-5-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20170628055900.22889-1-damien.lemoal@wdc.com>

If the user request handler completed the request with a CHECK CONDITION
status, tcmu_handle_completion() copies the command entry sense data
into the session request structure sense data. However, the sense data
length indicated by the field scsi_sense_length is not set and equal to
0, resulting in the copy being a no-op and failure to propagate the
sense data back to the initiator. To fix this, properly set the session
command sense data length and also set the session command
SCF_TRANSPORT_TASK_SENSE flag to indicate that the command has valid
sense data.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/target/target_core_user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index beb5f09..7426b4c 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -831,7 +831,9 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
 		entry->rsp.scsi_status = SAM_STAT_CHECK_CONDITION;
 	} else if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) {
 		memcpy(se_cmd->sense_buffer, entry->rsp.sense_buffer,
-			       se_cmd->scsi_sense_length);
+		       TRANSPORT_SENSE_BUFFER);
+		se_cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER;
+		se_cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE;
 	} else if (se_cmd->se_cmd_flags & SCF_BIDI) {
 		/* Get Data-In buffer before clean up */
 		gather_data_area(udev, cmd, true);
-- 
2.9.4

  parent reply	other threads:[~2017-06-28  5:59 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28  5:58 [PATCH 0/5] target: Zoned block device support and bug fixes Damien Le Moal
2017-06-28  5:58 ` [PATCH 1/5] target: Use macro for WRITE_VERIFY_xx operation codes Damien Le Moal
2017-07-07  5:00   ` Nicholas A. Bellinger
2017-06-28  5:58 ` [PATCH 2/5] target: pscsi: Introduce TYPE_ZBC support Damien Le Moal
2017-07-07  5:00   ` Nicholas A. Bellinger
2017-06-28  5:58 ` [PATCH 3/5] target: pscsi: Fix sense data handling Damien Le Moal
2017-07-07  5:02   ` Nicholas A. Bellinger
2017-06-28  5:58 ` Damien Le Moal [this message]
2017-06-28 17:44   ` [PATCH 4/5] target: user: " Mike Christie
2017-06-29  2:26     ` Damien Le Moal
2017-07-07  4:50     ` Nicholas A. Bellinger
2017-07-07  5:14       ` Damien Le Moal
2017-07-07  6:05         ` Nicholas A. Bellinger
2017-07-07  6:06           ` Nicholas A. Bellinger
2017-07-07  6:18             ` Damien Le Moal
2017-07-10  5:36           ` Damien Le Moal
2017-07-10 17:26             ` Mike Christie
2017-07-11  0:57               ` Damien Le Moal
2017-07-07 17:19       ` Mike Christie
2017-07-07  5:04   ` Nicholas A. Bellinger
2017-06-28  5:59 ` [PATCH 5/5] target: core: Fix failed command " Damien Le Moal
2017-06-28 17:45   ` Mike Christie
2017-07-07  5:06   ` Nicholas A. Bellinger
2017-06-28 14:34 ` [PATCH 0/5] target: Zoned block device support and bug fixes Bryant G. Ly
2017-06-29  2:24   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170628055900.22889-5-damien.lemoal@wdc.com \
    --to=damien.lemoal@wdc.com \
    --cc=bart.vanassche@sandisk.com \
    --cc=hare@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.