From: Chris Horn Date: Tue, 28 Feb 2023 20:09:57 +0000 (-0700) Subject: LU-16604 kfilnd: kfilnd_peer ref leak on send X-Git-Tag: 2.15.55~47 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F57%2F50157%2F2;p=fs%2Flustre-release.git LU-16604 kfilnd: kfilnd_peer ref leak on send There is an extra refcount_inc() done by kfilnd_tn_alloc_for_peer(). This is correct in the case where we are allocating TN for HELLO request, because our caller does not take extra ref on kfilnd_peer, but it is wrong in the normal kfilnd_tn_alloc() path because kfilnd_tn_alloc() takes this reference by way of a call to kfilnd_peer_get(). Move the refcount_inc() from kfilnd_tn_alloc_for_peer() to kfilnd_send_hello_request() where it is needed. Test-Parameters: trivial HPE-bug-id: LUS-11128 Fixes: 11a32d886b ("LU-16213 kfilnd: Allow one HELLO in-flight per peer") Signed-off-by: Chris Horn Change-Id: I3d723a829ec42929ce22a80ffda97dbd87917d4b Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50157 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Shaun Tancheff Reviewed-by: Ron Gredvig Reviewed-by: Ian Ziemba Reviewed-by: Oleg Drokin --- diff --git a/lnet/klnds/kfilnd/kfilnd.c b/lnet/klnds/kfilnd/kfilnd.c index 5f8d688..44c580d 100644 --- a/lnet/klnds/kfilnd/kfilnd.c +++ b/lnet/klnds/kfilnd/kfilnd.c @@ -85,6 +85,11 @@ int kfilnd_send_hello_request(struct kfilnd_dev *dev, int cpt, return rc; } + /* +1 for tn->tn_kp. This ref is dropped when this transaction is + * finalized + */ + refcount_inc(&kp->kp_cnt); + tn->msg_type = KFILND_MSG_HELLO_REQ; kp->kp_hello_ts = ktime_get_seconds(); diff --git a/lnet/klnds/kfilnd/kfilnd_tn.c b/lnet/klnds/kfilnd/kfilnd_tn.c index 59fe030..04b457f 100644 --- a/lnet/klnds/kfilnd/kfilnd_tn.c +++ b/lnet/klnds/kfilnd/kfilnd_tn.c @@ -1512,7 +1512,6 @@ struct kfilnd_transaction *kfilnd_tn_alloc_for_peer(struct kfilnd_dev *dev, } tn->tn_kp = kp; - refcount_inc(&kp->kp_cnt); mutex_init(&tn->tn_lock); tn->tn_ep = ep;