Skip to contentSkip to conversation

Number of fixes for rtrs

PATCH Applied Md Haris Iqbal 3 participants 6 messages Jul 24, 2020 – Jul 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Number of fixes for rtrs

This patch series fixes a number of issues discovered while testing

1) RDMA/rtrs: remove WQ_MEM_RECLAIM for rtrs_wq
2) RDMA/rtrs-srv: only call put_device when it's in sysfs
3) RDMA/rtrs-clt: add an additional random 8 seconds before reconnecting

Regards
Md Haris Iqbal

Jack Wang (2):
RDMA/rtrs-srv: only call put_device when it's in sysfs RDMA/rtrs: remove WQ_MEM_RECLAIM for rtrs_wq

Danil Kipnis (1):
RDMA/rtrs-clt: add an additional random 8 seconds before reconnecting

 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 16 +++++++++++++---
 drivers/infiniband/ulp/rtrs/rtrs-srv.c |  7 +++++--
 2 files changed, 18 insertions(+), 5 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 RDMA/rtrs-clt: add an additional random 8 seconds before reconnecting

From: Danil Kipnis <[email protected]>

In order to avoid all the clients to start reconnecting at the same time schedule the reconnect dwork +[0,8] seconds late

Fixes 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +12 -2
index 564388a85603..5b31d3b03737 100644
@@ -12,6 +12,7 @@
 
 #include <linux/module.h>
 #include <linux/rculist.h>
+#include <linux/random.h>
 
 #include "rtrs-clt.h"
 #include "rtrs-log.h"
@@ -23,6 +24,12 @@
  * leads to "false positives" failed reconnect attempts
  */
 #define RTRS_RECONNECT_BACKOFF 1000
+/*
+ * Wait for additional random time between 0 and 8 seconds
+ * before starting to reconnect to avoid clients reconnecting
+ * all at once in case of a major network outage
+ */
+#define RTRS_RECONNECT_SEED 8
 
 MODULE_DESCRIPTION("RDMA Transport Client");
 MODULE_LICENSE("GPL");
@@ -306,7 +313,8 @@ static void rtrs_rdma_error_recovery(struct rtrs_clt_con *con)
 		 */
 		delay_ms = clt->reconnect_delay_sec * 1000;
 		queue_delayed_work(rtrs_wq, &sess->reconnect_dwork,
-				   msecs_to_jiffies(delay_ms));
+				   msecs_to_jiffies(delay_ms +
+						    prandom_u32() % RTRS_RECONNECT_SEED));
 	} else {
 		/*
 		 * Error can happen just on establishing new connection,
@@ -2503,7 +2511,9 @@ static void rtrs_clt_reconnect_work(struct work_struct *work)
 		sess->stats->reconnects.fail_cnt++;
 		delay_ms = clt->reconnect_delay_sec * 1000;
 		queue_delayed_work(rtrs_wq, &sess->reconnect_dwork,
-				   msecs_to_jiffies(delay_ms));
+				   msecs_to_jiffies(delay_ms +
+						    prandom_u32() %
+						    RTRS_RECONNECT_SEED));
 	}
 }
 
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 RDMA/rtrs-srv: only call put_device when it's in sysfs

In reply to Md Haris Iqbal

From: Jack Wang <[email protected]>

There are error case we will call free_srv before device kobject initialized, in such case we shouldn't call put_device, otherwise a Warning will be generated, eg:

kobject: '(null)' (000000009f5445ed): is not initialized, yet kobject_put() is being called.

So add check before call into put_device.

Fixes 9cb837480424 ("RDMA/rtrs: server: main functionality")
---
 drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +4 -1
index 0d9241f5d9e6..8a55bc559466 100644
@@ -1373,7 +1373,10 @@ static void free_srv(struct rtrs_srv *srv)
 	mutex_destroy(&srv->paths_mutex);
 	mutex_destroy(&srv->paths_ev_mutex);
 	/* last put to release the srv structure */
-	put_device(&srv->dev);
+	if(srv->dev.kobj.state_in_sysfs)
+		put_device(&srv->dev);
+	else
+		kfree(srv);
 }
 
 static inline struct rtrs_srv *__find_srv_and_get(struct rtrs_srv_ctx *ctx,
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH 2/3] RDMA/rtrs-srv: only call put_device when it's in sysfs

Quoted 20 lines · Md Haris Iqbal

From: Jack Wang <[email protected]>

There are error case we will call free_srv before device kobject initialized, in such case we shouldn't call put_device, otherwise a Warning will be generated, eg:

kobject: '(null)' (000000009f5445ed): is not initialized, yet kobject_put() is being called.

