* [PATCH] scsi: raise error when sg slab/mempool cannot be initialized
@ 2006-12-19 8:36 Akinobu Mita
0 siblings, 0 replies; only message in thread
From: Akinobu Mita @ 2006-12-19 8:36 UTC (permalink / raw)
To: linux-scsi; +Cc: James E.J. Bottomley
This patch raises error when sg slab or mempool cannot be initialized.
It is better than crash after initialization.
Cc: "James E.J. Bottomley" <James.Bottomley@SteelEye.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
drivers/scsi/scsi_lib.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: 2.6-mm/drivers/scsi/scsi_lib.c
===================================================================
--- 2.6-mm.orig/drivers/scsi/scsi_lib.c
+++ 2.6-mm/drivers/scsi/scsi_lib.c
@@ -1682,6 +1682,7 @@ int __init scsi_init_queue(void)
if (!sgp->slab) {
printk(KERN_ERR "SCSI: can't init sg slab %s\n",
sgp->name);
+ goto out;
}
sgp->pool = mempool_create_slab_pool(SG_MEMPOOL_SIZE,
@@ -1689,10 +1690,23 @@ int __init scsi_init_queue(void)
if (!sgp->pool) {
printk(KERN_ERR "SCSI: can't init sg mempool %s\n",
sgp->name);
+ goto out;
}
}
return 0;
+out:
+ for (i = 0; i < SG_MEMPOOL_NR; i++) {
+ struct scsi_host_sg_pool *sgp = scsi_sg_pools + i;
+ if (sgp->pool)
+ mempool_destroy(sgp->pool);
+ if (sgp->slab)
+ kmem_cache_destroy(sgp->slab);
+ }
+
+ kmem_cache_destroy(scsi_io_context_cache);
+
+ return -ENOMEM;
}
void scsi_exit_queue(void)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-12-19 8:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-19 8:36 [PATCH] scsi: raise error when sg slab/mempool cannot be initialized Akinobu Mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox