Misc update for RTRS
Subsystems (2)
Jack Wang
maintainercover Misc update for RTRS
Hi Jason, hi Doug,
Please consider to include following changes to the next merge window.
The patchset is orgnized as:
- patch1 bugfix for corner case.
- patch2 reject client with special sessname.
- patch3 sysfs_emit conversion.
- patch4 remove unused functions.
- patch5 Fix warning with poll mode.
- patch6 remove len parameter.
- patch7 remove likely/unlikely.
- patch8 Fix inflight io accounting when switch mp_policy.
- patch9 add interface to disable IB port on server side.
- patch10 remove void cast.
The patches are created base on rdma/for-next at commit:07d0f314ba75 ("Merge branch 'mlx5_dcs' into rdma.git for-next")
Thanks!
Gioh Kim (4):
RDMA/rtrs-srv: Prevent sysfs error with path name "ctl" RDMA/rtrs: Remove all likely and unlikely RDMA/rtrs-clt: Fix counting inflight IO RDMA/rtrs: remove (void) casting for functions
Jack Wang (2):
RDMA/rtrs: Remove unused functions
RDMA/rtrs: Fix warning when use poll mode
Md Haris Iqbal (4):
RDMA/rtrs-clt: During add_path change for_new_clt according to
path_num
RDMA/rtrs: Use sysfs_emit instead of s*printf function for sysfs show RDMA/rtrs: Remove len parameter from helper print functions of sysfs RDMA/rtrs: Add support to disable an IB port on the storage side
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 40 ++--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 152 +++++++++-------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 16 +- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 2 +- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 3 +- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 +- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 169 ++++++++++++++----- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 7 +- drivers/infiniband/ulp/rtrs/rtrs.c | 17 +- 9 files changed, 253 insertions(+), 155 deletions(-)
Signature · 1 line
2.25.1
Jack Wang
maintainerPATCH 1/10 RDMA/rtrs-clt: During add_path change for_new_clt according to path_num
From: Md Haris Iqbal <[email protected]>
When all the paths are removed for a session, the addition of the first path is like a new session for the storage server.
Hence, for_new_clt has to be set to 1.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +9 -0
@@ -3083,6 +3083,15 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt,if (IS_ERR (sess))return PTR_ERR (sess); +if (clt->paths_num ==0 ) { +/* +* When all the paths are removed for a session, +* the addition of the first path is like a new session for +* the storage server +*/ + sess->for_new_clt =1 ; + } +/* * It is totally safe to add path in CONNECTING state: coming * IO will never grab it. Also it is very important to add
Signature · 1 line
2.25.1
Re: [PATCH for-next 01/10] RDMA/rtrs-clt: During add_path change for_new_clt according to path_num
Quoted 18 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
When all the paths are removed for a session, the addition of the first path is like a new session for the storage server.
Hence,
for_new_clthas to be set to 1.Signed-off-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/infiniband/ulp/rtrs/rtrs-clt.c +0
-0
drivers/infiniband/ulp/rtrs/rtrs-clt.c int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt, · line 3086
Quoted 4 lines
drivers/infiniband/ulp/rtrs/rtrs-clt.c +1
-0@@ -3083,6 +3083,15 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt,if (IS_ERR (sess))return PTR_ERR (sess); +if (clt->paths_num ==0 ) {
Don't you need some protection to read paths_num?rcu_read_lock() or mutex_lock?
Thanks
Haris Iqbal
maintainerRe: [PATCH for-next 01/10] RDMA/rtrs-clt: During add_path change for_new_clt according to path_num
Quoted 23 lines · Leon Romanovsky
Quoted 21 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
When all the paths are removed for a session, the addition of the first path is like a new session for the storage server.
Hence,
for_new_clthas to be set to 1.Signed-off-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/infiniband/ulp/rtrs/rtrs-clt.c +0
-0@@ -3083,6 +3083,15 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt,if (IS_ERR (sess))return PTR_ERR (sess);
Quoted 4 lines
drivers/infiniband/ulp/rtrs/rtrs-clt.c int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt, · line 3086
Quoted 1 line
drivers/infiniband/ulp/rtrs/rtrs-clt.c +1
-0+if (clt->paths_num ==0 ) {Don't you need some protection to read
paths_num?rcu_read_lock()ormutex_lock?
Good catch. The lock should be added.
Thanks
Quoted 2 lines
Thanks
Jack Wang
maintainerPATCH 2/10 RDMA/rtrs-srv: Prevent sysfs error with path name "ctl"
In reply to Jack WangFrom: Gioh Kim <[email protected]>
If the client tries to create a path with name "ctl",
the server tries to creates /sys/devices/virtual/rtrs-server/ctl/. Then server generated below error because there is already ctl directory which manages some setup of the server.
sysfs: cannot create duplicate filename '/devices/virtual/rtrs-server/ctl'
Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] Call Trace: dump_stack+0x50/0x63 sysfs_warn_dup.cold+0x17/0x24 sysfs_create_dir_ns+0xb6/0xd0 kobject_add_internal+0xa6/0x2a0 kobject_add+0x7e/0xb0 ? _cond_resched+0x15/0x30 device_add+0x121/0x640 rtrs_srv_create_sess_files+0x18f/0x1f0 [rtrs_server] ? __alloc_pages_nodemask+0x16c/0x2b0 ? kmalloc_order+0x7c/0x90 ? kmalloc_order_trace+0x1d/0xa0 ? rtrs_iu_alloc+0x17e/0x1bf [rtrs_core] rtrs_srv_info_req_done+0x417/0x5b0 [rtrs_server] ? __switch_to_asm+0x40/0x70 __ib_process_cq+0x76/0xd0 [ib_core] ib_cq_poll_work+0x26/0x80 [ib_core] process_one_work+0x1df/0x3a0 worker_thread+0x4a/0x3c0 kthread+0xfb/0x130 ? process_one_work+0x3a0/0x3a0 ? kthread_park+0x90/0x90 ret_from_fork+0x1f/0x40
kobject_add_internal failed for ctl with -EEXIST, don't try to register things with the same name in the same directory. rtrs_server L178: device_add(): -17
This patch checks the path name and disconnect on server to prevent the kernel error.
--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +8 -0
@@ -758,6 +758,14 @@ static bool exist_sessname(struct rtrs_srv_ctx *ctx,struct rtrs_srv_sess *sess;bool found = false; +/* +* Session name "ct" is not allowed because +* /sys/devices/virtual/rtrs-server/ctl already exists +* for setup management. +*/ +if (!strcmp (sessname,"ctl" )) +return true; +mutex_lock (&ctx->srv_mutex);list_for_each_entry (srv, &ctx->srv_list, ctx_list) {mutex_lock (&srv->paths_mutex);
Signature · 1 line
2.25.1
Re: [PATCH for-next 02/10] RDMA/rtrs-srv: Prevent sysfs error with path name "ctl"
Quoted 49 lines · Jack Wang
From: Gioh Kim <[email protected]>
If the client tries to create a path with name "ctl",
the server tries to creates/sys/devices/virtual/rtrs-server/ctl/. Then server generated below error because there is already ctl directory which manages some setup of the server.sysfs: cannot create duplicate filename '/devices/virtual/rtrs-server/ctl'
Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] Call Trace: dump_stack+0x50/0x63 sysfs_warn_dup.cold+0x17/0x24 sysfs_create_dir_ns+0xb6/0xd0 kobject_add_internal+0xa6/0x2a0 kobject_add+0x7e/0xb0 ? _cond_resched+0x15/0x30 device_add+0x121/0x640 rtrs_srv_create_sess_files+0x18f/0x1f0 [rtrs_server] ? __alloc_pages_nodemask+0x16c/0x2b0 ? kmalloc_order+0x7c/0x90 ? kmalloc_order_trace+0x1d/0xa0 ? rtrs_iu_alloc+0x17e/0x1bf [rtrs_core] rtrs_srv_info_req_done+0x417/0x5b0 [rtrs_server] ? __switch_to_asm+0x40/0x70 __ib_process_cq+0x76/0xd0 [ib_core] ib_cq_poll_work+0x26/0x80 [ib_core] process_one_work+0x1df/0x3a0 worker_thread+0x4a/0x3c0 kthread+0xfb/0x130 ? process_one_work+0x3a0/0x3a0 ? kthread_park+0x90/0x90 ret_from_fork+0x1f/0x40
kobject_add_internalfailed for ctl with-EEXIST, don't try to register things with the same name in the same directory.rtrs_serverL178:device_add(): -17This patch checks the path name and disconnect on server to prevent the kernel error.
Signed-off-by Gioh Kim <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/infiniband/ulp/rtrs/rtrs-srv.c +0
-0
drivers/infiniband/ulp/rtrs/rtrs-srv.c static bool exist_sessname(struct rtrs_srv_ctx *ctx, · line 767
Quoted 10 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c +7
-0@@ -758,6 +758,14 @@ static bool exist_sessname(struct rtrs_srv_ctx *ctx,struct rtrs_srv_sess *sess;bool found = false; +/* +* Session name "ct" is not allowed because +* /sys/devices/virtual/rtrs-server/ctl already exists +* for setup management. +*/ +if (!strcmp (sessname,"ctl" )) +return true;
Why does it have special treatment?
And what will happen if user supplies "." or ".."?
Does rtrs receive this session name from the other side in the network?
Thanks
Haris Iqbal
maintainerRe: [PATCH for-next 02/10] RDMA/rtrs-srv: Prevent sysfs error with path name "ctl"
Quoted 54 lines · Leon Romanovsky
Quoted 52 lines · Jack Wang
From: Gioh Kim <[email protected]>
If the client tries to create a path with name "ctl",
the server tries to creates/sys/devices/virtual/rtrs-server/ctl/. Then server generated below error because there is already ctl directory which manages some setup of the server.sysfs: cannot create duplicate filename '/devices/virtual/rtrs-server/ctl'
Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] Call Trace: dump_stack+0x50/0x63 sysfs_warn_dup.cold+0x17/0x24 sysfs_create_dir_ns+0xb6/0xd0 kobject_add_internal+0xa6/0x2a0 kobject_add+0x7e/0xb0 ? _cond_resched+0x15/0x30 device_add+0x121/0x640 rtrs_srv_create_sess_files+0x18f/0x1f0 [rtrs_server] ? __alloc_pages_nodemask+0x16c/0x2b0 ? kmalloc_order+0x7c/0x90 ? kmalloc_order_trace+0x1d/0xa0 ? rtrs_iu_alloc+0x17e/0x1bf [rtrs_core] rtrs_srv_info_req_done+0x417/0x5b0 [rtrs_server] ? __switch_to_asm+0x40/0x70 __ib_process_cq+0x76/0xd0 [ib_core] ib_cq_poll_work+0x26/0x80 [ib_core] process_one_work+0x1df/0x3a0 worker_thread+0x4a/0x3c0 kthread+0xfb/0x130 ? process_one_work+0x3a0/0x3a0 ? kthread_park+0x90/0x90 ret_from_fork+0x1f/0x40
kobject_add_internalfailed for ctl with-EEXIST, don't try to register things with the same name in the same directory.rtrs_serverL178:device_add(): -17This patch checks the path name and disconnect on server to prevent the kernel error.
Signed-off-by Gioh Kim <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/infiniband/ulp/rtrs/rtrs-srv.c +0
-0@@ -758,6 +758,14 @@ static bool exist_sessname(struct rtrs_srv_ctx *ctx,struct rtrs_srv_sess *sess;bool found = false;
Quoted 9 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c static bool exist_sessname(struct rtrs_srv_ctx *ctx, · line 767
Quoted 7 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c +7
-0+/* +* Session name "ct" is not allowed because +* /sys/devices/virtual/rtrs-server/ctl already exists +* for setup management. +*/ +if (!strcmp (sessname,"ctl" )) +return true;Why does it have special treatment?
rtrs-server creates a folder named ctl when the module is modprob'ed. When a session is established, a folder of the session name is created at the same location, which would hold sysfs entries such as clt_hostname, path details, queue_depth, etc.
Due to this conflict of names, creation of session with that name is not possible. So this gracefully fails the connection establishment instead of a stack trace.
Quoted 1 line
And what will happen if user supplies "." or ".."?
Weirdly enough, this succeeds. I tried, and the session creation succeeds, and there is a hidden entry in the rtrs-server folder, but it cannot be accessed through bash.
Quoted 1 line
Does rtrs receive this session name from the other side in the network?
Yes. This string is entered by the user while creating the session.
Quoted 2 lines
Thanks
Re: [PATCH for-next 02/10] RDMA/rtrs-srv: Prevent sysfs error with path name "ctl"
Quoted 74 lines · Haris Iqbal
Quoted 54 lines · Leon Romanovsky
Quoted 52 lines · Jack Wang
From: Gioh Kim <[email protected]>
If the client tries to create a path with name "ctl",
the server tries to creates/sys/devices/virtual/rtrs-server/ctl/. Then server generated below error because there is already ctl directory which manages some setup of the server.sysfs: cannot create duplicate filename '/devices/virtual/rtrs-server/ctl'
Workqueue: ib-comp-wq ib_cq_poll_work [ib_core] Call Trace: dump_stack+0x50/0x63 sysfs_warn_dup.cold+0x17/0x24 sysfs_create_dir_ns+0xb6/0xd0 kobject_add_internal+0xa6/0x2a0 kobject_add+0x7e/0xb0 ? _cond_resched+0x15/0x30 device_add+0x121/0x640 rtrs_srv_create_sess_files+0x18f/0x1f0 [rtrs_server] ? __alloc_pages_nodemask+0x16c/0x2b0 ? kmalloc_order+0x7c/0x90 ? kmalloc_order_trace+0x1d/0xa0 ? rtrs_iu_alloc+0x17e/0x1bf [rtrs_core] rtrs_srv_info_req_done+0x417/0x5b0 [rtrs_server] ? __switch_to_asm+0x40/0x70 __ib_process_cq+0x76/0xd0 [ib_core] ib_cq_poll_work+0x26/0x80 [ib_core] process_one_work+0x1df/0x3a0 worker_thread+0x4a/0x3c0 kthread+0xfb/0x130 ? process_one_work+0x3a0/0x3a0 ? kthread_park+0x90/0x90 ret_from_fork+0x1f/0x40
kobject_add_internalfailed for ctl with-EEXIST, don't try to register things with the same name in the same directory.rtrs_serverL178:device_add(): -17This patch checks the path name and disconnect on server to prevent the kernel error.
Signed-off-by Gioh Kim <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/infiniband/ulp/rtrs/rtrs-srv.c +0
-0@@ -758,6 +758,14 @@ static bool exist_sessname(struct rtrs_srv_ctx *ctx,struct rtrs_srv_sess *sess;bool found = false;Quoted 9 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c static bool exist_sessname(struct rtrs_srv_ctx *ctx, · line 767
Quoted 7 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c +7
-0+/* +* Session name "ct" is not allowed because +* /sys/devices/virtual/rtrs-server/ctl already exists +* for setup management. +*/ +if (!strcmp (sessname,"ctl" )) +return true;Why does it have special treatment?
rtrs-server creates a folder named ctl when the module is modprob'ed. When a session is established, a folder of the session name is created at the same location, which would hold sysfs entries such as
clt_hostname, path details,queue_depth, etc.Due to this conflict of names, creation of session with that name is not possible. So this gracefully fails the connection establishment instead of a stack trace.
Quoted 5 lines
Quoted 1 line
And what will happen if user supplies "." or ".."?
Weirdly enough, this succeeds. I tried, and the session creation succeeds, and there is a hidden entry in the rtrs-server folder, but it cannot be accessed through bash.
All special symbols must be disallowed and filtered on the server side.
Quoted 4 lines
Quoted 2 lines
Does rtrs receive this session name from the other side in the network?
Yes. This string is entered by the user while creating the session.
It sounds scary
Quoted 3 lines
Quoted 3 lines
Thanks
Jack Wang
maintainerPATCH 3/10 RDMA/rtrs: Use sysfs_emit instead of s*printf function for sysfs show
In reply to Jack WangFrom: Md Haris Iqbal <[email protected]>
sysfs_emit function was added to be aware of the PAGE_SIZE maximum of the temporary buffer used for outputting sysfs content, so there is no possible overruns. So replace the uses of any s*printf functions for the sysfs show functions with sysfs_emit.
--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 24 +++++++++----------- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +11 -13
@@ -45,24 +45,23 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats,size_t used;int cpu; - used =scnprintf (buf, len," " ); + used =sysfs_emit (buf," " );for_each_possible_cpu (cpu) - used +=scnprintf (buf + used, len - used," CPU%u" , cpu); + used +=sysfs_emit_at (buf, used," CPU%u" , cpu); - used +=scnprintf (buf + used, len - used,"\nfrom:" ); + used +=sysfs_emit_at (buf, used,"\nfrom:" );for_each_possible_cpu (cpu) { s =per_cpu_ptr (stats->pcpu_stats, cpu); - used +=scnprintf (buf + used, len - used," %d" , + used +=sysfs_emit_at (buf, used," %d" ,atomic_read (&s->cpu_migr.from)); } - used +=scnprintf (buf + used, len - used,"\nto :" ); + used +=sysfs_emit_at (buf, used,"\nto :" );for_each_possible_cpu (cpu) { s =per_cpu_ptr (stats->pcpu_stats, cpu); - used +=scnprintf (buf + used, len - used," %d" , - s->cpu_migr.to); + used +=sysfs_emit_at (buf, used," %d" , s->cpu_migr.to); } - used +=scnprintf (buf + used, len - used,"\n" ); + used +=sysfs_emit_at (buf, used,"\n" );return used; }
@@ -70,9 +69,8 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats,int rtrs_clt_stats_reconnects_to_str (struct rtrs_clt_stats *stats,char *buf,size_t len) { -return scnprintf (buf, len,"%d %d\n" , - stats->reconnects.successful_cnt, - stats->reconnects.fail_cnt); +return sysfs_emit (buf,"%d %d\n" , stats->reconnects.successful_cnt, + stats->reconnects.fail_cnt); } ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats,
@@ -94,7 +92,7 @@ ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, sum.failover_cnt += r->failover_cnt; } -return scnprintf (page, len,"%llu %llu %llu %llu %u %llu\n" , +return sysfs_emit (page,"%llu %llu %llu %llu %u %llu\n" , sum.dir[READ ].cnt, sum.dir[READ ].size_total, sum.dir[WRITE ].cnt, sum.dir[WRITE ].size_total,atomic_read (&stats->inflight), sum.failover_cnt);
@@ -103,7 +101,7 @@ ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats,ssize_t rtrs_clt_reset_all_help (struct rtrs_clt_stats *s,char *page,size_t len) { -return scnprintf (page, len,"echo 1 to reset all statistics\n" ); +return sysfs_emit (page,"echo 1 to reset all statistics\n" ); }int rtrs_clt_reset_rdma_stats (struct rtrs_clt_stats *stats,bool enable)
drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c +1 -1
@@ -102,7 +102,7 @@ static ssize_t rtrs_srv_src_addr_show(struct kobject *kobj, sess = container_of(kobj, struct rtrs_srv_sess, kobj); cnt =sockaddr_to_str ((struct sockaddr *)&sess->s.dst_addr, page,PAGE_SIZE ); -return cnt +scnprintf (page + cnt,PAGE_SIZE - cnt,"\n" ); +return cnt +sysfs_emit_at (page, cnt,"\n" ); } static struct kobj_attribute rtrs_srv_src_addr_attr =
Signature · 1 line
2.25.1
Re: [PATCH for-next 03/10] RDMA/rtrs: Use sysfs_emit instead of s*printf function for sysfs show
Quoted 20 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
sysfs_emitfunction was added to be aware of thePAGE_SIZEmaximum of the temporary buffer used for outputting sysfs content, so there is no possible overruns. So replace the uses of any s*printf functions for the sysfs show functions withsysfs_emit.Signed-off-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 24 +++++++++----------- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-)drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +0
-0@@ -45,24 +45,23 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats,size_t used;
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, · line 52
Quoted 10 lines
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +3
-3int cpu; - used =scnprintf (buf, len," " ); + used =sysfs_emit (buf," " );for_each_possible_cpu (cpu) - used +=scnprintf (buf + used, len - used," CPU%u" , cpu); + used +=sysfs_emit_at (buf, used," CPU%u" , cpu); - used +=scnprintf (buf + used, len - used,"\nfrom:" ); + used +=sysfs_emit_at (buf, used,"\nfrom:" );
"\nfrom" and "\nto" are abuse of sysfs rules.
https://lore.kernel.org/kernelnewbies/[email protected]/T/#m8bf898fcdb4a5371781bbc9646993a50fa950fbc
https://lore.kernel.org/kernelnewbies/[email protected]/T/#m9ce6f045a863597922012d71a6719d6d90c8e0a6
Thanks
Haris Iqbal
maintainerRe: [PATCH for-next 03/10] RDMA/rtrs: Use sysfs_emit instead of s*printf function for sysfs show
Quoted 30 lines · Leon Romanovsky
Quoted 28 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
sysfs_emitfunction was added to be aware of thePAGE_SIZEmaximum of the temporary buffer used for outputting sysfs content, so there is no possible overruns. So replace the uses of any s*printf functions for the sysfs show functions withsysfs_emit.Signed-off-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 24 +++++++++----------- drivers/infiniband/ulp/rtrs/rtrs-srv-sysfs.c | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-)drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +2
-2@@ -45,24 +45,23 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats,size_t used;int cpu; - used =scnprintf (buf, len," " ); + used =sysfs_emit (buf," " );for_each_possible_cpu (cpu) - used +=scnprintf (buf + used, len - used," CPU%u" , cpu); + used +=sysfs_emit_at (buf, used," CPU%u" , cpu);
Quoted 6 lines
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, · line 52
Quoted 2 lines
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +1
-1- used +=scnprintf (buf + used, len - used,"\nfrom:" ); + used +=sysfs_emit_at (buf, used,"\nfrom:" );"\nfrom" and "\nto" are abuse of sysfs rules.
https://lore.kernel.org/kernelnewbies/[email protected]/T/#m8bf898fcdb4a5371781bbc9646993a50fa950fbc
https://lore.kernel.org/kernelnewbies/[email protected]/T/#m9ce6f045a863597922012d71a6719d6d90c8e0a6
I see. We will discuss internally and see what can be done about this.
Thanks
Quoted 2 lines
Thanks
Jack Wang
maintainerPATCH 4/10 RDMA/rtrs: Remove unused functions
In reply to Jack WangThe two functions are unused, so just remove them.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 5 +---- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.h +1 -4
@@ -229,10 +229,7 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats, char *buf, size_t len);int rtrs_clt_reset_reconnects_stat (struct rtrs_clt_stats *stats,bool enable);int rtrs_clt_stats_reconnects_to_str (struct rtrs_clt_stats *stats,char *buf, -size_t len); -int rtrs_clt_reset_wc_comp_stats (struct rtrs_clt_stats *stats,bool enable); -int rtrs_clt_stats_wc_completion_to_str (struct rtrs_clt_stats *stats,char *buf, -size_t len); +size_t len);int rtrs_clt_reset_rdma_stats (struct rtrs_clt_stats *stats,bool enable);ssize_t rtrs_clt_stats_rdma_to_str (struct rtrs_clt_stats *stats,char *page,size_t len);
drivers/infiniband/ulp/rtrs/rtrs-srv.h +0 -4
@@ -138,10 +138,6 @@ static inline void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s,int rtrs_srv_reset_rdma_stats (struct rtrs_srv_stats *stats,bool enable);ssize_t rtrs_srv_stats_rdma_to_str (struct rtrs_srv_stats *stats,char *page,size_t len); -int rtrs_srv_reset_wc_completion_stats (struct rtrs_srv_stats *stats, -bool enable); -int rtrs_srv_stats_wc_completion_to_str (struct rtrs_srv_stats *stats,char *buf, -size_t len);int rtrs_srv_reset_all_stats (struct rtrs_srv_stats *stats,bool enable);ssize_t rtrs_srv_reset_all_help (struct rtrs_srv_stats *stats,char *page,size_t len);
Signature · 1 line
2.25.1
Re: [PATCH for-next 04/10] RDMA/rtrs: Remove unused functions
Quoted 9 lines · Jack Wang
The two functions are unused, so just remove them.
Signed-off-by Jack Wang <[email protected]>Reviewed-by Md Haris Iqbal <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 5 +---- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 4 ---- 2 files changed, 1 insertion(+), 8 deletions(-)
Thanks,
Jack Wang
maintainerPATCH 5/10 RDMA/rtrs: Fix warning when use poll mode
In reply to Jack Wangwhen test with poll mode, it will fail and lead to warning below:
echo "sessname=bla path=gid:fe80::2:c903:4e:d0b3@gid:fe80::2:c903:8:ca17 device_path=/dev/nullb2 nr_poll_queues=-1" |
sudo tee /sys/devices/virtual/rnbd-client/ctl/map_device
rnbd_client L597: Mapping device /dev/nullb2 on session bla, (access_mode: rw, nr_poll_queues: 8)
WARNING: CPU: 3 PID: 9886 at drivers/infiniband/core/cq.c:447 ib_cq_pool_get+0x26f/0x2a0 [ib_core]
The problem is in case of poll queue, we need to still call ib_alloc_cq/ib_free_cq, we can't use cq_poll api for poll queue.
--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 1 + drivers/infiniband/ulp/rtrs/rtrs.c | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +1 -0
@@ -1776,6 +1776,7 @@ static struct rtrs_srv_sess *__alloc_sess(struct rtrs_srv *srv,strscpy (sess->s.sessname, str,sizeof (sess->s.sessname)); sess->s.con_num = con_num; + sess->s.irq_con_num = con_num; sess->s.recon_cnt = recon_cnt;uuid_copy (&sess->s.uuid, uuid);spin_lock_init (&sess->state_lock);
drivers/infiniband/ulp/rtrs/rtrs.c +14 -3
@@ -228,7 +228,12 @@ static int create_cq(struct rtrs_con *con, int cq_vector, int nr_cqe,struct rdma_cm_id *cm_id = con->cm_id;struct ib_cq *cq; - cq =ib_cq_pool_get (cm_id->device, nr_cqe, cq_vector, poll_ctx); +if (con->cid >= con->sess->irq_con_num) + cq =ib_alloc_cq (cm_id->device, con, nr_cqe, cq_vector, + poll_ctx); +else + cq =ib_cq_pool_get (cm_id->device, nr_cqe, cq_vector, poll_ctx); +if (IS_ERR (cq)) {rtrs_err (con->sess,"Creating completion queue failed, errno: %ld\n" ,PTR_ERR (cq));
@@ -283,7 +288,10 @@ int rtrs_cq_qp_create(struct rtrs_sess *sess, struct rtrs_con *con, err =create_qp (con, sess->dev->ib_pd, max_send_wr, max_recv_wr, max_send_sge);if (err) { -ib_cq_pool_put (con->cq, con->nr_cqe); +if (con->cid >= con->sess->irq_con_num) +ib_free_cq (con->cq); +else +ib_cq_pool_put (con->cq, con->nr_cqe); con->cq =NULL ;return err; }
@@ -300,7 +308,10 @@ void rtrs_cq_qp_destroy(struct rtrs_con *con) con->qp =NULL ; }if (con->cq) { -ib_cq_pool_put (con->cq, con->nr_cqe); +if (con->cid >= con->sess->irq_con_num) +ib_free_cq (con->cq); +else +ib_cq_pool_put (con->cq, con->nr_cqe); con->cq =NULL ; } }
Signature · 1 line
2.25.1
Re: [PATCH for-next 05/10] RDMA/rtrs: Fix warning when use poll mode
Quoted 11 lines · Jack Wang
when test with poll mode, it will fail and lead to warning below:
echo "sessname=bla path=gid:fe80::2:c903:4e:d0b3@gid:fe80::2:c903:8:ca17 device_path=/dev/nullb2 nr_poll_queues=-1" |
sudo tee/sys/devices/virtual/rnbd-client/ctl/map_device
rnbd_clientL597: Mapping device/dev/nullb2on session bla, (access_mode: rw,nr_poll_queues: 8)WARNING: CPU: 3 PID: 9886 at drivers/infiniband/core/cq.c:447 ib_cq_pool_get+0x26f/0x2a0 [ib_core]The problem is in case of poll queue, we need to still call ib_alloc_cq/ib_free_cq, we can't use
cq_pollapi for poll queue.
It will be great to see an explanation here.
Thanks
Haris Iqbal
maintainerRe: [PATCH for-next 05/10] RDMA/rtrs: Fix warning when use poll mode
Quoted 7 lines · Leon Romanovsky
Quoted 5 lines · Jack Wang
when test with poll mode, it will fail and lead to warning below:
echo "sessname=bla path=gid:fe80::2:c903:4e:d0b3@gid:fe80::2:c903:8:ca17 device_path=/dev/nullb2 nr_poll_queues=-1" |
sudo tee/sys/devices/virtual/rnbd-client/ctl/map_device
Quoted 8 lines
Quoted 6 lines
rnbd_clientL597: Mapping device/dev/nullb2on session bla, (access_mode: rw,nr_poll_queues: 8)WARNING: CPU: 3 PID: 9886 at drivers/infiniband/core/cq.c:447 ib_cq_pool_get+0x26f/0x2a0 [ib_core]The problem is in case of poll queue, we need to still call ib_alloc_cq/ib_free_cq, we can't use
cq_pollapi for poll queue.It will be great to see an explanation here.
Will add and resend. Thanks
Quoted 2 lines
Thanks
Jack Wang
maintainerPATCH 6/10 RDMA/rtrs: Remove len parameter from helper print functions of sysfs
In reply to Jack WangFrom: Md Haris Iqbal <[email protected]>
Since we have changed all sysfs show functions to use sysfs_emit, we do not require the len (PAGE_SIZE) in our helper print functions. So remove it from the function parameter.
--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 12 ++++-------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 12 +++++------- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 2 +- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 3 +-- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 3 +-- 5 files changed, 12 insertions(+), 20 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +4 -8
@@ -37,8 +37,7 @@ void rtrs_clt_inc_failover_cnt(struct rtrs_clt_stats *stats) s->rdma.failover_cnt++; } -int rtrs_clt_stats_migration_cnt_to_str (struct rtrs_clt_stats *stats, -char *buf,size_t len) +int rtrs_clt_stats_migration_cnt_to_str (struct rtrs_clt_stats *stats,char *buf) {struct rtrs_clt_stats_pcpu *s;
@@ -66,15 +65,13 @@ int rtrs_clt_stats_migration_cnt_to_str(struct rtrs_clt_stats *stats,return used; } -int rtrs_clt_stats_reconnects_to_str (struct rtrs_clt_stats *stats,char *buf, -size_t len) +int rtrs_clt_stats_reconnects_to_str (struct rtrs_clt_stats *stats,char *buf) {return sysfs_emit (buf,"%d %d\n" , stats->reconnects.successful_cnt, stats->reconnects.fail_cnt); } -ssize_t rtrs_clt_stats_rdma_to_str (struct rtrs_clt_stats *stats, -char *page,size_t len) +ssize_t rtrs_clt_stats_rdma_to_str (struct rtrs_clt_stats *stats,char *page) {struct rtrs_clt_stats_rdma sum;struct rtrs_clt_stats_rdma *r;
@@ -98,8 +95,7 @@ ssize_t rtrs_clt_stats_rdma_to_str(struct rtrs_clt_stats *stats, atomic_read(&stats->inflight), sum.failover_cnt); } -ssize_t rtrs_clt_reset_all_help (struct rtrs_clt_stats *s, -char *page,size_t len) +ssize_t rtrs_clt_reset_all_help (struct rtrs_clt_stats *s,char *page) {return sysfs_emit (page,"echo 1 to reset all statistics\n" ); }
drivers/infiniband/ulp/rtrs/rtrs-clt.h +5 -7
@@ -223,19 +223,17 @@ void rtrs_clt_update_all_stats(struct rtrs_clt_io_req *req, int dir);int rtrs_clt_reset_rdma_lat_distr_stats (struct rtrs_clt_stats *stats,bool enable);ssize_t rtrs_clt_stats_rdma_lat_distr_to_str (struct rtrs_clt_stats *stats, -char *page,size_t len); +char *page);int rtrs_clt_reset_cpu_migr_stats (struct rtrs_clt_stats *stats,bool enable); -int rtrs_clt_stats_migration_cnt_to_str (struct rtrs_clt_stats *stats,char *buf, -size_t len); +int rtrs_clt_stats_migration_cnt_to_str (struct rtrs_clt_stats *stats,char *buf);int rtrs_clt_reset_reconnects_stat (struct rtrs_clt_stats *stats,bool enable); -int rtrs_clt_stats_reconnects_to_str (struct rtrs_clt_stats *stats,char *buf, -size_t len); +int rtrs_clt_stats_reconnects_to_str (struct rtrs_clt_stats *stats,char *buf);int rtrs_clt_reset_rdma_stats (struct rtrs_clt_stats *stats,bool enable);ssize_t rtrs_clt_stats_rdma_to_str (struct rtrs_clt_stats *stats, -char *page,size_t len); +char *page);int rtrs_clt_reset_all_stats (struct rtrs_clt_stats *stats,bool enable);ssize_t rtrs_clt_reset_all_help (struct rtrs_clt_stats *stats, -char *page,size_t len); +char *page);/* rtrs-clt-sysfs.c */
drivers/infiniband/ulp/rtrs/rtrs-pri.h +1 -1
@@ -398,7 +398,7 @@ static ssize_t get_value##_show(struct kobject *kobj, \ { \type *stats =container_of (kobj, type, kobj_stats); \ \ -return PAGE_SIZE ); \ +return #define STAT_ATTR (type, stat, print, reset) \
drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c +1 -2
@@ -23,8 +23,7 @@ int rtrs_srv_reset_rdma_stats(struct rtrs_srv_stats *stats, bool enable)return -EINVAL ; } -ssize_t rtrs_srv_stats_rdma_to_str (struct rtrs_srv_stats *stats, -char *page,size_t len) +ssize_t rtrs_srv_stats_rdma_to_str (struct rtrs_srv_stats *stats,char *page) {struct rtrs_srv_stats_rdma_stats *r = &stats->rdma_stats;
drivers/infiniband/ulp/rtrs/rtrs-srv.h +1 -2
@@ -136,8 +136,7 @@ static inline void rtrs_srv_update_rdma_stats(struct rtrs_srv_stats *s,/* functions which are implemented in rtrs-srv-stats.c */ int rtrs_srv_reset_rdma_stats (struct rtrs_srv_stats *stats,bool enable); -ssize_t rtrs_srv_stats_rdma_to_str (struct rtrs_srv_stats *stats, -char *page,size_t len); +ssize_t rtrs_srv_stats_rdma_to_str (struct rtrs_srv_stats *stats,char *page);int rtrs_srv_reset_all_stats (struct rtrs_srv_stats *stats,bool enable);ssize_t rtrs_srv_reset_all_help (struct rtrs_srv_stats *stats,char *page,size_t len);
Signature · 1 line
2.25.1
Re: [PATCH for-next 06/10] RDMA/rtrs: Remove len parameter from helper print functions of sysfs
Quoted 8 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
Since we have changed all sysfs show functions to use
sysfs_emit, we do not require the len (PAGE_SIZE) in our helper print functions. So remove it from the function parameter.Signed-off-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>
Quoted 7 lines
--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 12 ++++-------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 12 +++++------- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 2 +- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 3 +-- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 3 +-- 5 files changed, 12 insertions(+), 20 deletions(-)
I suggest to squash this patch to the one mentioned in the commit message.
Thanks
Haris Iqbal
maintainerRe: [PATCH for-next 06/10] RDMA/rtrs: Remove len parameter from helper print functions of sysfs
Quoted 18 lines · Leon Romanovsky
Quoted 8 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
Since we have changed all sysfs show functions to use
sysfs_emit, we do not require the len (PAGE_SIZE) in our helper print functions. So remove it from the function parameter.Signed-off-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>Quoted 7 lines
--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 12 ++++-------- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 12 +++++------- drivers/infiniband/ulp/rtrs/rtrs-pri.h | 2 +- drivers/infiniband/ulp/rtrs/rtrs-srv-stats.c | 3 +-- drivers/infiniband/ulp/rtrs/rtrs-srv.h | 3 +-- 5 files changed, 12 insertions(+), 20 deletions(-)
Quoted 1 line
I suggest to squash this patch to the one mentioned in the commit message.
The purpose of the 2 patches are different. I would prefer keeping them separate; unless there is a clear and obvious reason NOT to do so.
Thanks
Quoted 2 lines
Thanks
Jack Wang
maintainerPATCH 7/10 RDMA/rtrs: Remove all likely and unlikely
In reply to Jack WangFrom: Gioh Kim <[email protected]>
The IO performance test with fio after swapping the likely and unlikely macros in all if-statement shows no difference. They do not help for the performance of rtrs.
Thanks to Haakon Bugge for the test scenario.
The fio test did random read on 32 rnbd devices and 64 processes. Test environment:
- Intel(R) Xeon(R) Gold 6130 CPU @ 2.10GHz
- 376G memory
- kernel version: 5.4.86
- gcc version: gcc (Debian 8.3.0-6) 8.3.0
- Infiniband controller: Mellanox Technologies MT27800 Family [ConnectX-5]
Test result:
- before swapping: IOPS=829k, BW=3239MiB/s
- after swapping: IOPS=829k, BW=3238MiB/s
- remove all (un)likely: IOPS=829k, BW=3238MiB/s
--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 2 +- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 126 +++++++++---------- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 74 ++++++----- 3 files changed, 99 insertions(+), 103 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +1 -1
@@ -20,7 +20,7 @@ void rtrs_clt_update_wc_stats(struct rtrs_clt_con *con) cpu =raw_smp_processor_id (); s =this_cpu_ptr (stats->pcpu_stats); -if (unlikely (con->cpu != cpu)) { +if (con->cpu != cpu) { s->cpu_migr.to++;/* Careful here, override s pointer */
drivers/infiniband/ulp/rtrs/rtrs-clt.c +62 -64
450 lines not on this page · raw message
drivers/infiniband/ulp/rtrs/rtrs-srv.c +36 -38
278 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH for-next 07/10] RDMA/rtrs: Remove all likely and unlikely
Quoted 22 lines · Jack Wang
From: Gioh Kim <[email protected]>
The IO performance test with fio after swapping the likely and unlikely macros in all if-statement shows no difference. They do not help for the performance of rtrs.
Thanks to Haakon Bugge for the test scenario.
The fio test did random read on 32 rnbd devices and 64 processes. Test environment:
- Intel(R) Xeon(R) Gold 6130 CPU @ 2.10GHz
- 376G memory
- kernel version: 5.4.86
- gcc version: gcc (Debian 8.3.0-6) 8.3.0
- Infiniband controller: Mellanox Technologies MT27800 Family [ConnectX-5]Test result:
- before swapping: IOPS=829k, BW=3239MiB/s
- after swapping: IOPS=829k, BW=3238MiB/s
- remove all (un)likely: IOPS=829k, BW=3238MiB/s
Quoted 8 lines
Signed-off-by Gioh Kim <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 2 +- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 126 +++++++++---------- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 74 ++++++----- 3 files changed, 99 insertions(+), 103 deletions(-)
Thanks a lot,
Jack Wang
maintainerPATCH 8/10 RDMA/rtrs-clt: Fix counting inflight IO
In reply to Jack WangFrom: Gioh Kim <[email protected]>
There are mis-match at counting inflight IO after changing the multipath policy.
For example, we started fio test with round-robin policy and then we changed the policy to min-inflight. IOs created under the RR policy is finished under the min-inflight policy and inflight counter only decreased. So the counter would be negative value.
And also we started fio test with min-inflight policy and changed the policy to the round-robin. IOs created under the min-inflight policy increased the inflight IO counter but the inflight IO counter was not decreased because the policy was the round-robin when IO was finished.
So it should count IOs only if the IO is created under the min-inflight policy. It should not care the policy when the IO is finished.
This patch adds a field mp_policy in struct rtrs_clt_io_req and stores the multipath policy when an object of rtrs_clt_io_req is created. Then rtrs-clt checks the mp_policy of only struct rtrs_clt_io_req instead of the struct rtrs_clt.
--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 2 +- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++--- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c +1 -1
@@ -174,7 +174,7 @@ void rtrs_clt_update_all_stats(struct rtrs_clt_io_req *req, int dir) len = req->usr_len + req->data_len;rtrs_clt_update_rdma_stats (stats, len, dir); -if (sess->clt->mp_policy ==MP_POLICY_MIN_INFLIGHT ) +if (req->mp_policy ==MP_POLICY_MIN_INFLIGHT )atomic_inc (&stats->inflight); }
drivers/infiniband/ulp/rtrs/rtrs-clt.c +4 -3
@@ -438,7 +438,7 @@ static void complete_rdma_req(struct rtrs_clt_io_req *req, int errno, }if (!refcount_dec_and_test (&req->ref))return ; -if (sess->clt->mp_policy ==MP_POLICY_MIN_INFLIGHT ) +if (req->mp_policy ==MP_POLICY_MIN_INFLIGHT )atomic_dec (&sess->stats->inflight); req->in_use = false;
@@ -964,6 +964,7 @@ static void rtrs_clt_init_req(struct rtrs_clt_io_req *req, req->need_inv_comp = false; req->inv_errno =0 ;refcount_set (&req->ref,1 ); + req->mp_policy = sess->clt->mp_policy;iov_iter_kvec (&iter,READ , vec,1 , usr_len); len =_copy_from_iter (req->iu->buf, usr_len, &iter);
@@ -1154,7 +1155,7 @@ static int rtrs_clt_write_req(struct rtrs_clt_io_req *req)"Write request failed: error=%d path=%s [%s:%u]\n" , ret,kobject_name (&sess->kobj), sess->hca_name, sess->hca_port); -if (sess->clt->mp_policy ==MP_POLICY_MIN_INFLIGHT ) +if (req->mp_policy ==MP_POLICY_MIN_INFLIGHT )atomic_dec (&sess->stats->inflight);if (req->sg_cnt) ib_dma_unmap_sg(sess->s.dev->ib_dev, req->sglist,
@@ -1260,7 +1261,7 @@ static int rtrs_clt_read_req(struct rtrs_clt_io_req *req)"Read request failed: error=%d path=%s [%s:%u]\n" , ret,kobject_name (&sess->kobj), sess->hca_name, sess->hca_port); -if (sess->clt->mp_policy ==MP_POLICY_MIN_INFLIGHT ) +if (req->mp_policy ==MP_POLICY_MIN_INFLIGHT )atomic_dec (&sess->stats->inflight); req->need_inv = false;if (req->sg_cnt)
drivers/infiniband/ulp/rtrs/rtrs-clt.h +1 -0
@@ -101,6 +101,7 @@ struct rtrs_clt_io_req {unsigned int usr_len;void *priv;bool in_use; +enum rtrs_mp_policy mp_policy;struct rtrs_clt_con *con;struct rtrs_sg_desc *desc;struct ib_sge *sge;
Signature · 1 line
2.25.1
Re: [PATCH for-next 08/10] RDMA/rtrs-clt: Fix counting inflight IO
Quoted 23 lines · Jack Wang
From: Gioh Kim <[email protected]>
There are mis-match at counting inflight IO after changing the multipath policy.
For example, we started fio test with round-robin policy and then we changed the policy to min-inflight. IOs created under the RR policy is finished under the min-inflight policy and inflight counter only decreased. So the counter would be negative value.
And also we started fio test with min-inflight policy and changed the policy to the round-robin. IOs created under the min-inflight policy increased the inflight IO counter but the inflight IO counter was not decreased because the policy was the round-robin when IO was finished.So it should count IOs only if the IO is created under the min-inflight policy. It should not care the policy when the IO is finished.
This patch adds a field
mp_policyin structrtrs_clt_io_reqand stores the multipath policy when an object ofrtrs_clt_io_reqis created. Then rtrs-clt checks themp_policyof only structrtrs_clt_io_reqinstead of the structrtrs_clt.
Quoted 8 lines
Signed-off-by Gioh Kim <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt-stats.c | 2 +- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++--- drivers/infiniband/ulp/rtrs/rtrs-clt.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-)
Thanks,
Jack Wang
maintainerPATCH 9/10 RDMA/rtrs: Add support to disable an IB port on the storage side
In reply to Jack WangFrom: Md Haris Iqbal <[email protected]>
This commit adds support to reject connection on a specific IB port which can be specified in the added sysfs entry for the rtrs-server module.
Example,
$ echo "mlx4_0 1" > /sys/class/rtrs-server/ctl/disable_port
When a connection request is received on the above IB port, rtrs_srv rejects the connection and notifies the client to disable reconnection attempts. A manual reconnect has to be triggerred in such a case.
A manual reconnect can be triggered by doing the following,
echo 1 > /sys/class/rtrs-client/blya/paths/<select-path>/reconnect
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 10 ++++ drivers/infiniband/ulp/rtrs/rtrs-srv.c | 82 +++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +10 -0
@@ -1898,6 +1898,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con, struct rdma_cm_event *ev) {struct rtrs_sess *s = con->c.sess; +struct rtrs_clt_sess *sess =to_clt_sess (s);const struct rtrs_msg_conn_rsp *msg;const char *rej_msg;int status, errno;
@@ -1916,6 +1917,15 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con,rtrs_err (s,"Connect rejected: status %d (%s), rtrs errno %d\n" , status, rej_msg, errno); + +if (errno == -ENETDOWN ) { +/* +* Stop reconnection attempts +*/ + sess->reconnect_attempts =-1 ; +rtrs_err (s, +"Disabling auto-reconnect. Trigger a manual reconnect after issue is resolved\n" ); + } }else { rtrs_err(s, "Connect rejected but with malformed message: status %d (%s)\n",
drivers/infiniband/ulp/rtrs/rtrs-srv.c +80 -2
120 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH for-next 09/10] RDMA/rtrs: Add support to disable an IB port on the storage side
Quoted 109 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
This commit adds support to reject connection on a specific IB port which can be specified in the added sysfs entry for the rtrs-server module.
Example,
$ echo "mlx4_0 1" > /sys/class/rtrs-server/ctl/disable_portWhen a connection request is received on the above IB port,
rtrs_srvrejects the connection and notifies the client to disable reconnection attempts. A manual reconnect has to be triggerred in such a case.A manual reconnect can be triggered by doing the following,
echo 1 > /sys/class/rtrs-client/blya/paths/<select-path>/reconnect
Signed-off-by Md Haris Iqbal <[email protected]>Reviewed-by Gioh Kim <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 10 ++++ drivers/infiniband/ulp/rtrs/rtrs-srv.c | 82 +++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-)drivers/infiniband/ulp/rtrs/rtrs-clt.c +10
-0@@ -1898,6 +1898,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con, struct rdma_cm_event *ev) {struct rtrs_sess *s = con->c.sess; +struct rtrs_clt_sess *sess =to_clt_sess (s);const struct rtrs_msg_conn_rsp *msg;const char *rej_msg;int status, errno;@@ -1916,6 +1917,15 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con,rtrs_err (s,"Connect rejected: status %d (%s), rtrs errno %d\n" , status, rej_msg, errno); + +if (errno == -ENETDOWN ) { +/* +* Stop reconnection attempts +*/ + sess->reconnect_attempts =-1 ; +rtrs_err (s, +"Disabling auto-reconnect. Trigger a manual reconnect after issue is resolved\n" ); + } }else { rtrs_err(s, "Connect rejected but with malformed message: status %d (%s)\n",drivers/infiniband/ulp/rtrs/rtrs-srv.c +33
-0@@ -32,7 +32,9 @@ MODULE_LICENSE("GPL");static struct rtrs_rdma_dev_pd dev_pd;static mempool_t *chunk_pool;struct class *rtrs_dev_class; +static struct device *rtrs_dev;static struct rtrs_srv_ib_ctx ib_ctx; +static char disabled_port[NAME_MAX ];static int __read_mostly max_chunk_size =DEFAULT_MAX_CHUNK_SIZE ;static int __read_mostly sess_queue_depth =DEFAULT_SESS_QUEUE_DEPTH ;@@ -1826,6 +1828,20 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id,u16 recon_cnt;int err = -ECONNRESET ; +if (strnlen (disabled_port,NAME_MAX ) >0 ) { +char ib_device[NAME_MAX ]; + +snprintf (ib_device,NAME_MAX ,"%s %u" , cm_id->device->name, cm_id->port_num); +if (strncmp (disabled_port, ib_device,NAME_MAX ) ==0 ) { +/* +* Reject connection attempt on disabled port +*/ +pr_err ("Error: Connection request on a disabled port" ); + err = -ENETDOWN ; + goto reject_w_err; + } + } +if (len <sizeof (*msg)) {pr_err ("Invalid RTRS connection request\n" ); goto reject_w_err;@@ -2242,6 +2258,56 @@ static int check_module_params(void)return 0 ; } +static ssize_t disable_port_show (struct kobject *kobj, +struct kobj_attribute *attr, +char *page) +{ +return sysfs_emit (page,"%s\n" , disabled_port); +} + +static ssize_t disable_port_store (struct kobject *kobj, +struct kobj_attribute *attr, +const char *buf,size_t count) +{ +int ret, len; + +if (count >1 &&strnlen (disabled_port,NAME_MAX ) >0 ) { +pr_err ("A disabled port already exists.\n" ); +return -EINVAL ; + }
drivers/infiniband/ulp/rtrs/rtrs-srv.c static int check_module_params(void) · line 2287
Quoted 10 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c +10
-0+ + ret =strscpy (disabled_port, buf,NAME_MAX ); +if (ret == -E2BIG ) { +pr_err ("String too big.\n" ); + disabled_port[0 ] ='\0' ; +return ret; + } + + len =strlen (disabled_port); +if (len >0 && disabled_port[len-1 ] =='\n' )
All the "\n" checks in rtrs sysfs looks like cargo cult. You don't need them.
And maybe Jason thinks differently, but I don't feel comfortable with such new sysfs file at all.
Thanks
Haris Iqbal
maintainerRe: [PATCH for-next 09/10] RDMA/rtrs: Add support to disable an IB port on the storage side
Quoted 116 lines · Leon Romanovsky
Quoted 114 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
This commit adds support to reject connection on a specific IB port which can be specified in the added sysfs entry for the rtrs-server module.
Example,
$ echo "mlx4_0 1" > /sys/class/rtrs-server/ctl/disable_portWhen a connection request is received on the above IB port,
rtrs_srvrejects the connection and notifies the client to disable reconnection attempts. A manual reconnect has to be triggerred in such a case.A manual reconnect can be triggered by doing the following,
echo 1 > /sys/class/rtrs-client/blya/paths/<select-path>/reconnect
Signed-off-by Md Haris Iqbal <[email protected]>Reviewed-by Gioh Kim <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 10 ++++ drivers/infiniband/ulp/rtrs/rtrs-srv.c | 82 +++++++++++++++++++++++++- 2 files changed, 90 insertions(+), 2 deletions(-)drivers/infiniband/ulp/rtrs/rtrs-clt.c +10
-0@@ -1898,6 +1898,7 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con, struct rdma_cm_event *ev) {struct rtrs_sess *s = con->c.sess; +struct rtrs_clt_sess *sess =to_clt_sess (s);const struct rtrs_msg_conn_rsp *msg;const char *rej_msg;int status, errno;@@ -1916,6 +1917,15 @@ static int rtrs_rdma_conn_rejected(struct rtrs_clt_con *con,rtrs_err (s,"Connect rejected: status %d (%s), rtrs errno %d\n" , status, rej_msg, errno); + +if (errno == -ENETDOWN ) { +/* +* Stop reconnection attempts +*/ + sess->reconnect_attempts =-1 ; +rtrs_err (s, +"Disabling auto-reconnect. Trigger a manual reconnect after issue is resolved\n" ); + } }else { rtrs_err(s, "Connect rejected but with malformed message: status %d (%s)\n",drivers/infiniband/ulp/rtrs/rtrs-srv.c +38
-0@@ -32,7 +32,9 @@ MODULE_LICENSE("GPL");static struct rtrs_rdma_dev_pd dev_pd;static mempool_t *chunk_pool;struct class *rtrs_dev_class; +static struct device *rtrs_dev;static struct rtrs_srv_ib_ctx ib_ctx; +static char disabled_port[NAME_MAX ];static int __read_mostly max_chunk_size =DEFAULT_MAX_CHUNK_SIZE ;static int __read_mostly sess_queue_depth =DEFAULT_SESS_QUEUE_DEPTH ;@@ -1826,6 +1828,20 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id,u16 recon_cnt;int err = -ECONNRESET ; +if (strnlen (disabled_port,NAME_MAX ) >0 ) { +char ib_device[NAME_MAX ]; + +snprintf (ib_device,NAME_MAX ,"%s %u" , cm_id->device->name, cm_id->port_num); +if (strncmp (disabled_port, ib_device,NAME_MAX ) ==0 ) { +/* +* Reject connection attempt on disabled port +*/ +pr_err ("Error: Connection request on a disabled port" ); + err = -ENETDOWN ; + goto reject_w_err; + } + } +if (len <sizeof (*msg)) {pr_err ("Invalid RTRS connection request\n" ); goto reject_w_err;@@ -2242,6 +2258,56 @@ static int check_module_params(void)return 0 ; } +static ssize_t disable_port_show (struct kobject *kobj, +struct kobj_attribute *attr, +char *page) +{ +return sysfs_emit (page,"%s\n" , disabled_port); +} + +static ssize_t disable_port_store (struct kobject *kobj, +struct kobj_attribute *attr, +const char *buf,size_t count) +{ +int ret, len; + +if (count >1 &&strnlen (disabled_port,NAME_MAX ) >0 ) { +pr_err ("A disabled port already exists.\n" ); +return -EINVAL ; + } + + ret =strscpy (disabled_port, buf,NAME_MAX ); +if (ret == -E2BIG ) { +pr_err ("String too big.\n" ); + disabled_port[0 ] ='\0' ;
Quoted 8 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c static int check_module_params(void) · line 2287
Quoted 5 lines
drivers/infiniband/ulp/rtrs/rtrs-srv.c +5
-0+return ret; + } + + len =strlen (disabled_port); +if (len >0 && disabled_port[len-1 ] =='\n' )All the "\n" checks in rtrs sysfs looks like cargo cult. You don't need them.
Thanks. Will change and resend.
Quoted 5 lines
And maybe Jason thinks differently, but I don't feel comfortable with such new sysfs file at all.
Thanks
Re: [PATCH for-next 09/10] RDMA/rtrs: Add support to disable an IB port on the storage side
Quoted 19 lines · Haris Iqbal
Quoted 18 lines · Leon Romanovsky
Quoted 16 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
This commit adds support to reject connection on a specific IB port which can be specified in the added sysfs entry for the rtrs-server module.
Example,
$ echo "mlx4_0 1" > /sys/class/rtrs-server/ctl/disable_portWhen a connection request is received on the above IB port,
rtrs_srvrejects the connection and notifies the client to disable reconnection attempts. A manual reconnect has to be triggerred in such a case.A manual reconnect can be triggered by doing the following,
echo 1 > /sys/class/rtrs-client/blya/paths/<select-path>/reconnect
<...>
Quoted 3 lines
Quoted 3 lines
And maybe Jason thinks differently, but I don't feel comfortable with such new sysfs file at all.
This part is much more important and should be cleared before resending.
Quoted 2 lines
Quoted 2 lines
Thanks
Haris Iqbal
maintainerRe: [PATCH for-next 09/10] RDMA/rtrs: Add support to disable an IB port on the storage side
Quoted 22 lines · Leon Romanovsky
Quoted 12 lines · Haris Iqbal
Quoted 11 lines · Leon Romanovsky
Quoted 9 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
This commit adds support to reject connection on a specific IB port which can be specified in the added sysfs entry for the rtrs-server module.
Example,
$ echo "mlx4_0 1" > /sys/class/rtrs-server/ctl/disable_portQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
When a connection request is received on the above IB port,
rtrs_srvrejects the connection and notifies the client to disable reconnection attempts. A manual reconnect has to be triggerred in such a case.A manual reconnect can be triggered by doing the following,
echo 1 > /sys/class/rtrs-client/blya/paths/<select-path>/reconnect
Quoted 7 lines
<...>
Quoted 3 lines
Quoted 3 lines
And maybe Jason thinks differently, but I don't feel comfortable with such new sysfs file at all.
This part is much more important and should be cleared before resending.
Agreed. I will wait for Jason to respond.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Thanks
Re: [PATCH for-next 09/10] RDMA/rtrs: Add support to disable an IB port on the storage side
Quoted 26 lines · Haris Iqbal
Quoted 25 lines · Leon Romanovsky
Quoted 19 lines · Haris Iqbal
Quoted 18 lines · Leon Romanovsky
Quoted 16 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
This commit adds support to reject connection on a specific IB port which can be specified in the added sysfs entry for the rtrs-server module.
Example,
$ echo "mlx4_0 1" > /sys/class/rtrs-server/ctl/disable_portWhen a connection request is received on the above IB port,
rtrs_srvrejects the connection and notifies the client to disable reconnection attempts. A manual reconnect has to be triggerred in such a case.A manual reconnect can be triggered by doing the following,
echo 1 > /sys/class/rtrs-client/blya/paths/<select-path>/reconnect
<...>
Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
And maybe Jason thinks differently, but I don't feel comfortable with such new sysfs file at all.
This part is much more important and should be cleared before resending.
Agreed. I will wait for Jason to respond.
Based on some past conversation with Greg I'm skeptical he would approve of this kind of usage of sysfs..
It is also very strange that this is under a class directory, I'm starting to think it was a mistake to merge the original sysfs stuff :(
Can you do this some other way?
Jason
Haris Iqbal
maintainerRe: [PATCH for-next 09/10] RDMA/rtrs: Add support to disable an IB port on the storage side
Quoted 35 lines · Jason Gunthorpe
Quoted 26 lines · Haris Iqbal
Quoted 25 lines · Leon Romanovsky
Quoted 19 lines · Haris Iqbal
Quoted 18 lines · Leon Romanovsky
Quoted 16 lines · Jack Wang
From: Md Haris Iqbal <[email protected]>
This commit adds support to reject connection on a specific IB port which can be specified in the added sysfs entry for the rtrs-server module.
Example,
$ echo "mlx4_0 1" > /sys/class/rtrs-server/ctl/disable_portWhen a connection request is received on the above IB port,
rtrs_srvrejects the connection and notifies the client to disable reconnection attempts. A manual reconnect has to be triggerred in such a case.A manual reconnect can be triggered by doing the following,
echo 1 > /sys/class/rtrs-client/blya/paths/<select-path>/reconnect
<...>
Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
And maybe Jason thinks differently, but I don't feel comfortable with such new sysfs file at all.
This part is much more important and should be cleared before resending.
Agreed. I will wait for Jason to respond.
Quoted 8 lines
Based on some past conversation with Greg I'm skeptical he would approve of this kind of usage of sysfs..
It is also very strange that this is under a class directory, I'm starting to think it was a mistake to merge the original sysfs stuff :(
Can you do this some other way?
I understand the discomfort. I will try to see if there is another way to do this.
In the meanwhile, I will resend the other patches which has been reviewed.
Thanks.
Quoted 2 lines
Jason
Jack Wang
maintainerPATCH 10/10 RDMA/rtrs: remove (void) casting for functions
In reply to Jack WangFrom: Gioh Kim <[email protected]>
As recommended by Leon
https://www.spinics.net/lists/linux-rdma/msg102200.html
this patch removes (void) casting because that does nothing.
--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-srv.c +2 -2
@@ -1918,7 +1918,7 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, err =create_con (sess, cm_id, cid);if (err) {rtrs_err ((&sess->s),"create_con(), error %d\n" , err); - (void )rtrs_rdma_do_reject (cm_id, err); +rtrs_rdma_do_reject (cm_id, err);/* * Since session has other connections we follow normal way * through workqueue, but still return an error to tell cma.c
@@ -1929,7 +1929,7 @@ static int rtrs_rdma_connect(struct rdma_cm_id *cm_id, err =rtrs_rdma_do_accept (sess, cm_id);if (err) {rtrs_err ((&sess->s),"rtrs_rdma_do_accept(), error %d\n" , err); - (void )rtrs_rdma_do_reject (cm_id, err); +rtrs_rdma_do_reject (cm_id, err);/* * Since current connection was successfully added to the * session we follow normal way through workqueue to close the
Signature · 1 line
2.25.1
Re: [PATCH for-next 10/10] RDMA/rtrs: remove (void) casting for functions
Quoted 6 lines · Jack Wang
From: Gioh Kim <[email protected]>
As recommended by Leon
https://www.spinics.net/lists/linux-rdma/msg102200.html
this patch removes (void) casting because that does nothing.
Quoted 7 lines
Signed-off-by Gioh Kim <[email protected]>Reviewed-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
I would write the commit message differently:
------
Casting to (void) does nothing, remove them.
Haris Iqbal
maintainerRe: [PATCH for-next 10/10] RDMA/rtrs: remove (void) casting for functions
Quoted 16 lines · Leon Romanovsky
Quoted 6 lines · Jack Wang
From: Gioh Kim <[email protected]>
As recommended by Leon
https://www.spinics.net/lists/linux-rdma/msg102200.html
this patch removes (void) casting because that does nothing.Quoted 7 lines
Signed-off-by Gioh Kim <[email protected]>Reviewed-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>--- drivers/infiniband/ulp/rtrs/rtrs-srv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 8 lines
I would write the commit message differently:
------
Casting to (void) does nothing, remove them.
Thanks Leon. Will change and resend.
Quoted 3 lines
Signed-off-by Gioh Kim <[email protected]>Reviewed-by Md Haris Iqbal <[email protected]>Signed-off-by Jack Wang <[email protected]>