Commit 25a033f5 authored by Guoqing Jiang's avatar Guoqing Jiang Committed by Jason Gunthorpe

RDMA/rtrs-clt: Kill wait_for_inflight_permits

Let's wait the inflight permits before free it.

Link: https://lore.kernel.org/r/20201217141915.56989-10-jinpu.wang@cloud.ionos.comSigned-off-by: default avatarGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
Reviewed-by: default avatarMd Haris Iqbal <haris.iqbal@cloud.ionos.com>
Signed-off-by: default avatarJack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent 7b47b27f
...@@ -1318,6 +1318,12 @@ static int alloc_permits(struct rtrs_clt *clt) ...@@ -1318,6 +1318,12 @@ static int alloc_permits(struct rtrs_clt *clt)
static void free_permits(struct rtrs_clt *clt) static void free_permits(struct rtrs_clt *clt)
{ {
if (clt->permits_map) {
size_t sz = clt->queue_depth;
wait_event(clt->permits_wait,
find_first_bit(clt->permits_map, sz) >= sz);
}
kfree(clt->permits_map); kfree(clt->permits_map);
clt->permits_map = NULL; clt->permits_map = NULL;
kfree(clt->permits); kfree(clt->permits);
...@@ -2607,19 +2613,8 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num, ...@@ -2607,19 +2613,8 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num,
return clt; return clt;
} }
static void wait_for_inflight_permits(struct rtrs_clt *clt)
{
if (clt->permits_map) {
size_t sz = clt->queue_depth;
wait_event(clt->permits_wait,
find_first_bit(clt->permits_map, sz) >= sz);
}
}
static void free_clt(struct rtrs_clt *clt) static void free_clt(struct rtrs_clt *clt)
{ {
wait_for_inflight_permits(clt);
free_permits(clt); free_permits(clt);
free_percpu(clt->pcpu_path); free_percpu(clt->pcpu_path);
mutex_destroy(&clt->paths_ev_mutex); mutex_destroy(&clt->paths_ev_mutex);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment