diff mbox series

[07/24] lustre: lnet: cleanup of lnet_peer_ni_addref/decref_locked()

Message ID 153895437782.16383.10279057472731467540.stgit@noble (mailing list archive)
State New, archived
Headers show
Series Port Dynamic Discovery to drivers/staging | expand

Commit Message

NeilBrown Oct. 7, 2018, 11:19 p.m. UTC
From: Olaf Weber <olaf@sgi.com>

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().

WC-bug-id: https://jira.whamcloud.com/browse/LU-9480
Signed-off-by: Olaf Weber <olaf@sgi.com>
Reviewed-on: https://review.whamcloud.com/25777
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Amir Shehata <amir.shehata@intel.com>
Tested-by: Amir Shehata <amir.shehata@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
---
 .../staging/lustre/include/linux/lnet/lib-lnet.h   |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

James Simmons Oct. 14, 2018, 7:38 p.m. UTC | #1
> From: Olaf Weber <olaf@sgi.com>
> 
> 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().

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> WC-bug-id: https://jira.whamcloud.com/browse/LU-9480
> Signed-off-by: Olaf Weber <olaf@sgi.com>
> Reviewed-on: https://review.whamcloud.com/25777
> Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
> Reviewed-by: Amir Shehata <amir.shehata@intel.com>
> Tested-by: Amir Shehata <amir.shehata@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/lnet/lib-lnet.h   |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> index 2e2b5ed27116..f15f5c9c9a25 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> @@ -323,8 +323,7 @@ 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)
> +	if (atomic_dec_and_test(&lp->lpni_refcount))
>  		lnet_destroy_peer_ni_locked(lp);
>  }
>  
> 
> 
>
James Simmons Oct. 14, 2018, 7:39 p.m. UTC | #2
> From: Olaf Weber <olaf@sgi.com>
> 
> 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().

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> WC-bug-id: https://jira.whamcloud.com/browse/LU-9480
> Signed-off-by: Olaf Weber <olaf@sgi.com>
> Reviewed-on: https://review.whamcloud.com/25777
> Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
> Reviewed-by: Amir Shehata <amir.shehata@intel.com>
> Tested-by: Amir Shehata <amir.shehata@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  .../staging/lustre/include/linux/lnet/lib-lnet.h   |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> index 2e2b5ed27116..f15f5c9c9a25 100644
> --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
> @@ -323,8 +323,7 @@ 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)
> +	if (atomic_dec_and_test(&lp->lpni_refcount))
>  		lnet_destroy_peer_ni_locked(lp);
>  }
>  
> 
> 
>
diff mbox series

Patch

diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 2e2b5ed27116..f15f5c9c9a25 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -323,8 +323,7 @@  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)
+	if (atomic_dec_and_test(&lp->lpni_refcount))
 		lnet_destroy_peer_ni_locked(lp);
 }