[PATCH 09/11] drbd_transport_rdma: introduce timeout for rdma_disocnnect
zhengbing.huang
zhengbing.huang at easystack.cn
Mon Jun 24 07:46:17 CEST 2024
From: Dongsheng Yang <dongsheng.yang at easystack.cn>
The rdma driver timeout for dreq is too long in network failure, we can
introduce a timeout for rdma_disconnect().
If timeout we will put kref, and finaly it will go to rdma_destory_id(),
which will cancel all dreq in rdma driver, so dont worry about use-after-free
problem in dtr_cma_event_handler.
Signed-off-by: Dongsheng Yang <dongsheng.yang at easystack.cn>
---
drbd/drbd_transport_rdma.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/drbd/drbd_transport_rdma.c b/drbd/drbd_transport_rdma.c
index c47b344f8..811f1a20a 100644
--- a/drbd/drbd_transport_rdma.c
+++ b/drbd/drbd_transport_rdma.c
@@ -2760,9 +2760,15 @@ static void __dtr_disconnect_path(struct dtr_path *path)
}
/* There might be a signal pending here. Not incorruptible! */
- wait_event_timeout(cm->state_wq,
- !test_bit(DSB_CONNECTED, &cm->state),
- HZ);
+ err = wait_event_timeout(cm->state_wq,
+ !test_bit(DSB_CONNECTED, &cm->state), 20 * HZ);
+
+ if (err == 0 && test_and_clear_bit(DSB_CONNECTED, &cm->state)) {
+ dtr_remove_cm_from_path(path, cm);
+
+ kref_put(&cm->kref, dtr_destroy_cm);
+ clear_bit(TR_ESTABLISHED, &path->path.flags);
+ }
if (test_bit(DSB_CONNECTED, &cm->state))
tr_warn(transport, "WARN: not properly disconnected, state = %lu\n",
--
2.27.0
More information about the drbd-dev
mailing list