From 7cedb1f17fb7f4374d11501f61656ae9d3ba47e9 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Sun, 13 Jan 2008 14:15:28 -0600 Subject: 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 Signed-off-by: Jens Axboe --- drivers/scsi/scsi_lib.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/scsi/scsi_lib.c') diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 3b5121c4c08..eb4911a6164 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) BUG_ON(!cmd->use_sg); - ret = __sg_alloc_table(&cmd->sg_table, cmd->use_sg, gfp_mask, scsi_sg_alloc); + ret = __sg_alloc_table(&cmd->sg_table, cmd->use_sg, + SCSI_MAX_SG_SEGMENTS, gfp_mask, scsi_sg_alloc); if (unlikely(ret)) - __sg_free_table(&cmd->sg_table, scsi_sg_free); + __sg_free_table(&cmd->sg_table, SCSI_MAX_SG_SEGMENTS, + scsi_sg_free); cmd->request_buffer = cmd->sg_table.sgl; return ret; @@ -773,7 +775,7 @@ EXPORT_SYMBOL(scsi_alloc_sgtable); void scsi_free_sgtable(struct scsi_cmnd *cmd) { - __sg_free_table(&cmd->sg_table, scsi_sg_free); + __sg_free_table(&cmd->sg_table, SCSI_MAX_SG_SEGMENTS, scsi_sg_free); } EXPORT_SYMBOL(scsi_free_sgtable); -- cgit v1.2.3