Whamcloud - gitweb
LU-16604 kfilnd: kfilnd_peer ref leak on send 57/50157/2
authorChris Horn <chris.horn@hpe.com>
Tue, 28 Feb 2023 20:09:57 +0000 (13:09 -0700)
committerOleg Drokin <green@whamcloud.com>
Tue, 28 Mar 2023 22:12:19 +0000 (22:12 +0000)
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 <chris.horn@hpe.com>
Change-Id: I3d723a829ec42929ce22a80ffda97dbd87917d4b
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50157
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Ron Gredvig <ron.gredvig@hpe.com>
Reviewed-by: Ian Ziemba <ian.ziemba@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/klnds/kfilnd/kfilnd.c
lnet/klnds/kfilnd/kfilnd_tn.c

index 5f8d688..44c580d 100644 (file)
@@ -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();
index 59fe030..04b457f 100644 (file)
@@ -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;