Skip to contentSkip to conversation

Do not pass disable_sqflow if not supported

PATCH Superseded Daniel Wagner 2 participants 5 messages Aug 8, 2023 NVMe

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Do not pass disable_sqflow if not supported

Follow up on the discussion in [1]

[1] https://lore.kernel.org/linux-nvme/[email protected]/

Sagi Grimberg (2):
fabrics: Read the supported options lazy
fabrics: Do not pass disable_sqflow if not supported

 src/nvme/fabrics.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH v2 1/2 fabrics: Read the supported options lazy

From: Sagi Grimberg <[email protected]>

Read the options in when we need the for the first time.

---
 src/nvme/fabrics.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
src/nvme/fabrics.c +12 -7
index 800293e2a8e7..9725eeb3cda8 100644
@@ -357,10 +357,18 @@ static int __add_argument(char **argstr, const char *tok, const char *arg)
 	return 0;
 }
 
+static int __nvmf_supported_options(nvme_root_t r);
+#define nvmf_check_option(r, tok)					\
+({									\
+	if (!(r)->options)						\
+		__nvmf_supported_options(r);				\
+	(r)->options->tok;						\
+})
+
 #define add_bool_argument(o, argstr, tok, arg)				\
 ({									\
 	int ret;							\
-	if (r->options->tok) {						\
+	if (nvmf_check_option(r, tok)) {				\
 		ret = __add_bool_argument(argstr,			\
 					  stringify(tok),		\
 					  arg);				\
@@ -376,7 +384,7 @@ static int __add_argument(char **argstr, const char *tok, const char *arg)
 #define add_int_argument(o, argstr, tok, arg, allow_zero) \
 ({									\
 	int ret;							\
-	if (r->options->tok) {						\
+	if (nvmf_check_option(r, tok)) {				\
 		ret = __add_int_argument(argstr,			\
 					stringify(tok),			\
 					arg,				\
@@ -393,7 +401,7 @@ static int __add_argument(char **argstr, const char *tok, const char *arg)
 #define add_int_or_minus_one_argument(o, argstr, tok, arg)		\
 ({									\
 	int ret;							\
-	if (r->options->tok) {						\
+	if (nvmf_check_option(r, tok)) {				\
 		ret = __add_int_or_minus_one_argument(argstr,		\
 						     stringify(tok),	\
 						     arg);		\
@@ -409,7 +417,7 @@ static int __add_argument(char **argstr, const char *tok, const char *arg)
 #define add_argument(r, argstr, tok, arg)				\
 ({									\
 	int ret;							\
-	if (r->options->tok) {						\
+	if (nvmf_check_option(r, tok)) {				\
 		ret = __add_argument(argstr,				\
 				     stringify(tok),			\
 				     arg);				\
@@ -913,9 +921,6 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,
 		free(traddr);
 	}
 
-	ret = __nvmf_supported_options(h->r);
-	if (ret)
-		return ret;
 	ret = build_options(h, c, &argstr);
 	if (ret)
 		return ret;
Signature · 1 line
2.41.0
#2 lore raw

PATCH v2 2/2 fabrics: Do not pass disable_sqflow if not supported

In reply to Daniel Wagner

From: Sagi Grimberg <[email protected]>

Only retry a connect attempt with disable_sqflow if the kernel actually supports this option.

---
 src/nvme/fabrics.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/nvme/fabrics.c +2 -1
index 9725eeb3cda8..f0e85d3b766d 100644
@@ -1043,7 +1043,8 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
 	if (!ret)
 		return c;
 
-	if (errno == EINVAL && c->cfg.disable_sqflow) {
+	if (errno == EINVAL && c->cfg.disable_sqflow &&
+	    nvmf_check_option(h->r, disable_sqflow)) {
 		errno = 0;
 		/* disable_sqflow is unrecognized option on older kernels */
 		nvme_msg(h->r, LOG_INFO, "failed to connect controller, "
Signature · 1 line
2.41.0
maintainer
#3 lore raw

Re: [PATCH libnvme v2 2/2] fabrics: Do not pass disable_sqflow if not supported

Quoted 15 lines

Only retry a connect attempt with disable_sqflow if the kernel actually supports this option.

---
  src/nvme/fabrics.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
src/nvme/fabrics.c +0 -0
index 9725eeb3cda8..f0e85d3b766d 100644

src/nvme/fabrics.c nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h, · line 1050

Quoted 9 lines
src/nvme/fabrics.c +2 -1
@@ -1043,7 +1043,8 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
  	if (!ret)
  		return c;
 
-	if (errno == EINVAL && c->cfg.disable_sqflow) {
+	if (errno == EINVAL && c->cfg.disable_sqflow &&
+	    nvmf_check_option(h->r, disable_sqflow)) {
  		errno = 0;
  		/* disable_sqflow is unrecognized option on older kernels */
  		nvme_msg(h->r, LOG_INFO, "failed to connect controller, "

I think you want to check this before the initial call and avoid the retry altogether.
--
- if (e->treq & NVMF_TREQ_DISABLE_SQFLOW)
+ if (e->treq & NVMF_TREQ_DISABLE_SQFLOW &&
+ nvmf_check_option(h->r, disable_sqflow))

                c->cfg.disable_sqflow = true;

+ else
+ c->cfg.disable_sqflow = false;

        if (e->trtype == NVMF_TRTYPE_TCP &&
            (e->treq & NVMF_TREQ_REQUIRED ||

--

#4 lore raw

Re: [PATCH libnvme v2 2/2] fabrics: Do not pass disable_sqflow if not supported

Review

Quoted 12 lines · Sagi Grimberg

I think you want to check this before the initial call and avoid the retry altogether.
--

(quoted diff) +4 -1
-       if (e->treq & NVMF_TREQ_DISABLE_SQFLOW)
+       if (e->treq & NVMF_TREQ_DISABLE_SQFLOW &&
+           nvmf_check_option(h->r, disable_sqflow))
                c->cfg.disable_sqflow = true;
+       else
+               c->cfg.disable_sqflow = false;
 
        if (e->trtype == NVMF_TRTYPE_TCP &&
            (e->treq & NVMF_TREQ_REQUIRED ||

Yep, makes sense.