Whamcloud - gitweb
LU-12264 lnet: Protect lp_dc_pendq manipulation with lp_lock 37/36037/4
authorChris Horn <hornc@cray.com>
Thu, 2 May 2019 22:24:32 +0000 (17:24 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 4 Oct 2019 20:30:52 +0000 (20:30 +0000)
Protect the peer discovery queue from concurrent manipulation by
acquiring the lp_lock.

Lustre-change: https://review.whamcloud.com/34798
Lustre-commit: dd16a31bf4ae874a69cc7dc5fe1f3197993630ae

Signed-off-by: Chris Horn <hornc@cray.com>
Change-Id: If43b877c1c7ea203f346a3d6ea846f00b8f9661f
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Amir Shehata <ashehata@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/36037
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/lnet/lib-move.c
lnet/lnet/peer.c

index b8b8434..e9139ce 100644 (file)
@@ -2565,7 +2565,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);