From 6b9279721a068b44cac0e175b8e89355d6a3a964 Mon Sep 17 00:00:00 2001 From: Mark Harvey<markh794@xxxxxxxxx> Date: Sat, 9 Apr 2011 05:46:29 +1000 Subject: Handle Incorrect Length Indicator in sg backing store If ILI sense bit set, return available data. Tested-by: James Pattinson<james@xxxxxxxxxxxxx> Signed-off-by: Mark Harvey<markh794@xxxxxxxxx> --- usr/bs_sg.c | 10 ++++++++-- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/usr/bs_sg.c b/usr/bs_sg.c index 69cce9b..10af39a 100644 --- a/usr/bs_sg.c +++ b/usr/bs_sg.c @@ -247,6 +247,7 @@ static void bs_sg_cmd_complete(int fd, int events, void *data) struct sg_io_hdr io_hdr; struct scsi_cmd *cmd; int err; + unsigned resid; memset(&io_hdr, 0, sizeof(io_hdr)); io_hdr.interface_id = 'S'; @@ -261,9 +262,14 @@ static void bs_sg_cmd_complete(int fd, int events, void *data) scsi_set_out_resid(cmd, io_hdr.resid); scsi_set_in_resid(cmd, io_hdr.resid); } else { + if (io_hdr.sbp[2] == 0x20) /* Incorrect Length Indicator set */ + resid = io_hdr.dxfer_len - io_hdr.resid; + else + resid = 0; + cmd->sense_len = io_hdr.sb_len_wr; - scsi_set_out_resid_by_actual(cmd, 0); - scsi_set_in_resid_by_actual(cmd, 0); + scsi_set_out_resid_by_actual(cmd, resid); + scsi_set_in_resid_by_actual(cmd, resid); } cmd->scsi_cmd_done(cmd, io_hdr.status); -- 1.7.0.4 Cheers Mark -- To unsubscribe from this list: send the line "unsubscribe stgt" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html