From cd518da8fee942388dfa193571c58fe52e3f8b4b Mon Sep 17 00:00:00 2001 From: Olaf Weber Date: Fri, 27 Jan 2017 16:23:20 +0100 Subject: [PATCH] LU-9480 lnet: cleanup of lnet_peer_ni_addref/decref_locked() Address style issues in lnet_peer_ni_addref_locked() and lnet_peer_ni_decref_locked(). In the latter routine, replace a sequence of atomic_dec()/atomic_read() with atomic_dec_and_test(). Test-Parameters: trivial Signed-off-by: Olaf Weber Change-Id: I9b7030ac9850b035f8bd80487a7b69b66b1d5858 Reviewed-on: https://review.whamcloud.com/25777 Reviewed-by: Olaf Weber Reviewed-by: Amir Shehata Tested-by: Amir Shehata --- lnet/include/lnet/lib-lnet.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lnet/include/lnet/lib-lnet.h b/lnet/include/lnet/lib-lnet.h index 0331222..d66a684 100644 --- a/lnet/include/lnet/lib-lnet.h +++ b/lnet/include/lnet/lib-lnet.h @@ -384,7 +384,7 @@ lnet_handle2me(struct lnet_handle_me *handle) static inline void lnet_peer_ni_addref_locked(struct lnet_peer_ni *lp) { - LASSERT (atomic_read(&lp->lpni_refcount) > 0); + LASSERT(atomic_read(&lp->lpni_refcount) > 0); atomic_inc(&lp->lpni_refcount); } @@ -393,9 +393,8 @@ extern void lnet_destroy_peer_ni_locked(struct lnet_peer_ni *lp); static inline void lnet_peer_ni_decref_locked(struct lnet_peer_ni *lp) { - LASSERT (atomic_read(&lp->lpni_refcount) > 0); - atomic_dec(&lp->lpni_refcount); - if (atomic_read(&lp->lpni_refcount) == 0) + LASSERT(atomic_read(&lp->lpni_refcount) > 0); + if (atomic_dec_and_test(&lp->lpni_refcount)) lnet_destroy_peer_ni_locked(lp); } -- 1.8.3.1