From: Mike Christie <[EMAIL PROTECTED]>

This is a resend of the per host cache cleanups with Vasu's comments
about using the proper prefix done.

Signed-off-by: Mike Christie <[EMAIL PROTECTED]>
---
 drivers/scsi/fcoe/fcoe_if.c  |    2 +-
 drivers/scsi/libfc/fc_exch.c |   42 +++++++++++++++++++-----------------------
 drivers/scsi/libfc/fc_fcp.c  |    9 ++++++++-
 include/scsi/libfc/libfc.h   |   10 ++++++++--
 4 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_if.c b/drivers/scsi/fcoe/fcoe_if.c
index 01ad482..d8ca5a1 100644
--- a/drivers/scsi/fcoe/fcoe_if.c
+++ b/drivers/scsi/fcoe/fcoe_if.c
@@ -273,7 +273,7 @@ static int lport_config(struct fc_lport *lp, struct 
Scsi_Host *shost)
        lp->drv_priv = (void *)(lp + 1);
 
        lp->emp = fc_exch_mgr_alloc(lp, FC_CLASS_3,
-                                   FCOE_MIN_XID, FCOE_MAX_XID, 0);
+                                   FCOE_MIN_XID, FCOE_MAX_XID);
        if (!lp->emp)
                return -ENOMEM;
 
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index a4d3901..a273a2f 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -35,6 +35,7 @@
  * fc_exch_debug can be set in debugger or at compile time to get more logs.
  */
 static int fc_exch_debug;
+static struct kmem_cache *fc_em_cachep;        /* cache for exchanges */
 
 /*
  * Structure and function definitions for managing Fibre Channel Exchanges
@@ -108,8 +109,6 @@ struct fc_exch_mgr {
        u16             last_xid;       /* last allocated exchange ID */
        u16             min_xid;        /* min exchange ID */
        u16             max_xid;        /* max exchange ID */
-       char em_cache_name[20];         /* cache name string */
-       struct  kmem_cache      *em_cache;      /* cache for exchanges */
        u32     total_exches;           /* total allocated exchanges */
        struct list_head        ex_list;        /* allocated exchanges list */
        struct fc_lport *lp;            /* fc device instance */
@@ -293,7 +292,7 @@ static void fc_exch_release(struct fc_exch *ep)
 
                WARN_ON(!ep->esb_stat & ESB_ST_COMPLETE);
                WARN_ON(timer_pending(&ep->ex_timer));
-               kmem_cache_free(mp->em_cache, ep);
+               kmem_cache_free(fc_em_cachep, ep);
        }
 }
 
@@ -464,7 +463,7 @@ struct fc_exch *fc_exch_alloc(struct fc_exch_mgr *mp, u16 
xid)
        /*
         * Allocate new exchange
         */
-       ep = kmem_cache_zalloc(mp->em_cache, GFP_ATOMIC);
+       ep = kmem_cache_zalloc(fc_em_cachep, GFP_ATOMIC);
        if (!ep) {
                atomic_inc(&mp->stats.no_free_exch);
                goto out;
@@ -492,7 +491,7 @@ struct fc_exch *fc_exch_alloc(struct fc_exch_mgr *mp, u16 
xid)
                } else {
                        spin_unlock_bh(&mp->em_lock);
                        atomic_inc(&mp->stats.no_free_exch_xid);
-                       kmem_cache_free(mp->em_cache, ep);
+                       kmem_cache_free(fc_em_cachep, ep);
                        goto out;
                }
        }
@@ -1735,9 +1734,7 @@ reject:
 
 struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp,
                                      enum fc_class class,
-                                     u16 min_xid,
-                                     u16 max_xid,
-                                     u32 em_idx)
+                                     u16 min_xid, u16 max_xid)
 {
        struct fc_exch_mgr *mp;
        size_t len;
@@ -1764,21 +1761,7 @@ struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport 
*lp,
                mp->max_xid = max_xid;
                mp->lp = lp;
                INIT_LIST_HEAD(&mp->ex_list);
-
                spin_lock_init(&mp->em_lock);
-
-               sprintf(mp->em_cache_name,
-                       "libfc-host%d-EM%d",
-                       lp->host->host_no, em_idx);
-               mp->em_cache = kmem_cache_create(mp->em_cache_name,
-                                             sizeof(struct fc_exch),
-                                             0, SLAB_HWCACHE_ALIGN,
-                                             NULL);
-
-               if (!mp->em_cache) {
-                       kfree(mp);
-                       mp = NULL;
-               }
        }
        return mp;
 }
@@ -1792,7 +1775,6 @@ void fc_exch_mgr_free(struct fc_exch_mgr *mp)
         * before freeing exchange manager.
         */
        WARN_ON(mp->total_exches != 0);
-       kmem_cache_destroy(mp->em_cache);
        kfree(mp);
 }
 EXPORT_SYMBOL(fc_exch_mgr_free);
@@ -1962,3 +1944,17 @@ int fc_exch_init(struct fc_lport *lp)
        return 0;
 }
 EXPORT_SYMBOL(fc_exch_init);
+
+int fc_setup_exch_mgr(void)
+{
+       fc_em_cachep = kmem_cache_create("libfc_em", sizeof(struct fc_exch),
+                                        0, SLAB_HWCACHE_ALIGN, NULL);
+       if (!fc_em_cachep)
+               return -ENOMEM;
+       return 0;
+}
+
+void fc_destroy_exch_mgr(void)
+{
+       kmem_cache_destroy(fc_em_cachep);
+}
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 26b0a96..eb37a66 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -2101,6 +2101,8 @@ EXPORT_SYMBOL(fc_fcp_init);
 
 static int __init libfc_init(void)
 {
+       int rc;
+
        scsi_pkt_cachep = kmem_cache_create("libfc_fcp_pkt",
                                            sizeof(struct fc_fcp_pkt),
                                            0, SLAB_HWCACHE_ALIGN, NULL);
@@ -2108,12 +2110,17 @@ static int __init libfc_init(void)
                FC_DBG("Unable to allocate SRB cache...module load failed!");
                return -ENOMEM;
        }
-       return 0;
+
+       rc = fc_setup_exch_mgr();
+       if (rc)
+               kmem_cache_destroy(scsi_pkt_cachep);
+       return rc;
 }
 
 static void __exit libfc_exit(void)
 {
        kmem_cache_destroy(scsi_pkt_cachep);
+       fc_destroy_exch_mgr();
 }
 
 module_init(libfc_init);
diff --git a/include/scsi/libfc/libfc.h b/include/scsi/libfc/libfc.h
index c9afeed..de68c44 100644
--- a/include/scsi/libfc/libfc.h
+++ b/include/scsi/libfc/libfc.h
@@ -644,8 +644,7 @@ int fc_exch_init(struct fc_lport *lp);
 struct fc_exch_mgr *fc_exch_mgr_alloc(struct fc_lport *lp,
                                      enum fc_class class,
                                      u16 min_xid,
-                                     u16 max_xid,
-                                     u32 em_idx);
+                                     u16 max_xid);
 
 /*
  * Free an exchange manager.
@@ -743,4 +742,11 @@ void fc_get_host_fabric_name(struct Scsi_Host *shost);
 void fc_set_rport_loss_tmo(struct fc_rport *rport, u32 timeout);
 struct fc_host_statistics *fc_get_host_stats(struct Scsi_Host *);
 
+/*
+ * module setup functions.
+ */
+int fc_setup_exch_mgr(void);
+void fc_destroy_exch_mgr(void);
+
+
 #endif /* _LIBFC_H_ */
-- 
1.5.4.1

_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel

Reply via email to