Commit d6ea3950 authored by Danil Kipnis's avatar Danil Kipnis Committed by Jason Gunthorpe

rnbd/rtrs: Pass max segment size from blk user to the rdma library

When Block Device Layer is disabled, BLK_MAX_SEGMENT_SIZE is undefined.
The rtrs is a transport library and should compile independently of the
block layer. The desired max segment size should be passed down by the
user.

Introduce max_segment_size parameter for the rtrs_clt_open() call.

Fixes: f7a7a5c2 ("block/rnbd: client: main functionality")
Fixes: 6a98d71d ("RDMA/rtrs: client: main functionality")
Fixes: cb80329c ("RDMA/rtrs: client: private header with client structs and functions")
Fixes: b5c27cdb ("RDMA/rtrs: public interface header to establish RDMA connections")
Link: https://lore.kernel.org/r/20200519111419.924170-1-danil.kipnis@cloud.ionos.comSigned-off-by: default avatarDanil Kipnis <danil.kipnis@cloud.ionos.com>
Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 6b31afce
......@@ -1216,6 +1216,7 @@ find_and_get_or_create_sess(const char *sessname,
paths, path_cnt, port_nr,
sizeof(struct rnbd_iu),
RECONNECT_DELAY, BMAX_SEGMENTS,
BLK_MAX_SEGMENT_SIZE,
MAX_RECONNECTS);
if (IS_ERR(sess->rtrs)) {
err = PTR_ERR(sess->rtrs);
......
......@@ -12,7 +12,6 @@
#include <linux/module.h>
#include <linux/rculist.h>
#include <linux/blkdev.h> /* for BLK_MAX_SEGMENT_SIZE */
#include "rtrs-clt.h"
#include "rtrs-log.h"
......@@ -1406,7 +1405,8 @@ static void rtrs_clt_close_work(struct work_struct *work);
static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt,
const struct rtrs_addr *path,
size_t con_num, u16 max_segments)
size_t con_num, u16 max_segments,
size_t max_segment_size)
{
struct rtrs_clt_sess *sess;
int err = -ENOMEM;
......@@ -1443,7 +1443,7 @@ static struct rtrs_clt_sess *alloc_sess(struct rtrs_clt *clt,
strlcpy(sess->s.sessname, clt->sessname, sizeof(sess->s.sessname));
sess->s.con_num = con_num;
sess->clt = clt;
sess->max_pages_per_mr = max_segments * BLK_MAX_SEGMENT_SIZE >> 12;
sess->max_pages_per_mr = max_segments * max_segment_size >> 12;
init_waitqueue_head(&sess->state_wq);
sess->state = RTRS_CLT_CONNECTING;
atomic_set(&sess->connected_cnt, 0);
......@@ -2526,6 +2526,7 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num,
void (*link_ev)(void *priv,
enum rtrs_clt_link_ev ev),
unsigned int max_segments,
size_t max_segment_size,
unsigned int reconnect_delay_sec,
unsigned int max_reconnect_attempts)
{
......@@ -2555,6 +2556,7 @@ static struct rtrs_clt *alloc_clt(const char *sessname, size_t paths_num,
clt->port = port;
clt->pdu_sz = pdu_sz;
clt->max_segments = max_segments;
clt->max_segment_size = max_segment_size;
clt->reconnect_delay_sec = reconnect_delay_sec;
clt->max_reconnect_attempts = max_reconnect_attempts;
clt->priv = priv;
......@@ -2636,6 +2638,7 @@ static void free_clt(struct rtrs_clt *clt)
* @pdu_sz: Size of extra payload which can be accessed after permit allocation.
* @reconnect_delay_sec: time between reconnect tries
* @max_segments: Max. number of segments per IO request
* @max_segment_size: Max. size of one segment
* @max_reconnect_attempts: Number of times to reconnect on error before giving
* up, 0 for * disabled, -1 for forever
*
......@@ -2650,6 +2653,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops,
size_t paths_num, u16 port,
size_t pdu_sz, u8 reconnect_delay_sec,
u16 max_segments,
size_t max_segment_size,
s16 max_reconnect_attempts)
{
struct rtrs_clt_sess *sess, *tmp;
......@@ -2658,7 +2662,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops,
clt = alloc_clt(sessname, paths_num, port, pdu_sz, ops->priv,
ops->link_ev,
max_segments, reconnect_delay_sec,
max_segments, max_segment_size, reconnect_delay_sec,
max_reconnect_attempts);
if (IS_ERR(clt)) {
err = PTR_ERR(clt);
......@@ -2668,7 +2672,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops,
struct rtrs_clt_sess *sess;
sess = alloc_sess(clt, &paths[i], nr_cpu_ids,
max_segments);
max_segments, max_segment_size);
if (IS_ERR(sess)) {
err = PTR_ERR(sess);
goto close_all_sess;
......@@ -2917,7 +2921,8 @@ int rtrs_clt_create_path_from_sysfs(struct rtrs_clt *clt,
struct rtrs_clt_sess *sess;
int err;
sess = alloc_sess(clt, addr, nr_cpu_ids, clt->max_segments);
sess = alloc_sess(clt, addr, nr_cpu_ids, clt->max_segments,
clt->max_segment_size);
if (IS_ERR(sess))
return PTR_ERR(sess);
......
......@@ -164,6 +164,7 @@ struct rtrs_clt {
unsigned int max_reconnect_attempts;
unsigned int reconnect_delay_sec;
unsigned int max_segments;
size_t max_segment_size;
void *permits;
unsigned long *permits_map;
size_t queue_depth;
......
......@@ -58,6 +58,7 @@ struct rtrs_clt *rtrs_clt_open(struct rtrs_clt_ops *ops,
size_t path_cnt, u16 port,
size_t pdu_sz, u8 reconnect_delay_sec,
u16 max_segments,
size_t max_segment_size,
s16 max_reconnect_attempts);
void rtrs_clt_close(struct rtrs_clt *sess);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment