aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2008-01-13 15:15:28 -0500
committerJens Axboe <jens.axboe@oracle.com>2008-01-28 04:54:49 -0500
commit7cedb1f17fb7f4374d11501f61656ae9d3ba47e9 (patch)
treed6257751445618b827c3e41e5b8fde2704c9d716 /drivers
parent5ed7959ede0936c55e50421a53f153b17080e876 (diff)
SG: work with the SCSI fixed maximum allocations.
SCSI sg table allocation has a maximum size (of SCSI_MAX_SG_SEGMENTS, currently 128) and this will cause a BUG_ON() in SCSI if something tries an allocation over it. This patch adds a size limit to the chaining allocator to allow the specification of the maximum allocation size for chaining, so we always chain in units of the maximum SCSI allocation size. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/scsi/scsi_lib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 3b5121c4c081..eb4911a61641 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -761,9 +761,11 @@ int scsi_alloc_sgtable(struct scsi_cmnd *cmd, gfp_t gfp_mask)
761 761
762 BUG_ON(!cmd->use_sg); 762 BUG_ON(!cmd->use_sg);
763 763
764 ret = __sg_alloc_table(&cmd->sg_table, cmd->use_sg, gfp_mask, scsi_sg_alloc); 764 ret = __sg_alloc_table(&cmd->sg_table, cmd->use_sg,
765 SCSI_MAX_SG_SEGMENTS, gfp_mask, scsi_sg_alloc);
765 if (unlikely(ret)) 766 if (unlikely(ret))
766 __sg_free_table(&cmd->sg_table, scsi_sg_free); 767 __sg_free_table(&cmd->sg_table, SCSI_MAX_SG_SEGMENTS,
768 scsi_sg_free);
767 769
768 cmd->request_buffer = cmd->sg_table.sgl; 770 cmd->request_buffer = cmd->sg_table.sgl;
769 return ret; 771 return ret;
@@ -773,7 +775,7 @@ EXPORT_SYMBOL(scsi_alloc_sgtable);
773 775
774void scsi_free_sgtable(struct scsi_cmnd *cmd) 776void scsi_free_sgtable(struct scsi_cmnd *cmd)
775{ 777{
776 __sg_free_table(&cmd->sg_table, scsi_sg_free); 778 __sg_free_table(&cmd->sg_table, SCSI_MAX_SG_SEGMENTS, scsi_sg_free);
777} 779}
778 780
779EXPORT_SYMBOL(scsi_free_sgtable); 781EXPORT_SYMBOL(scsi_free_sgtable);