So add check before call into put_device.

Fixes 9cb837480424 ("RDMA/rtrs: server: main functionality")
 drivers/infiniband/ulp/rtrs/rtrs-srv.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +1 -0
index 0d9241f5d9e6..8a55bc559466 100644
+++ b/drivers/infiniband/ulp/rtrs/rtrs-srv.c

drivers/infiniband/ulp/rtrs/rtrs-srv.c static void free_srv(struct rtrs_srv *srv) · line 1380

Quoted 9 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c +4 -1
@@ -1373,7 +1373,10 @@ static void free_srv(struct rtrs_srv *srv)
 	mutex_destroy(&srv->paths_mutex);
 	mutex_destroy(&srv->paths_ev_mutex);
 	/* last put to release the srv structure */
-	put_device(&srv->dev);
+	if(srv->dev.kobj.state_in_sysfs)
+		put_device(&srv->dev);
+	else
+		kfree(srv);
 }

Not like this, call device_initialize() sooner.

Jason

#4 lore raw

PATCH 3/3 RDMA/rtrs: remove WQ_MEM_RECLAIM for rtrs_wq

In reply to Md Haris Iqbal

From: Jack Wang <[email protected]>

We triggered warning from time to time when we run regression test, eg:

rnbd_client L685: </dev/nullb0@bla> Device disconnected. rnbd_client L1756: Unloading module

------------[ cut here ]-----------
workqueue: WQ_MEM_RECLAIM rtrs_client_wq:rtrs_clt_reconnect_work [rtrs_client] is flushing !WQ_MEM_RECLAIM ib_addr:process_one_req [ib_core]
WARNING: CPU: 2 PID: 18824 at kernel/workqueue.c:2517 check_flush_dependency+0xad/0x130

The root cause is workqueue core expect flushing should not be done for a !WQ_MEM_RECLAIM wq from a WQ_MEM_RECLAIM workqueue.

In above case ib_addr workqueue without WQ_MEM_RECLAIM, but rtrs_wq WQ_MEM_RECLAIM.

To avoid the warning, remove the WQ_MEM_RECLAIM flag.

Fixes 9cb837480424 ("RDMA/rtrs: server: main functionality")
Fixes 6a98d71daea1 ("RDMA/rtrs: client: main functionality")
---
 drivers/infiniband/ulp/rtrs/rtrs-clt.c | 2 +-
 drivers/infiniband/ulp/rtrs/rtrs-srv.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +1 -1
index 5b31d3b03737..776e89231c52 100644
@@ -2982,7 +2982,7 @@ static int __init rtrs_client_init(void)
 		pr_err("Failed to create rtrs-client dev class\n");
 		return PTR_ERR(rtrs_clt_dev_class);
 	}
-	rtrs_wq = alloc_workqueue("rtrs_client_wq", WQ_MEM_RECLAIM, 0);
+	rtrs_wq = alloc_workqueue("rtrs_client_wq", 0, 0);
 	if (!rtrs_wq) {
 		class_destroy(rtrs_clt_dev_class);
 		return -ENOMEM;
drivers/infiniband/ulp/rtrs/rtrs-srv.c +1 -1
index 8a55bc559466..454bb6c343bb 100644
@@ -2153,7 +2153,7 @@ static int __init rtrs_server_init(void)
 		err = PTR_ERR(rtrs_dev_class);
 		goto out_chunk_pool;
 	}
-	rtrs_wq = alloc_workqueue("rtrs_server_wq", WQ_MEM_RECLAIM, 0);
+	rtrs_wq = alloc_workqueue("rtrs_server_wq", 0, 0);
 	if (!rtrs_wq) {
 		err = -ENOMEM;
 		goto out_dev_class;
Signature · 1 line
2.25.1
maintainer Applied
#5 lore raw
In reply to Md Haris Iqbal
Quoted 10 lines · Md Haris Iqbal

This patch series fixes a number of issues discovered while testing

1) RDMA/rtrs: remove WQ_MEM_RECLAIM for rtrs_wq
2) RDMA/rtrs-srv: only call put_device when it's in sysfs
3) RDMA/rtrs-clt: add an additional random 8 seconds before reconnecting

Regards
Md Haris Iqbal

Quoted 5 lines

Jack Wang (2):
RDMA/rtrs: remove WQ_MEM_RECLAIM for rtrs_wq

Danil Kipnis (1):
RDMA/rtrs-clt: add an additional random 8 seconds before reconnecting

Applied to for-next, thanks

Quoted 1 line

RDMA/rtrs-srv: only call put_device when it's in sysfs

Needs more work

Thanks,
Jason