]> err.no Git - linux-2.6/commitdiff
[SCSI] libsas: Add SAS_HA state flags to avoid queueing events while unloading
authorDarrick J. Wong <djwong@us.ibm.com>
Thu, 11 Jan 2007 22:15:43 +0000 (14:15 -0800)
committerJames Bottomley <jejb@mulgrave.il.steeleye.com>
Sat, 13 Jan 2007 22:21:53 +0000 (16:21 -0600)
Track sas_ha_struct state so that we ignore events that come in while
we're shutting things down.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
drivers/scsi/libsas/sas_discover.c
drivers/scsi/libsas/sas_event.c
drivers/scsi/libsas/sas_init.c
drivers/scsi/libsas/sas_internal.h
include/scsi/libsas.h

index 21f538e4a0b587cd88cd35f877a67d41e5de1552..b6ba0e053d1a4edfe5e582859e3f6ca547c84b9f 100644 (file)
@@ -753,7 +753,7 @@ int sas_discover_event(struct asd_sas_port *port, enum discover_event ev)
        BUG_ON(ev >= DISC_NUM_EVENTS);
 
        sas_queue_event(ev, &disc->disc_event_lock, &disc->pending,
-                       &disc->disc_work[ev].work, port->ha->core.shost);
+                       &disc->disc_work[ev].work, port->ha);
 
        return 0;
 }
index d83392ee6823f09dab380b1008d2e2bbbf0031ba..9db30fb5caf2e1be01aa27b5433aa78d63889eb4 100644 (file)
@@ -31,7 +31,7 @@ static void notify_ha_event(struct sas_ha_struct *sas_ha, enum ha_event event)
        BUG_ON(event >= HA_NUM_EVENTS);
 
        sas_queue_event(event, &sas_ha->event_lock, &sas_ha->pending,
-                       &sas_ha->ha_events[event].work, sas_ha->core.shost);
+                       &sas_ha->ha_events[event].work, sas_ha);
 }
 
 static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
@@ -41,7 +41,7 @@ static void notify_port_event(struct asd_sas_phy *phy, enum port_event event)
        BUG_ON(event >= PORT_NUM_EVENTS);
 
        sas_queue_event(event, &ha->event_lock, &phy->port_events_pending,
-                       &phy->port_events[event].work, ha->core.shost);
+                       &phy->port_events[event].work, ha);
 }
 
 static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
@@ -51,7 +51,7 @@ static void notify_phy_event(struct asd_sas_phy *phy, enum phy_event event)
        BUG_ON(event >= PHY_NUM_EVENTS);
 
        sas_queue_event(event, &ha->event_lock, &phy->phy_events_pending,
-                       &phy->phy_events[event].work, ha->core.shost);
+                       &phy->phy_events[event].work, ha);
 }
 
 int sas_init_events(struct sas_ha_struct *sas_ha)
index 4df73d69bb3c554cd0eac9636697f6168b3e36ac..965698c8b7bff407cf2157922b93e7895ede92e7 100644 (file)
@@ -87,6 +87,9 @@ int sas_register_ha(struct sas_ha_struct *sas_ha)
        else if (sas_ha->lldd_queue_size == -1)
                sas_ha->lldd_queue_size = 128; /* Sanity */
 
+       sas_ha->state = SAS_HA_REGISTERED;
+       spin_lock_init(&sas_ha->state_lock);
+
        error = sas_register_phys(sas_ha);
        if (error) {
                printk(KERN_NOTICE "couldn't register sas phys:%d\n", error);
@@ -127,6 +130,15 @@ Undo_phys:
 
 int sas_unregister_ha(struct sas_ha_struct *sas_ha)
 {
+       unsigned long flags;
+
+       /* Set the state to unregistered to avoid further
+        * events to be queued */
+       spin_lock_irqsave(&sas_ha->state_lock, flags);
+       sas_ha->state = SAS_HA_UNREGISTERED;
+       spin_unlock_irqrestore(&sas_ha->state_lock, flags);
+       scsi_flush_work(sas_ha->core.shost);
+
        sas_unregister_ports(sas_ha);
 
        if (sas_ha->lldd_max_execute_num > 1) {
index 137d7e496b6d99ab6d1f6c8cbac094e27d072760..a78638df2018dd50cb8fb420076052252f130ffc 100644 (file)
@@ -80,7 +80,7 @@ void sas_hae_reset(struct work_struct *work);
 static inline void sas_queue_event(int event, spinlock_t *lock,
                                   unsigned long *pending,
                                   struct work_struct *work,
-                                  struct Scsi_Host *shost)
+                                  struct sas_ha_struct *sas_ha)
 {
        unsigned long flags;
 
@@ -91,7 +91,12 @@ static inline void sas_queue_event(int event, spinlock_t *lock,
        }
        __set_bit(event, pending);
        spin_unlock_irqrestore(lock, flags);
-       scsi_queue_work(shost, work);
+
+       spin_lock_irqsave(&sas_ha->state_lock, flags);
+       if (sas_ha->state != SAS_HA_UNREGISTERED) {
+               scsi_queue_work(sas_ha->core.shost, work);
+       }
+       spin_unlock_irqrestore(&sas_ha->state_lock, flags);
 }
 
 static inline void sas_begin_event(int event, spinlock_t *lock,
index c83426344e8f1da83b2725e2fc393b7794f8479b..ca393929c10b1d2fe37ac649ecbaa4019e28db94 100644 (file)
@@ -323,12 +323,20 @@ struct sas_ha_event {
        struct sas_ha_struct *ha;
 };
 
+enum sas_ha_state {
+       SAS_HA_REGISTERED,
+       SAS_HA_UNREGISTERED
+};
+
 struct sas_ha_struct {
 /* private: */
        spinlock_t       event_lock;
        struct sas_ha_event ha_events[HA_NUM_EVENTS];
        unsigned long    pending;
 
+       enum sas_ha_state state;
+       spinlock_t        state_lock;
+
        struct scsi_core core;
 
 /* public: */