[24/24] lustre: lnet: balance references in lnet_discover_peer_locked()
diff mbox series

Message ID 153895437848.16383.5882317080014923551.stgit@noble
State New
Headers show
Series
  • Port Dynamic Discovery to drivers/staging
Related show

Commit Message

NeilBrown Oct. 7, 2018, 11:19 p.m. UTC
From: John L. Hammond <john.hammond@intel.com>

In lnet_discover_peer_locked() avoid a leaked reference to the peer in
the non-blocking discovery case.

WC-bug-id: https://jira.whamcloud.com/browse/LU-9913
Signed-off-by: John L. Hammond <john.hammond@intel.com>
Reviewed-on: https://review.whamcloud.com/28695
Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: NeilBrown <neilb@suse.com>
---
 drivers/staging/lustre/lnet/lnet/peer.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

James Simmons Oct. 14, 2018, 11:53 p.m. UTC | #1
> From: John L. Hammond <john.hammond@intel.com>
> 
> In lnet_discover_peer_locked() avoid a leaked reference to the peer in
> the non-blocking discovery case.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> WC-bug-id: https://jira.whamcloud.com/browse/LU-9913
> Signed-off-by: John L. Hammond <john.hammond@intel.com>
> Reviewed-on: https://review.whamcloud.com/28695
> Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
> Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lnet/lnet/peer.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
> index 5f61fca09f44..db36b5cf31e1 100644
> --- a/drivers/staging/lustre/lnet/lnet/peer.c
> +++ b/drivers/staging/lustre/lnet/lnet/peer.c
> @@ -2010,7 +2010,6 @@ lnet_discover_peer_locked(struct lnet_peer_ni *lpni, int cpt, bool block)
>  		if (lnet_peer_is_uptodate(lp))
>  			break;
>  		lnet_peer_queue_for_discovery(lp);
> -		lnet_peer_addref_locked(lp);
>  		/*
>  		 * if caller requested a non-blocking operation then
>  		 * return immediately. Once discovery is complete then the
> @@ -2019,6 +2018,8 @@ lnet_discover_peer_locked(struct lnet_peer_ni *lpni, int cpt, bool block)
>  		 */
>  		if (!block)
>  			break;
> +
> +		lnet_peer_addref_locked(lp);
>  		lnet_net_unlock(LNET_LOCK_EX);
>  		schedule();
>  		finish_wait(&lp->lp_dc_waitq, &wait);
> 
> 
>
James Simmons Oct. 14, 2018, 11:54 p.m. UTC | #2
> From: John L. Hammond <john.hammond@intel.com>
> 
> In lnet_discover_peer_locked() avoid a leaked reference to the peer in
> the non-blocking discovery case.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> WC-bug-id: https://jira.whamcloud.com/browse/LU-9913
> Signed-off-by: John L. Hammond <john.hammond@intel.com>
> Reviewed-on: https://review.whamcloud.com/28695
> Reviewed-by: Olaf Weber <olaf.weber@hpe.com>
> Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lnet/lnet/peer.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
> index 5f61fca09f44..db36b5cf31e1 100644
> --- a/drivers/staging/lustre/lnet/lnet/peer.c
> +++ b/drivers/staging/lustre/lnet/lnet/peer.c
> @@ -2010,7 +2010,6 @@ lnet_discover_peer_locked(struct lnet_peer_ni *lpni, int cpt, bool block)
>  		if (lnet_peer_is_uptodate(lp))
>  			break;
>  		lnet_peer_queue_for_discovery(lp);
> -		lnet_peer_addref_locked(lp);
>  		/*
>  		 * if caller requested a non-blocking operation then
>  		 * return immediately. Once discovery is complete then the
> @@ -2019,6 +2018,8 @@ lnet_discover_peer_locked(struct lnet_peer_ni *lpni, int cpt, bool block)
>  		 */
>  		if (!block)
>  			break;
> +
> +		lnet_peer_addref_locked(lp);
>  		lnet_net_unlock(LNET_LOCK_EX);
>  		schedule();
>  		finish_wait(&lp->lp_dc_waitq, &wait);
> 
> 
>

Patch
diff mbox series

diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index 5f61fca09f44..db36b5cf31e1 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -2010,7 +2010,6 @@  lnet_discover_peer_locked(struct lnet_peer_ni *lpni, int cpt, bool block)
 		if (lnet_peer_is_uptodate(lp))
 			break;
 		lnet_peer_queue_for_discovery(lp);
-		lnet_peer_addref_locked(lp);
 		/*
 		 * if caller requested a non-blocking operation then
 		 * return immediately. Once discovery is complete then the
@@ -2019,6 +2018,8 @@  lnet_discover_peer_locked(struct lnet_peer_ni *lpni, int cpt, bool block)
 		 */
 		if (!block)
 			break;
+
+		lnet_peer_addref_locked(lp);
 		lnet_net_unlock(LNET_LOCK_EX);
 		schedule();
 		finish_wait(&lp->lp_dc_waitq, &wait);