Whamcloud - gitweb
891ce5697737b116128503bc324b9732dd8a7bc3
[fs/lustre-release.git] / lustre / kernel_patches / patches / ipoib-locking-fix.patch
1 commit fa16ebed31f336e41970f3f0ea9e8279f6be2d27
2 Author: Shlomo Pongratz <shlomop@mellanox.com>
3 Date:   Mon Aug 13 14:39:49 2012 +0000
4
5     IB/ipoib: Add missing locking when CM object is deleted
6     
7     Commit b63b70d87741 ("IPoIB: Use a private hash table for path lookup
8     in xmit path") introduced a bug where in ipoib_cm_destroy_tx() a CM
9     object is moved between lists without any supported locking.  Under a
10     stress test, this eventually leads to list corruption and a crash.
11     
12     Previously when this routine was called, callers were taking the
13     device priv lock.  Currently this function is called from the RCU
14     callback associated with neighbour deletion.  Fix the race by taking
15     the same lock we used to before.
16     
17     Signed-off-by: Shlomo Pongratz <shlomop@mellanox.com>
18     Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
19     Signed-off-by: Roland Dreier <roland@purestorage.com>
20
21 diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
22 index 95ecf4e..24683fd 100644
23 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
24 +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
25 @@ -1271,12 +1271,15 @@ struct ipoib_cm_tx *ipoib_cm_create_tx(struct net_device *dev, struct ipoib_path
26  void ipoib_cm_destroy_tx(struct ipoib_cm_tx *tx)
27  {
28         struct ipoib_dev_priv *priv = netdev_priv(tx->dev);
29 +       unsigned long flags;
30         if (test_and_clear_bit(IPOIB_FLAG_INITIALIZED, &tx->flags)) {
31 +               spin_lock_irqsave(&priv->lock, flags);
32                 list_move(&tx->list, &priv->cm.reap_list);
33                 queue_work(ipoib_workqueue, &priv->cm.reap_task);
34                 ipoib_dbg(priv, "Reap connection for gid %pI6\n",
35                           tx->neigh->daddr + 4);
36                 tx->neigh = NULL;
37 +               spin_unlock_irqrestore(&priv->lock, flags);
38         }
39  }
40