From 73ee638813a8b3663a35a4dec119164f6eb30b34 Mon Sep 17 00:00:00 2001 From: Chris Horn Date: Tue, 28 Feb 2023 13:09:57 -0700 Subject: [PATCH] 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 --- lnet/klnds/kfilnd/kfilnd.c | 5 +++++ lnet/klnds/kfilnd/kfilnd_tn.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) 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; -- 1.8.3.1