Whamcloud - gitweb
LU-12264 lnet: Protect lp_dc_pendq manipulation with lp_lock 98/34798/9
authorChris Horn <hornc@cray.com>
Thu, 2 May 2019 22:24:32 +0000 (17:24 -0500)
committerAmir Shehata <ashehata@whamcloud.com>
Fri, 7 Jun 2019 18:09:02 +0000 (18:09 +0000)
Protect the peer discovery queue from concurrent manipulation by
acquiring the lp_lock.

Test-Parameters: forbuildonly
Signed-off-by: Chris Horn <hornc@cray.com>
Change-Id: If43b877c1c7ea203f346a3d6ea846f00b8f9661f
Reviewed-on: https://review.whamcloud.com/34798
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Tested-by: Jenkins
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
lnet/lnet/lib-move.c
lnet/lnet/peer.c

index df230bf..843a800 100644 (file)
@@ -2568,7 +2568,9 @@ again:
                /* queue message and return */
                msg->msg_rtr_nid_param = rtr_nid;
                msg->msg_sending = 0;
+               spin_lock(&peer->lp_lock);
                list_add_tail(&msg->msg_list, &peer->lp_dc_pendq);
+               spin_unlock(&peer->lp_lock);
                lnet_peer_ni_decref_locked(lpni);
                primary_nid = peer->lp_primary_nid;
                lnet_net_unlock(cpt);
index 4c1a499..db012f3 100644 (file)
@@ -297,7 +297,9 @@ lnet_destroy_peer_locked(struct lnet_peer *lp)
         * Releasing the lock can cause an inconsistent state
         */
        spin_lock(&the_lnet.ln_msg_resend_lock);
+       spin_lock(&lp->lp_lock);
        list_splice(&lp->lp_dc_pendq, &the_lnet.ln_msg_resend);
+       spin_unlock(&lp->lp_lock);
        spin_unlock(&the_lnet.ln_msg_resend_lock);
        wake_up(&the_lnet.ln_dc_waitq);
 
@@ -1786,7 +1788,9 @@ static void lnet_peer_discovery_complete(struct lnet_peer *lp)
               libcfs_nid2str(lp->lp_primary_nid));
 
        list_del_init(&lp->lp_dc_list);
+       spin_lock(&lp->lp_lock);
        list_splice_init(&lp->lp_dc_pendq, &pending_msgs);
+       spin_unlock(&lp->lp_lock);
        wake_up_all(&lp->lp_dc_waitq);
 
        lnet_net_unlock(LNET_LOCK_EX);