* [PATCH 0/9] Misc patches for RTRS
@ 2026-11-23 14:37 Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter Md Haris Iqbal
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky; +Cc: Md Haris Iqbal
Hi Jason, hi Leon,
Please consider including the following changes in the next merge window.
Benjamin Stürz (1):
RDMA/rtrs-srv: Snapshot the READ request header instead of reusing it
Danil Kipnis (3):
RDMA/rtrs-clt: Add mpath_policy module parameter
RDMA/rtrs-clt: rename pathname parameter to sessname in
rtrs_clt_open()
RDMA/rtrs-clt: Back off the reconnect delay exponentially
Grzegorz Prajsner (1):
RDMA/rtrs-srv: Fix processing messages for Big-Endian archs
Jack Wang (2):
RDMA/rtrs-clt: Fix refcount imbalance in rtrs_clt_write_req error path
RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails
Md Haris Iqbal (2):
RDMA/rtrs-clt: Fix reconnect jitter being applied in milliseconds
RDMA/rtrs-clt: Close all paths before freeing any in rtrs_clt_close()
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 132 +++++++++++++++++++------
drivers/infiniband/ulp/rtrs/rtrs-srv.c | 38 +++----
drivers/infiniband/ulp/rtrs/rtrs-srv.h | 13 ++-
drivers/infiniband/ulp/rtrs/rtrs.h | 2 +-
4 files changed, 137 insertions(+), 48 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 14:44 ` sashiko-bot
2026-11-23 14:37 ` [PATCH 2/9] RDMA/rtrs-clt: Fix refcount imbalance in rtrs_clt_write_req error path Md Haris Iqbal
` (8 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Danil Kipnis, Jack Wang, Md Haris Iqbal
From: Danil Kipnis <danil.kipnis1@ionos.com>
Add a module parameter to set the default multipath policy for newly
created sessions. This simplifies configuration when all sessions should
use the same policy, allowing administrators to set the default at module
load time or boot time via kernel parameters.
The parameter accepts numeric values 0-2:
- 0: Round-robin (MP_POLICY_RR)
- 1: Minimum inflight requests (MP_POLICY_MIN_INFLIGHT) - default
- 2: Minimum latency (MP_POLICY_MIN_LATENCY)
Invalid values are clamped to the valid range. The parameter is runtime
adjustable via /sys/module/rtrs_client/parameters/mpath_policy, affecting
only newly created sessions. Existing sessions retain their current policy.
The per-session sysfs interface remains fully functional for session-
specific overrides, maintaining backward compatibility.
Signed-off-by: Danil Kipnis <danil.kipnis1@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index bf3a0377da3f..573beb5ccdf0 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -39,6 +39,13 @@
MODULE_DESCRIPTION("RDMA Transport Client");
MODULE_LICENSE("GPL");
+static int mpath_policy = MP_POLICY_MIN_INFLIGHT;
+module_param_named(mpath_policy, mpath_policy, int, 0644);
+MODULE_PARM_DESC(mpath_policy,
+ "Default multipath policy for new sessions (default: "
+ __stringify(MP_POLICY_MIN_INFLIGHT)
+ " (min-inflight), 0: round-robin, 1: min-inflight, 2: min-latency)");
+
static const struct rtrs_rdma_dev_pd_ops dev_pd_ops;
static struct rtrs_rdma_dev_pd dev_pd = {
.ops = &dev_pd_ops
@@ -2758,7 +2765,7 @@ static struct rtrs_clt_sess *alloc_clt(const char *sessname, size_t paths_num,
clt->max_reconnect_attempts = max_reconnect_attempts;
clt->priv = priv;
clt->link_ev = link_ev;
- clt->mp_policy = MP_POLICY_MIN_INFLIGHT;
+ clt->mp_policy = mpath_policy;
strscpy(clt->sessname, sessname, sizeof(clt->sessname));
init_waitqueue_head(&clt->permits_wait);
mutex_init(&clt->paths_ev_mutex);
@@ -3220,6 +3227,10 @@ static int __init rtrs_client_init(void)
int ret = 0;
rtrs_rdma_dev_pd_init(0, &dev_pd);
+
+ /* Validate and clamp mpath_policy to valid range */
+ mpath_policy = clamp(mpath_policy, MP_POLICY_RR, MP_POLICY_MIN_LATENCY);
+
ret = class_register(&rtrs_clt_dev_class);
if (ret) {
pr_err("Failed to create rtrs-client dev class\n");
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 2/9] RDMA/rtrs-clt: Fix refcount imbalance in rtrs_clt_write_req error path
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails Md Haris Iqbal
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Jack Wang, Roman Penyaev, Md Haris Iqbal
From: Jack Wang <jinpu.wang@ionos.com>
When commit bab9f8db4295 ("RDMA/rtrs-clt: Do local invalidate after write
io completion") removed the chained LOCAL_INV WR for write requests, it
deleted the matching refcount_inc(&req->ref) under the
"req->mr->need_inval = true" assignment. The corresponding
refcount_dec(&req->ref) in the rtrs_post_rdma_write_sg() error path was
left behind, creating a refcount imbalance.
On synchronous post failure (e.g. -ENOMEM from ib_post_send()) the
refcount drops from 1 to 0 via refcount_dec(), which is annotated to
WARN ("decrement hit 0; leaking memory") because callers should use
refcount_dec_and_test() in that situation. The req is then reset to 1
on the next rtrs_clt_init_req(), but the WARN still fires and the
imbalance can race with an in-flight invalidate completion during
failover.
Drop the orphan refcount_dec(); clearing need_inval is sufficient.
Fixes: bab9f8db4295 ("RDMA/rtrs-clt: Do local invalidate after write io completion")
Reviewed-by: Roman Penyaev <roman.penyaev@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 573beb5ccdf0..de226e6ba124 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -1163,10 +1163,8 @@ static int rtrs_clt_write_req(struct rtrs_clt_io_req *req)
clt_path->hca_name, clt_path->hca_port);
if (req->mp_policy == MP_POLICY_MIN_INFLIGHT)
atomic_dec(&clt_path->stats->inflight);
- if (req->mr->need_inval) {
+ if (req->mr->need_inval)
req->mr->need_inval = false;
- refcount_dec(&req->ref);
- }
if (req->sg_cnt)
ib_dma_unmap_sg(clt_path->s.dev->ib_dev, req->sglist,
req->sg_cnt, req->dir);
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 2/9] RDMA/rtrs-clt: Fix refcount imbalance in rtrs_clt_write_req error path Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 15:02 ` sashiko-bot
2026-11-23 14:37 ` [PATCH 4/9] RDMA/rtrs-srv: Fix processing messages for Big-Endian archs Md Haris Iqbal
` (6 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Jack Wang, Roman Penyaev, Md Haris Iqbal
From: Jack Wang <jinpu.wang@ionos.com>
When ib_post_send() rejects the LOCAL_INV WR synchronously
(e.g. -ENOMEM on a full SQ), no completion will ever fire, but
complete_rdma_req() previously just logged the error and returned
early via refcount_dec_and_test() (count goes 2->1, returns false).
That left the request with need_inval=true forever, the rkey live
on the HCA, the DMA mapping pinned, and req->conf never invoked.
A subsequent reuse of the same permit/req would call
rtrs_clt_init_req() which blindly resets need_inval=false; combined
with the still-live rkey on the HCA this is the kind of state
mismatch that has previously surfaced as LOCAL_PROT_ERR.
On synchronous post failure: clear need_inval (we genuinely cannot
invalidate from this context) and call rtrs_rdma_error_recovery() so
the path goes to RECONNECTING, fail_all_outstanding_reqs() runs, and
complete_rdma_req(can_wait=true) reaps the request cleanly with DMA
unmap + failover. The refcount path is unchanged on success and now
matches the success-path early-return shape on failure.
Fixes: 2ece9ec62e5b ("RDMA/rtrs-clt: Write path fast memory registration")
Reviewed-by: Roman Penyaev <roman.penyaev@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index de226e6ba124..5ef912a472cd 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -436,6 +436,19 @@ static void complete_rdma_req(struct rtrs_clt_io_req *req, int errno,
if (err) {
rtrs_err_rl(con->c.path, "Send INV WR key=%#x: %pe\n",
req->mr->rkey, ERR_PTR(err));
+ /*
+ * No LOCAL_INV completion will fire, so the
+ * rkey is still live on the HCA but we cannot
+ * invalidate it from this context. Clear
+ * need_inval so subsequent reapers don't
+ * wait on an invalidate that will never
+ * happen, and kick off error recovery so the
+ * QP (and MR) is torn down cleanly via
+ * fail_all_outstanding_reqs() ->
+ * complete_rdma_req(can_wait=true).
+ */
+ req->mr->need_inval = false;
+ rtrs_rdma_error_recovery(con);
} else if (can_wait) {
wait_for_completion(&req->inv_comp);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 4/9] RDMA/rtrs-srv: Fix processing messages for Big-Endian archs
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
` (2 preceding siblings ...)
2026-11-23 14:37 ` [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open() Md Haris Iqbal
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Grzegorz Prajsner, Md Haris Iqbal
From: Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
Convert msg->sg_cnt from le16 to cpu endianness before processing
it. This fixes bug processing messages on Big-Endian architectures.
Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality")
Signed-off-by: Grzegorz Prajsner <grzegorz.prajsner@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
index 5314599d29fe..7a47b90e8539 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
@@ -1045,7 +1045,7 @@ static void process_read(struct rtrs_srv_con *con,
struct rtrs_srv_ctx *ctx = srv->ctx;
struct rtrs_srv_op *id;
- size_t usr_len, data_len;
+ size_t usr_len, data_len, sg_cnt;
void *data;
int ret;
@@ -1055,7 +1055,8 @@ static void process_read(struct rtrs_srv_con *con,
rtrs_srv_state_str(srv_path->state));
return;
}
- if (msg->sg_cnt != 1 && msg->sg_cnt != 0) {
+ sg_cnt = le16_to_cpu(msg->sg_cnt);
+ if (sg_cnt != 1 && sg_cnt != 0) {
rtrs_err_rl(s,
"Processing read request failed, invalid message\n");
return;
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open()
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
` (3 preceding siblings ...)
2026-11-23 14:37 ` [PATCH 4/9] RDMA/rtrs-srv: Fix processing messages for Big-Endian archs Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 14:42 ` sashiko-bot
2026-11-23 14:37 ` [PATCH 6/9] RDMA/rtrs-clt: Fix reconnect jitter being applied in milliseconds Md Haris Iqbal
` (4 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Danil Kipnis, Jack Wang, Md Haris Iqbal
From: Danil Kipnis <danil.kipnis1@ionos.com>
The parameter has always referred to the RTRS session name, not a
filesystem path. Rename it to sessname throughout the API declaration
in rtrs.h and the implementation in rtrs-clt.c for clarity.
Signed-off-by: Danil Kipnis <danil.kipnis1@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 10 +++++-----
drivers/infiniband/ulp/rtrs/rtrs.h | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 5ef912a472cd..c059d69c3e5a 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -2832,7 +2832,7 @@ static void free_clt(struct rtrs_clt_sess *clt)
/**
* rtrs_clt_open() - Open a path to an RTRS server
* @ops: holds the link event callback and the private pointer.
- * @pathname: name of the path to an RTRS server
+ * @sessname: name of the RTRS session
* @paths: Paths to be established defined by their src and dst addresses
* @paths_num: Number of elements in the @paths array
* @port: port to be used by the RTRS session
@@ -2848,7 +2848,7 @@ static void free_clt(struct rtrs_clt_sess *clt)
* Return a valid pointer on success otherwise PTR_ERR.
*/
struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
- const char *pathname,
+ const char *sessname,
const struct rtrs_addr *paths,
size_t paths_num, u16 port,
size_t pdu_sz, u8 reconnect_delay_sec,
@@ -2858,13 +2858,13 @@ struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
struct rtrs_clt_sess *clt;
int err, i;
- if (strchr(pathname, '/') || strchr(pathname, '.')) {
- pr_err("pathname cannot contain / and .\n");
+ if (strchr(sessname, '/') || strchr(sessname, '.')) {
+ pr_err("sessname cannot contain / and .\n");
err = -EINVAL;
goto out;
}
- clt = alloc_clt(pathname, paths_num, port, pdu_sz, ops->priv,
+ clt = alloc_clt(sessname, paths_num, port, pdu_sz, ops->priv,
ops->link_ev,
reconnect_delay_sec,
max_reconnect_attempts);
diff --git a/drivers/infiniband/ulp/rtrs/rtrs.h b/drivers/infiniband/ulp/rtrs/rtrs.h
index b5bd35712de0..0ae78b28986e 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs.h
+++ b/drivers/infiniband/ulp/rtrs/rtrs.h
@@ -55,7 +55,7 @@ struct rtrs_clt_ops {
};
struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
- const char *pathname,
+ const char *sessname,
const struct rtrs_addr *paths,
size_t path_cnt, u16 port,
size_t pdu_sz, u8 reconnect_delay_sec,
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 6/9] RDMA/rtrs-clt: Fix reconnect jitter being applied in milliseconds
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
` (4 preceding siblings ...)
2026-11-23 14:37 ` [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open() Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 7/9] RDMA/rtrs-clt: Back off the reconnect delay exponentially Md Haris Iqbal
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky; +Cc: Md Haris Iqbal, Jack Wang
RTRS_RECONNECT_SEED was introduced to spread reconnect attempts of
different clients over an 8 second window, so that a major network
outage does not make all of them hammer the server at the same moment.
The random value is however added to delay_ms, which is already in
milliseconds, before the sum is converted with msecs_to_jiffies():
delay_ms = clt->reconnect_delay_sec * 1000;
queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork,
msecs_to_jiffies(delay_ms +
get_random_u32_below(RTRS_RECONNECT_SEED)));
With the seed defined as 8, the jitter is therefore 0 to 7
milliseconds instead of the intended 0 to 8 seconds, which is far too
small to stagger reconnects and leaves the thundering herd it was
meant to prevent.
Define the seed in milliseconds, matching RTRS_RECONNECT_BACKOFF and
the unit of the expression it is added to, and reword the comment to
state the resulting half open range.
Fixes: 09e0dbbeed82 ("RDMA/rtrs-clt: add an additional random 8 seconds before reconnecting")
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index c059d69c3e5a..54d72fa52cb1 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -26,11 +26,13 @@
*/
#define RTRS_RECONNECT_BACKOFF 1000
/*
- * Wait for additional random time between 0 and 8 seconds
+ * Wait for additional random time in the range [0, 8) seconds
* before starting to reconnect to avoid clients reconnecting
- * all at once in case of a major network outage
+ * all at once in case of a major network outage.
+ * Expressed in milliseconds, like RTRS_RECONNECT_BACKOFF, since
+ * it is added to a millisecond delay before conversion to jiffies.
*/
-#define RTRS_RECONNECT_SEED 8
+#define RTRS_RECONNECT_SEED 8000
#define FIRST_CONN 0x01
/* limit to 128 * 4k = 512k max IO */
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 7/9] RDMA/rtrs-clt: Back off the reconnect delay exponentially
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
` (5 preceding siblings ...)
2026-11-23 14:37 ` [PATCH 6/9] RDMA/rtrs-clt: Fix reconnect jitter being applied in milliseconds Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 8/9] RDMA/rtrs-srv: Snapshot the READ request header instead of reusing it Md Haris Iqbal
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Danil Kipnis, Md Haris Iqbal, Jack Wang
From: Danil Kipnis <danil.kipnis1@ionos.com>
A path that loses its link waits out the full, flat reconnect_delay_sec
(30s on rnbd, + 0-8s jitter) before its first retry, and every retry
after that, no matter how quickly the far end actually comes back.
Nothing about that delay depends on how the path went down:
rtrs_clt_err_recovery_work() runs the same way whether the trigger was a
CM disconnect, a heartbeat timeout, or a port error, so a transient blip
pays the same price as a genuinely dead fabric.
Start the delay at RTRS_RECONNECT_BACKOFF_INIT_MS (1s) after the first
failure and double it on each further consecutive failure, capped at the
configured reconnect_delay_sec, which becomes the steady-state ceiling
rather than a constant. reconnect_attempts already counts consecutive
failures since the path last came up and already resets to 0 in
rtrs_clt_path_up() on success, so it doubles as the backoff step with no
new per-path state. The existing anti-herd jitter (RTRS_RECONNECT_SEED)
is kept as-is on top of every step. RTRS_RECONNECT_BACKOFF_MAX_SHIFT (8)
only bounds the shift below reconnect_delay_sec's u8 range (max 255s);
it is a safety margin, not a behavior knob.
Signed-off-by: Danil Kipnis <danil.kipnis1@ionos.com>
Reviewed-by: Md Haris Iqbal <haris.iqbal@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 35 ++++++++++++++++++++++++--
1 file changed, 33 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 54d72fa52cb1..7930039dcd32 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -34,6 +34,26 @@
*/
#define RTRS_RECONNECT_SEED 8000
+/*
+ * Delay before the first reconnect attempt after a failure, doubled on each
+ * further consecutive failure and capped at reconnect_delay_sec. Lets a path
+ * that recovers quickly (a transient CM error, a brief port flap) start
+ * retrying off this short initial delay instead of the full configured
+ * delay, while a path facing a genuinely dead fabric still settles at the
+ * same steady state as before. RTRS_RECONNECT_SEED jitter is added on top
+ * of every attempt as before, so the actual first retry lands anywhere in
+ * [RTRS_RECONNECT_BACKOFF_INIT_MS, RTRS_RECONNECT_BACKOFF_INIT_MS +
+ * RTRS_RECONNECT_SEED).
+ */
+/* Matches RTRS_RECONNECT_BACKOFF's value by coincidence, not by shared purpose. */
+#define RTRS_RECONNECT_BACKOFF_INIT_MS 1000
+/*
+ * Shifting RTRS_RECONNECT_BACKOFF_INIT_MS by more than this always exceeds
+ * reconnect_delay_sec's range (u8, so at most 255000 ms); capping the shift
+ * avoids relying on shift-by-large-amount being well defined.
+ */
+#define RTRS_RECONNECT_BACKOFF_MAX_SHIFT 8
+
#define FIRST_CONN 0x01
/* limit to 128 * 4k = 512k max IO */
#define RTRS_MAX_SEGMENTS 128
@@ -1537,11 +1557,22 @@ static void rtrs_clt_err_recovery_work(struct work_struct *work)
{
struct rtrs_clt_path *clt_path;
struct rtrs_clt_sess *clt;
- int delay_ms;
+ unsigned int shift;
+ u32 delay_ms;
clt_path = container_of(work, struct rtrs_clt_path, err_recovery_work);
clt = clt_path->clt;
- delay_ms = clt->reconnect_delay_sec * 1000;
+ /*
+ * reconnect_attempts counts consecutive failures since the path last
+ * came up (rtrs_clt_path_up() resets it to 0), so it doubles as the
+ * backoff step: 0 failures so far -> the initial delay, each further
+ * failure doubles it, capped once it reaches the configured steady
+ * state delay.
+ */
+ shift = min_t(unsigned int, clt_path->reconnect_attempts,
+ RTRS_RECONNECT_BACKOFF_MAX_SHIFT);
+ delay_ms = min_t(u32, clt->reconnect_delay_sec * 1000,
+ RTRS_RECONNECT_BACKOFF_INIT_MS << shift);
rtrs_clt_stop_and_destroy_conns(clt_path);
queue_delayed_work(rtrs_wq, &clt_path->reconnect_dwork,
msecs_to_jiffies(delay_ms +
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 8/9] RDMA/rtrs-srv: Snapshot the READ request header instead of reusing it
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
` (6 preceding siblings ...)
2026-11-23 14:37 ` [PATCH 7/9] RDMA/rtrs-clt: Back off the reconnect delay exponentially Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 9/9] RDMA/rtrs-clt: Close all paths before freeing any in rtrs_clt_close() Md Haris Iqbal
2026-11-23 15:02 ` [PATCH 0/9] Misc patches for RTRS sashiko-bot
9 siblings, 0 replies; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Benjamin Stürz, Jack Wang, Md Haris Iqbal
From: Benjamin Stürz <benjamin.stuerz@ionos.com>
process_read() validates the READ request header and then keeps a
pointer to it in srv->chunks[buf_id]. The client's permits normally keep
that chunk stable until the server responds, but the server does not
enforce it: once the client gives up on a request and releases the
permit, the chunk is reused for an unrelated I/O, while a slow backend
can leave the original operation in flight on a path the server has not
yet declared dead.
rdma_write_sg(), send_io_resp_imm() and rtrs_srv_resp_rdma() re-read
sg_cnt, the invalidate flag and the descriptor from there at completion
time, so they act on whatever now lives at that offset. The RDMA write
can then go to another request's remote address with its length and
rkey, or the response can invalidate the wrong rkey.
Snapshot sg_cnt, the invalidate flag and the descriptor into
rtrs_srv_op when the request arrives, and drop rd_msg. The WRITE path
reads none of them, so nothing needs clearing there.
Fixes: 9cb837480424 ("RDMA/rtrs: server: main functionality")
Signed-off-by: Benjamin Stürz <benjamin.stuerz@ionos.com>
Reviewed-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-srv.c | 33 ++++++++++++++------------
drivers/infiniband/ulp/rtrs/rtrs-srv.h | 13 +++++++++-
2 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.c b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
index 7a47b90e8539..c1c76ec65d0f 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c
@@ -210,8 +210,8 @@ static int rdma_write_sg(struct rtrs_srv_op *id)
struct ib_sge *plist;
struct ib_sge list;
- sg_cnt = le16_to_cpu(id->rd_msg->sg_cnt);
- need_inval = le16_to_cpu(id->rd_msg->flags) & RTRS_MSG_NEED_INVAL_F;
+ sg_cnt = id->sg_cnt;
+ need_inval = id->need_inval;
if (sg_cnt != 1)
return -EINVAL;
@@ -220,7 +220,7 @@ static int rdma_write_sg(struct rtrs_srv_op *id)
wr = &id->tx_wr;
plist = &id->tx_sg;
plist->addr = dma_addr + offset;
- plist->length = le32_to_cpu(id->rd_msg->desc[0].len);
+ plist->length = le32_to_cpu(id->desc.len);
/* WR will fail with length error
* if this is 0
@@ -236,8 +236,8 @@ static int rdma_write_sg(struct rtrs_srv_op *id)
wr->wr.sg_list = plist;
wr->wr.num_sge = 1;
- wr->remote_addr = le64_to_cpu(id->rd_msg->desc[0].addr);
- wr->rkey = le32_to_cpu(id->rd_msg->desc[0].key);
+ wr->remote_addr = le64_to_cpu(id->desc.addr);
+ wr->rkey = le32_to_cpu(id->desc.key);
wr->wr.opcode = IB_WR_RDMA_WRITE;
wr->wr.wr_cqe = &io_comp_cqe;
@@ -347,15 +347,10 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id,
int err;
if (id->dir == READ) {
- struct rtrs_msg_rdma_read *rd_msg = id->rd_msg;
- size_t sg_cnt;
-
- need_inval = le16_to_cpu(rd_msg->flags) &
- RTRS_MSG_NEED_INVAL_F;
- sg_cnt = le16_to_cpu(rd_msg->sg_cnt);
+ need_inval = id->need_inval;
if (need_inval) {
- if (sg_cnt) {
+ if (id->sg_cnt) {
inv_wr.wr_cqe = &io_comp_cqe;
inv_wr.sg_list = NULL;
inv_wr.num_sge = 0;
@@ -363,7 +358,7 @@ static int send_io_resp_imm(struct rtrs_srv_con *con, struct rtrs_srv_op *id,
inv_wr.send_flags = 0;
/* Only one key is actually used */
inv_wr.ex.invalidate_rkey =
- le32_to_cpu(rd_msg->desc[0].key);
+ le32_to_cpu(id->desc.key);
} else {
WARN_ON_ONCE(1);
need_inval = false;
@@ -512,7 +507,7 @@ bool rtrs_srv_resp_rdma(struct rtrs_srv_op *id, int status)
return false;
}
- if (status || id->dir == WRITE || !id->rd_msg->sg_cnt)
+ if (status || id->dir == WRITE || !id->sg_cnt)
err = send_io_resp_imm(con, id, status);
else
err = rdma_write_sg(id);
@@ -1072,7 +1067,15 @@ static void process_read(struct rtrs_srv_con *con,
id->con = con;
id->dir = READ;
id->msg_id = buf_id;
- id->rd_msg = msg;
+ /*
+ * Take a private copy of everything we still need once the I/O
+ * completes: by then the chunk is not guaranteed to still hold
+ * this request's header, see struct rtrs_srv_op.
+ */
+ id->sg_cnt = sg_cnt;
+ id->need_inval = le16_to_cpu(msg->flags) & RTRS_MSG_NEED_INVAL_F;
+ if (sg_cnt)
+ id->desc = msg->desc[0];
data_len = off - usr_len;
data = page_address(srv->chunks[buf_id]);
ret = ctx->ops.rdma_ev(srv->priv, id, data, data_len,
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-srv.h b/drivers/infiniband/ulp/rtrs/rtrs-srv.h
index 3d36876527f5..bf27e01402d1 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-srv.h
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.h
@@ -52,7 +52,18 @@ struct rtrs_srv_op {
struct rtrs_srv_con *con;
u32 msg_id;
u8 dir;
- struct rtrs_msg_rdma_read *rd_msg;
+ /*
+ * Snapshot of the READ request header, taken when the request is
+ * received and validated. The client's permits normally keep the
+ * chunk stable until we respond, but that is the client's
+ * bookkeeping and not something we enforce: reconnect and failover
+ * edge cases can leave the chunk rewritten by a newer request while
+ * this I/O is still running. The completion path must use this copy
+ * and never read srv->chunks[msg_id] back.
+ */
+ bool need_inval;
+ u16 sg_cnt;
+ struct rtrs_sg_desc desc;
struct ib_rdma_wr tx_wr;
struct ib_sge tx_sg;
struct list_head wait_list;
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 9/9] RDMA/rtrs-clt: Close all paths before freeing any in rtrs_clt_close()
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
` (7 preceding siblings ...)
2026-11-23 14:37 ` [PATCH 8/9] RDMA/rtrs-srv: Snapshot the READ request header instead of reusing it Md Haris Iqbal
@ 2026-11-23 14:37 ` Md Haris Iqbal
2026-11-23 15:02 ` [PATCH 0/9] Misc patches for RTRS sashiko-bot
9 siblings, 0 replies; 14+ messages in thread
From: Md Haris Iqbal @ 2026-11-23 14:37 UTC (permalink / raw)
To: linux-rdma, Jason Gunthorpe, Leon Romanovsky
Cc: Md Haris Iqbal, Shuangpeng Bai
rtrs_clt_close() closes and frees the paths one at a time. Meanwhile, the
paths that are not closed yet can still walk clt->paths_list: a reconnect
fires link_ev(RECONNECTED), whose handler calls rtrs_clt_query(), and a
closing path fails its requests over through rtrs_clt_failover_req().
Either can then touch a path that is already freed:
BUG: KASAN: slab-use-after-free in rtrs_clt_query
Workqueue: rtrs_client_wq rtrs_clt_reconnect_work
rtrs_clt_query
rnbd_clt_link_ev
init_path
rtrs_clt_reconnect_work
Move every path to CLOSING first, wait for all close works, and only then
unlink and free the paths. A close work cancels the reconnect work of its
path synchronously, so no path is freed while another one still uses the
list.
rtrs_clt_open() tears down its paths on error the same way, so move the
sequence into rtrs_clt_destroy_all_paths() and use it from both, with
sysfs torn down first.
Fixes: 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
Reported-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
Closes: https://lore.kernel.org/linux-rdma/20261105202939.3104321-1-shuangpeng.kernel@gmail.com/
Signed-off-by: Md Haris Iqbal <haris.iqbal@ionos.com>
---
drivers/infiniband/ulp/rtrs/rtrs-clt.c | 49 ++++++++++++++++++--------
1 file changed, 34 insertions(+), 15 deletions(-)
diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
index 7930039dcd32..760ae71c9230 100644
--- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
+++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
@@ -2862,6 +2862,38 @@ static void free_clt(struct rtrs_clt_sess *clt)
device_unregister(&clt->dev);
}
+/*
+ * Close and free every path of @clt. The caller has torn down sysfs, so
+ * no paths can be added or removed, and does not use the session any more
+ * (no IO, no rtrs_clt_query()).
+ *
+ * Until its close work has finished, a path can still reconnect (firing
+ * link_ev, whose user may call rtrs_clt_query()) or fail requests over,
+ * and both walk clt->paths_list. So move every path to CLOSING first,
+ * which keeps further reconnect attempts from starting, wait for all of
+ * them, and only then free.
+ */
+static void rtrs_clt_destroy_all_paths(struct rtrs_clt_sess *clt)
+{
+ struct rtrs_clt_path *clt_path, *tmp;
+
+ list_for_each_entry(clt_path, &clt->paths_list, s.entry)
+ rtrs_clt_close_conns(clt_path, false);
+ list_for_each_entry(clt_path, &clt->paths_list, s.entry)
+ flush_work(&clt_path->close_work);
+
+ /*
+ * The close works have flushed every reconnect and stopped the
+ * heartbeat, and the caller issues nothing, so nobody walks the list
+ * any more and no grace period is needed.
+ */
+ list_for_each_entry_safe(clt_path, tmp, &clt->paths_list, s.entry) {
+ list_del(&clt_path->s.entry);
+ rtrs_clt_destroy_path_files(clt_path, NULL);
+ kobject_put(&clt_path->kobj);
+ }
+}
+
/**
* rtrs_clt_open() - Open a path to an RTRS server
* @ops: holds the link event callback and the private pointer.
@@ -2887,7 +2919,6 @@ struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
size_t pdu_sz, u8 reconnect_delay_sec,
s16 max_reconnect_attempts, u32 nr_poll_queues)
{
- struct rtrs_clt_path *clt_path, *tmp;
struct rtrs_clt_sess *clt;
int err, i;
@@ -2943,12 +2974,8 @@ struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
return clt;
close_all_path:
- list_for_each_entry_safe(clt_path, tmp, &clt->paths_list, s.entry) {
- rtrs_clt_destroy_path_files(clt_path, NULL);
- rtrs_clt_close_conns(clt_path, true);
- kobject_put(&clt_path->kobj);
- }
rtrs_clt_destroy_sysfs_root(clt);
+ rtrs_clt_destroy_all_paths(clt);
free_clt(clt);
out:
@@ -2962,17 +2989,9 @@ EXPORT_SYMBOL(rtrs_clt_open);
*/
void rtrs_clt_close(struct rtrs_clt_sess *clt)
{
- struct rtrs_clt_path *clt_path, *tmp;
-
/* Firstly forbid sysfs access */
rtrs_clt_destroy_sysfs_root(clt);
-
- /* Now it is safe to iterate over all paths without locks */
- list_for_each_entry_safe(clt_path, tmp, &clt->paths_list, s.entry) {
- rtrs_clt_close_conns(clt_path, true);
- rtrs_clt_destroy_path_files(clt_path, NULL);
- kobject_put(&clt_path->kobj);
- }
+ rtrs_clt_destroy_all_paths(clt);
free_permits(clt);
free_clt(clt);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open()
2026-11-23 14:37 ` [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open() Md Haris Iqbal
@ 2026-11-23 14:42 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-23 14:42 UTC (permalink / raw)
To: Md Haris Iqbal, linux-rdma
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] RDMA/rtrs-clt: use-after-free in rtrs_clt_open() [1]
--
commit d270a6058ae45a4fbd952be02c065eb235215fda
Author: Danil Kipnis <danil.kipnis1@ionos.com>
RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open()
This commit renames the pathname parameter of rtrs_clt_open() to sessname
in the header declaration and implementation.
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index 5ef912a472cda..c059d69c3e5a3 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
[ ... ]
> @@ -2848,7 +2848,7 @@ static void free_clt(struct rtrs_clt_sess *clt)
> * Return a valid pointer on success otherwise PTR_ERR.
> */
> struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
> - const char *pathname,
> + const char *sessname,
> const struct rtrs_addr *paths,
> size_t paths_num, u16 port,
> size_t pdu_sz, u8 reconnect_delay_sec,
> @@ -2858,13 +2858,13 @@ struct rtrs_clt_sess *rtrs_clt_open(struct rtrs_clt_ops *ops,
> struct rtrs_clt_sess *clt;
> int err, i;
>
> - if (strchr(pathname, '/') || strchr(pathname, '.')) {
> - pr_err("pathname cannot contain / and .\n");
> + if (strchr(sessname, '/') || strchr(sessname, '.')) {
> + pr_err("sessname cannot contain / and .\n");
> err = -EINVAL;
> goto out;
> }
>
> - clt = alloc_clt(pathname, paths_num, port, pdu_sz, ops->priv,
> + clt = alloc_clt(sessname, paths_num, port, pdu_sz, ops->priv,
> ops->link_ev,
> reconnect_delay_sec,
> max_reconnect_attempts);
[Severity: Critical]
This problem wasn't introduced by this patch, but can a failure in
rtrs_clt_create_path_files() later in rtrs_clt_open() cause a
use-after-free and double free of clt_path [1]?
When kobject_init_and_add() fails in rtrs_clt_create_path_files(), it
calls kobject_put(&clt_path->kobj), which invokes rtrs_clt_path_release()
and frees clt_path via free_path():
drivers/infiniband/ulp/rtrs/rtrs-clt-sysfs.c:rtrs_clt_create_path_files() {
...
err = kobject_init_and_add(&clt_path->kobj, &ktype_sess,
clt->kobj_paths,
"%s", str);
if (err) {
pr_err("kobject_init_and_add: %pe\n", ERR_PTR(err));
kobject_put(&clt_path->kobj);
return err;
}
...
}
rtrs_clt_open() then touches the freed clt_path in list_del_rcu(),
rtrs_clt_close_conns(), and free_percpu() before calling free_path() a
second time:
drivers/infiniband/ulp/rtrs/rtrs-clt.c:rtrs_clt_open() {
...
err = rtrs_clt_create_path_files(clt_path);
if (err) {
list_del_rcu(&clt_path->s.entry);
rtrs_clt_close_conns(clt_path, true);
free_percpu(clt_path->stats->pcpu_stats);
free_path(clt_path);
goto close_all_path;
}
...
}
[1] https://sashiko.dev/#/bug/linux-982ecccb-b1ca-401f-8293-d1973992f3f6
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123143719.938876-1-haris.iqbal@ionos.com?part=5
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter
2026-11-23 14:37 ` [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter Md Haris Iqbal
@ 2026-11-23 14:44 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-23 14:44 UTC (permalink / raw)
To: Md Haris Iqbal, linux-rdma
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] RDMA/rtrs-clt: unclamped runtime sysfs writes to mpath_policy
in alloc_clt()
- [Low] RDMA/rtrs-clt: __stringify() on enum MP_POLICY_MIN_INFLIGHT in
MODULE_PARM_DESC
--
commit 9f1bdddc73a41e6280e607ffdea1faff0f78b52e
Author: Danil Kipnis <danil.kipnis1@ionos.com>
RDMA/rtrs-clt: Add mpath_policy module parameter
This commit adds a runtime-adjustable mpath_policy module parameter to
configure the default multipath policy for newly created RTRS client
sessions.
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index bf3a0377da3ff..573beb5ccdf07 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -39,6 +39,13 @@
> MODULE_DESCRIPTION("RDMA Transport Client");
> MODULE_LICENSE("GPL");
>
> +static int mpath_policy = MP_POLICY_MIN_INFLIGHT;
> +module_param_named(mpath_policy, mpath_policy, int, 0644);
> +MODULE_PARM_DESC(mpath_policy,
> + "Default multipath policy for new sessions (default: "
> + __stringify(MP_POLICY_MIN_INFLIGHT)
> + " (min-inflight), 0: round-robin, 1: min-inflight, 2: min-latency)");
[Severity: Low]
Does __stringify(MP_POLICY_MIN_INFLIGHT) expand to the literal token name
"MP_POLICY_MIN_INFLIGHT" in modinfo rather than "1"?
MP_POLICY_MIN_INFLIGHT is an enum constant in enum rtrs_mp_policy, not a
preprocessor macro.
> @@ -2758,7 +2765,7 @@ static struct rtrs_clt_sess *alloc_clt(const char *sessname, size_t paths_num,
> clt->max_reconnect_attempts = max_reconnect_attempts;
> clt->priv = priv;
> clt->link_ev = link_ev;
> - clt->mp_policy = MP_POLICY_MIN_INFLIGHT;
> + clt->mp_policy = mpath_policy;
> strscpy(clt->sessname, sessname, sizeof(clt->sessname));
> init_waitqueue_head(&clt->permits_wait);
> mutex_init(&clt->paths_ev_mutex);
> @@ -3220,6 +3227,10 @@ static int __init rtrs_client_init(void)
> int ret = 0;
>
> rtrs_rdma_dev_pd_init(0, &dev_pd);
> +
> + /* Validate and clamp mpath_policy to valid range */
> + mpath_policy = clamp(mpath_policy, MP_POLICY_RR, MP_POLICY_MIN_LATENCY);
> +
> ret = class_register(&rtrs_clt_dev_class);
> if (ret) {
> pr_err("Failed to create rtrs-client dev class\n");
[Severity: Medium]
Does clamping mpath_policy only in rtrs_client_init() leave runtime writes
to /sys/module/rtrs_client/parameters/mpath_policy unclamped?
Because mpath_policy uses mode 0644 with standard param_ops_int, writing
an out-of-range value via sysfs after module load stores that value
directly into clt->mp_policy in alloc_clt(). New sessions then report
"Unknown (<val>)" in mpath_policy_show(), and negative values fall through
path_it_init() to get_next_path_min_latency instead of clamping to
MP_POLICY_RR.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123143719.938876-1-haris.iqbal@ionos.com?part=1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails
2026-11-23 14:37 ` [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails Md Haris Iqbal
@ 2026-11-23 15:02 ` sashiko-bot
0 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-23 15:02 UTC (permalink / raw)
To: Md Haris Iqbal, linux-rdma
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] RDMA/rtrs-clt: early return in complete_rdma_req() leaks DMA
mappings
--
commit 61b2b66e033c3217c1bebe6348e99899004f5550
Author: Jack Wang <jinpu.wang@ionos.com>
RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails
This commit clears req->mr->need_inval and triggers RDMA error recovery
when rtrs_inv_rkey() fails synchronously in complete_rdma_req().
> diff --git a/drivers/infiniband/ulp/rtrs/rtrs-clt.c b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> index de226e6ba1246..5ef912a472cda 100644
> --- a/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> +++ b/drivers/infiniband/ulp/rtrs/rtrs-clt.c
> @@ -436,6 +436,19 @@ static void complete_rdma_req(struct rtrs_clt_io_req *req, int errno,
> if (err) {
> rtrs_err_rl(con->c.path, "Send INV WR key=%#x: %pe\n",
> req->mr->rkey, ERR_PTR(err));
> + /*
> + * No LOCAL_INV completion will fire, so the
> + * rkey is still live on the HCA but we cannot
> + * invalidate it from this context. Clear
> + * need_inval so subsequent reapers don't
> + * wait on an invalidate that will never
> + * happen, and kick off error recovery so the
> + * QP (and MR) is torn down cleanly via
> + * fail_all_outstanding_reqs() ->
> + * complete_rdma_req(can_wait=true).
> + */
> + req->mr->need_inval = false;
> + rtrs_rdma_error_recovery(con);
> } else if (can_wait) {
> wait_for_completion(&req->inv_comp);
> }
[Severity: High]
Does complete_rdma_req() leak the DMA mapping on req->sglist when called
from fail_all_outstanding_reqs() on an in-flight request that still has
req->mr->need_inval set?
During recovery, rtrs_clt_stop_and_destroy_conns() drains QPs via
stop_cm() and then runs fail_all_outstanding_reqs(), which calls
complete_rdma_req() with can_wait = true and req->ref == 1.
complete_rdma_req() increments req->ref to 2 before rtrs_inv_rkey(), and
neither the if (err) branch (when posting to the stopped QP fails) nor the
else if (can_wait) branch (where rtrs_clt_inv_rkey_done() only signals
req->inv_comp without dropping a reference) decrements req->ref:
drivers/infiniband/ulp/rtrs/rtrs-clt.c:complete_rdma_req() {
...
refcount_inc(&req->ref);
err = rtrs_inv_rkey(req);
if (err) {
...
req->mr->need_inval = false;
rtrs_rdma_error_recovery(con);
} else if (can_wait) {
wait_for_completion(&req->inv_comp);
}
if (!refcount_dec_and_test(&req->ref))
return;
}
ib_dma_unmap_sg(clt_path->s.dev->ib_dev, req->sglist,
req->sg_cnt, req->dir);
...
}
refcount_dec_and_test(&req->ref) drops req->ref from 2 to 1 and returns
early, skipping ib_dma_unmap_sg() and the clt_path->stats->inflight
decrement right before fail_all_outstanding_reqs() fails over or completes
the request.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123143719.938876-1-haris.iqbal@ionos.com?part=3
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 0/9] Misc patches for RTRS
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
` (8 preceding siblings ...)
2026-11-23 14:37 ` [PATCH 9/9] RDMA/rtrs-clt: Close all paths before freeing any in rtrs_clt_close() Md Haris Iqbal
@ 2026-11-23 15:02 ` sashiko-bot
9 siblings, 0 replies; 14+ messages in thread
From: sashiko-bot @ 2026-11-23 15:02 UTC (permalink / raw)
To: Md Haris Iqbal, linux-rdma
Sashiko has finished reviewing this 9-patch series:
- Patches 2, 4, and 6-9: no issues found.
- Patch 1 ("RDMA/rtrs-clt: Add mpath_policy module parameter"): 2
potential issues (1 Medium, 1 Low)
- Patch 3 ("RDMA/rtrs-clt: Trigger error recovery when posting L..."): 1
potential issue (1 High)
- Patch 5 ("RDMA/rtrs-clt: rename pathname parameter to sessname..."): 1
related pre-existing bug noted
Detailed reviews have been sent as separate replies to patches 1, 3, and
5.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123143719.938876-1-haris.iqbal@ionos.com
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2026-11-23 15:02 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 14:37 [PATCH 0/9] Misc patches for RTRS Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 1/9] RDMA/rtrs-clt: Add mpath_policy module parameter Md Haris Iqbal
2026-11-23 14:44 ` sashiko-bot
2026-11-23 14:37 ` [PATCH 2/9] RDMA/rtrs-clt: Fix refcount imbalance in rtrs_clt_write_req error path Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 3/9] RDMA/rtrs-clt: Trigger error recovery when posting LOCAL_INV fails Md Haris Iqbal
2026-11-23 15:02 ` sashiko-bot
2026-11-23 14:37 ` [PATCH 4/9] RDMA/rtrs-srv: Fix processing messages for Big-Endian archs Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 5/9] RDMA/rtrs-clt: rename pathname parameter to sessname in rtrs_clt_open() Md Haris Iqbal
2026-11-23 14:42 ` sashiko-bot
2026-11-23 14:37 ` [PATCH 6/9] RDMA/rtrs-clt: Fix reconnect jitter being applied in milliseconds Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 7/9] RDMA/rtrs-clt: Back off the reconnect delay exponentially Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 8/9] RDMA/rtrs-srv: Snapshot the READ request header instead of reusing it Md Haris Iqbal
2026-11-23 14:37 ` [PATCH 9/9] RDMA/rtrs-clt: Close all paths before freeing any in rtrs_clt_close() Md Haris Iqbal
2026-11-23 15:02 ` [PATCH 0/9] Misc patches for RTRS sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox