Skip to contentSkip to conversation

cciss: Fix scsi tape io with more than 255 scatter gather elements

PATCH In review Stephen M. Cameron 2 participants 3 messages Mar 22, 2012 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cciss: Fix scsi tape io with more than 255 scatter gather elements

From: Stephen M. Cameron <[email protected]>

The total number of scatter gather elements in the CISS command used by the scsi tape code was being cast to a u8, which can hold at most 255 scatter gather elements. It should have been cast to a u16. Without this patch the command gets rejected by the controller since the total scatter gather count did not add up to the right value resulting in an i/o error.

---
 drivers/block/cciss_scsi.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/block/cciss_scsi.c +1 -1
index e820b68..1162f7b 100644
@@ -1410,7 +1410,7 @@ static void cciss_scatter_gather(ctlr_info_t *h, CommandList_struct *c,
 	/* track how many SG entries we are using */
 	if (request_nsgs > h->maxSG)
 		h->maxSG = request_nsgs;
-	c->Header.SGTotal = (__u8) request_nsgs + chained;
+	c->Header.SGTotal = (u16) request_nsgs + chained;
 	if (request_nsgs > h->max_cmd_sgentries)
 		c->Header.SGList = h->max_cmd_sgentries;
 	else
#1 lore raw

PATCH 2/2 cciss: Initialize scsi host max_sectors for tape drive support

From: Stephen M. Cameron <[email protected]>

The default is too small (1024 blocks), use h->cciss_max_sectors (8192 blocks) Without this change, if you try to set the block size of a tape drive above 512*1024, via "mt -f /dev/st0 setblk nnn" where nnn is greater than 524288, it won't work right.

---
 drivers/block/cciss_scsi.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/block/cciss_scsi.c +1 -0
index 1162f7b..acda773 100644
@@ -866,6 +866,7 @@ cciss_scsi_detect(ctlr_info_t *h)
 	sh->can_queue = cciss_tape_cmds;
 	sh->sg_tablesize = h->maxsgentries;
 	sh->max_cmd_len = MAX_COMMAND_SIZE;
+	sh->max_sectors = h->cciss_max_sectors;
 
 	((struct cciss_scsi_adapter_data_t *) 
 		h->scsi_ctlr)->scsi_host = sh;
maintainer
#2 lore raw
In reply to Stephen M. Cameron
Quoted 8 lines · Stephen M. Cameron

From: Stephen M. Cameron <[email protected]>

The total number of scatter gather elements in the CISS command used by the scsi tape code was being cast to a u8, which can hold at most 255 scatter gather elements. It should have been cast to a u16. Without this patch the command gets rejected by the controller since the total scatter gather count did not add up to the right value resulting in an i/o error.

Thanks Stephen, applied both patches.

Signature · 1 line
Jens Axboe