SG: work with the SCSI fixed maximum allocations
Subsystems (2)
James Bottomley
maintainerPATCH 1/1 SG: work with the SCSI fixed maximum allocations
Boaz pointed out that the current sg table code will bug in the SCSI index function because it assumes a larger sized allocator that SCSI possesses. This patch fixes the issue.
James
---
Quoted 1 line
From
258aae00284d61786758d9e740df08cc4b916f96Mon Sep 17 00:00:00 2001
From: James Bottomley <[email protected]>
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.
--- drivers/scsi/scsi_lib.c | 8 +++++--- include/linux/scatterlist.h | 5 +++-- lib/scatterlist.c | 41 +++++++++++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 19 deletions(-)
drivers/scsi/scsi_lib.c +5 -3
@@ -773,16 +773,18 @@ static int scsi_alloc_sgtable(struct scsi_data_buffer *sdb, int nents,BUG_ON (!nents); - ret =__sg_alloc_table (&sdb->table, nents, gfp_mask, scsi_sg_alloc); + ret =__sg_alloc_table (&sdb->table, nents,SCSI_MAX_SG_SEGMENTS , + gfp_mask, scsi_sg_alloc);if (unlikely (ret)) -__sg_free_table (&sdb->table, scsi_sg_free); +__sg_free_table (&sdb->table,SCSI_MAX_SG_SEGMENTS , + scsi_sg_free);return ret; }static void scsi_free_sgtable (struct scsi_data_buffer *sdb) { -__sg_free_table (&sdb->table, scsi_sg_free); +__sg_free_table (&sdb->table,SCSI_MAX_SG_SEGMENTS , scsi_sg_free); }/*
include/linux/scatterlist.h +3 -2
@@ -207,9 +207,10 @@ void sg_init_one(struct scatterlist *, const void *, unsigned int);typedef struct scatterlist *(sg_alloc_fn )(unsigned int ,gfp_t );typedef void (sg_free_fn )(struct scatterlist *,unsigned int ); -void __sg_free_table (struct sg_table *,sg_free_fn *); +void __sg_free_table (struct sg_table *,unsigned int ,sg_free_fn *);void sg_free_table (struct sg_table *); -int __sg_alloc_table (struct sg_table *,unsigned int ,gfp_t ,sg_alloc_fn *); +int __sg_alloc_table (struct sg_table *,unsigned int ,unsigned int ,gfp_t , +sg_alloc_fn *);int sg_alloc_table (struct sg_table *,unsigned int ,gfp_t );/*
lib/scatterlist.c +27 -14
107 lines not on this page · raw message
Signature · 1 line
1.5.3.7