Commit 891e7f5e authored by Sagi Grimberg's avatar Sagi Grimberg Committed by Kleber Sacilotto de Souza

RDMA/iser: Fix possible mr leak on device removal event

BugLink: http://bugs.launchpad.net/bugs/1745054

[ Upstream commit ea174c95 ]

When the rdma device is removed, we must cleanup all
the rdma resources within the DEVICE_REMOVAL event
handler to let the device teardown gracefully. When
this happens with live I/O, some memory regions are
occupied. Thus, track them too and dereg all the mr's.

We are safe with mr access by iscsi_iser_cleanup_task.
Reported-by: default avatarRaju Rangoju <rajur@chelsio.com>
Signed-off-by: default avatarSagi Grimberg <sagi@grimberg.me>
Reviewed-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Reviewed-by: default avatarMax Gurtovoy <maxg@mellanox.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
parent c2279689
...@@ -450,6 +450,7 @@ struct iser_fr_desc { ...@@ -450,6 +450,7 @@ struct iser_fr_desc {
struct list_head list; struct list_head list;
struct iser_reg_resources rsc; struct iser_reg_resources rsc;
struct iser_pi_context *pi_ctx; struct iser_pi_context *pi_ctx;
struct list_head all_list;
}; };
/** /**
...@@ -463,6 +464,7 @@ struct iser_fr_pool { ...@@ -463,6 +464,7 @@ struct iser_fr_pool {
struct list_head list; struct list_head list;
spinlock_t lock; spinlock_t lock;
int size; int size;
struct list_head all_list;
}; };
/** /**
......
...@@ -405,6 +405,7 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, ...@@ -405,6 +405,7 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn,
int i, ret; int i, ret;
INIT_LIST_HEAD(&fr_pool->list); INIT_LIST_HEAD(&fr_pool->list);
INIT_LIST_HEAD(&fr_pool->all_list);
spin_lock_init(&fr_pool->lock); spin_lock_init(&fr_pool->lock);
fr_pool->size = 0; fr_pool->size = 0;
for (i = 0; i < cmds_max; i++) { for (i = 0; i < cmds_max; i++) {
...@@ -416,6 +417,7 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, ...@@ -416,6 +417,7 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn,
} }
list_add_tail(&desc->list, &fr_pool->list); list_add_tail(&desc->list, &fr_pool->list);
list_add_tail(&desc->all_list, &fr_pool->all_list);
fr_pool->size++; fr_pool->size++;
} }
...@@ -435,13 +437,13 @@ void iser_free_fastreg_pool(struct ib_conn *ib_conn) ...@@ -435,13 +437,13 @@ void iser_free_fastreg_pool(struct ib_conn *ib_conn)
struct iser_fr_desc *desc, *tmp; struct iser_fr_desc *desc, *tmp;
int i = 0; int i = 0;
if (list_empty(&fr_pool->list)) if (list_empty(&fr_pool->all_list))
return; return;
iser_info("freeing conn %p fr pool\n", ib_conn); iser_info("freeing conn %p fr pool\n", ib_conn);
list_for_each_entry_safe(desc, tmp, &fr_pool->list, list) { list_for_each_entry_safe(desc, tmp, &fr_pool->all_list, all_list) {
list_del(&desc->list); list_del(&desc->all_list);
iser_free_reg_res(&desc->rsc); iser_free_reg_res(&desc->rsc);
if (desc->pi_ctx) if (desc->pi_ctx)
iser_free_pi_ctx(desc->pi_ctx); iser_free_pi_ctx(desc->pi_ctx);
......
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