diff options
author | Roland Dreier <roland@purestorage.com> | 2012-02-14 18:30:31 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2012-02-25 17:37:50 -0500 |
commit | 6cf3fa6918baab0c447f1206f1cef9166ad04864 (patch) | |
tree | 9613aaaa51fd6082f31f2d45f707b54e01128dc9 /drivers/target/loopback | |
parent | 015487b89f27d91d95a056cdc3c85e6c729bff12 (diff) |
tcm_loop: Set residual field for SCSI commands
If the target core signals an over- or under-run, tcm_loop should call
scsi_set_resid() to tell the SCSI midlayer about the residual data length.
The difference can be seen by doing something like
strace -eioctl sg_raw -r 1024 /dev/sda 8 0 0 0 1 0 > /dev/null
and looking at the "resid=" part of the SG_IO ioctl -- after this patch,
the field is correctly reported as 512.
Signed-off-by: Roland Dreier <roland@purestorage.com>
Cc: stable@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/loopback')
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 88fb3d1b0ad5..041673e9d2db 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -829,6 +829,9 @@ static int tcm_loop_queue_data_in(struct se_cmd *se_cmd) | |||
829 | 829 | ||
830 | sc->result = SAM_STAT_GOOD; | 830 | sc->result = SAM_STAT_GOOD; |
831 | set_host_byte(sc, DID_OK); | 831 | set_host_byte(sc, DID_OK); |
832 | if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) || | ||
833 | (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT)) | ||
834 | scsi_set_resid(sc, se_cmd->residual_count); | ||
832 | sc->scsi_done(sc); | 835 | sc->scsi_done(sc); |
833 | return 0; | 836 | return 0; |
834 | } | 837 | } |
@@ -854,6 +857,9 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd) | |||
854 | sc->result = se_cmd->scsi_status; | 857 | sc->result = se_cmd->scsi_status; |
855 | 858 | ||
856 | set_host_byte(sc, DID_OK); | 859 | set_host_byte(sc, DID_OK); |
860 | if ((se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) || | ||
861 | (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT)) | ||
862 | scsi_set_resid(sc, se_cmd->residual_count); | ||
857 | sc->scsi_done(sc); | 863 | sc->scsi_done(sc); |
858 | return 0; | 864 | return 0; |
859 | } | 865 | } |