On Wed, Dec 9, 2020 at 5:45 PM Jack Wang <jinpu.wang@xxxxxxxxxxxxxxx> wrote: > > If there are many establishments/teardowns, we need to make sure > we do not consume too much system memory. Thus let on going > session closing to finish before accepting new connection. > > Inspired by commit 777dc82395de ("nvmet-rdma: occasionally flush ongoing controller teardown") > Signed-off-by: Jack Wang <jinpu.wang@xxxxxxxxxxxxxxx> > Reviewed-by: Guoqing Jiang <guoqing.jiang@xxxxxxxxxxxxxxx> Please ignore this one, it could lead to deadlock, due to the fact cma_ib_req_handler is holding mutex_lock(&listen_id->handler_mutex) when calling into rtrs_rdma_connect, we call close_work which will call rdma_destroy_id, which could try to hold the same handler_mutex, so deadlock. Sorry & thanks! Jack > --- > drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c > index ed4628f032bb..0a2202c28b54 100644 > --- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c > +++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c > @@ -1791,6 +1791,10 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, > err = -ENOMEM; > goto reject_w_err; > } > + if (!cid) { > + /* Let inflight session teardown complete */ > + flush_workqueue(rtrs_wq); > + } > mutex_lock(&srv->paths_mutex); > sess = __find_sess(srv, &msg->sess_uuid); > if (sess) { > -- > 2.25.1 >