Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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: Raju Rangoju <rajur@chelsio.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Sagi Grimberg and committed by
Doug Ledford
ea174c95 b7363e67

+7 -3
+2
drivers/infiniband/ulp/iser/iscsi_iser.h
··· 430 430 struct list_head list; 431 431 struct iser_reg_resources rsc; 432 432 struct iser_pi_context *pi_ctx; 433 + struct list_head all_list; 433 434 }; 434 435 435 436 /** ··· 444 443 struct list_head list; 445 444 spinlock_t lock; 446 445 int size; 446 + struct list_head all_list; 447 447 }; 448 448 449 449 /**
+5 -3
drivers/infiniband/ulp/iser/iser_verbs.c
··· 362 362 int i, ret; 363 363 364 364 INIT_LIST_HEAD(&fr_pool->list); 365 + INIT_LIST_HEAD(&fr_pool->all_list); 365 366 spin_lock_init(&fr_pool->lock); 366 367 fr_pool->size = 0; 367 368 for (i = 0; i < cmds_max; i++) { ··· 374 373 } 375 374 376 375 list_add_tail(&desc->list, &fr_pool->list); 376 + list_add_tail(&desc->all_list, &fr_pool->all_list); 377 377 fr_pool->size++; 378 378 } 379 379 ··· 394 392 struct iser_fr_desc *desc, *tmp; 395 393 int i = 0; 396 394 397 - if (list_empty(&fr_pool->list)) 395 + if (list_empty(&fr_pool->all_list)) 398 396 return; 399 397 400 398 iser_info("freeing conn %p fr pool\n", ib_conn); 401 399 402 - list_for_each_entry_safe(desc, tmp, &fr_pool->list, list) { 403 - list_del(&desc->list); 400 + list_for_each_entry_safe(desc, tmp, &fr_pool->all_list, all_list) { 401 + list_del(&desc->all_list); 404 402 iser_free_reg_res(&desc->rsc); 405 403 if (desc->pi_ctx) 406 404 iser_free_pi_ctx(desc->pi_ctx);