Whamcloud - gitweb
LU-9921 lnet: resolve unsafe list access 23/28723/6
authorAmir Shehata <amir.shehata@intel.com>
Sat, 26 Aug 2017 04:18:16 +0000 (21:18 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 13 Sep 2017 03:37:43 +0000 (03:37 +0000)
commit62c3c8d148563781198abe11b2be213708b165cb
tree1a8413551381c71d21217bca0f441f90aa42a55a
parenta8d33a29e77e102505ee3916782dc697ad121ff8
LU-9921 lnet: resolve unsafe list access

Use list_for_each_entry_safe() when accessing messages on pending
queue. Remove the message from the list before calling lnet_finalize()
or lnet_send().

When destroying the peer make sure to queue all pending messages on
a global list. We can not resend them at this point because the
cpt lock is held. Unlocking the cpt lock could lead to an inconsistent
state. Use the discovery thread to check if the global list is not
empty and if so resend all messages on the list. Use a new spin
lock to protect the resend message list. I steered clear from reusing
an existing lock because LNet locking is complex and reusing a lock
will add to this complexity. Using a new lock makes the code easier
to understand.

Verify that all lists are empty before destroying the peer_ni

Signed-off-by: Amir Shehata <amir.shehata@intel.com>
Change-Id: Ia081419ec5ed2be5823cfbca7e050138a229ab9c
Reviewed-on: https://review.whamcloud.com/28723
Tested-by: Jenkins
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lnet/include/lnet/lib-types.h
lnet/lnet/api-ni.c
lnet/lnet/peer.c