fabrics: don't pass sqflow_disable if the kernel does not support the option
Sagi Grimberg
maintainerPATCH 1/1 fabrics: don't pass sqflow_disable if the kernel does not support the option
Instead of retrying again without it.
--- src/nvme/fabrics.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
src/nvme/fabrics.c +1 -11
@@ -1026,7 +1026,7 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,return NULL ; } -if (e->treq &NVMF_TREQ_DISABLE_SQFLOW ) +if (e->treq &NVMF_TREQ_DISABLE_SQFLOW && h->r->options->disable_sqflow) c->cfg.disable_sqflow = true; if (e->trtype == NVMF_TRTYPE_TCP &&
@@ -1038,16 +1038,6 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,if (!ret)return c; -if (errno ==EINVAL && c->cfg.disable_sqflow) { - errno =0 ; -/* disable_sqflow is unrecognized option on older kernels */ -nvme_msg (h->r,LOG_INFO ,"failed to connect controller, " -"retry with disabling SQ flow control\n" ); - c->cfg.disable_sqflow = false; - ret =nvmf_add_ctrl (h, c, cfg); -if (!ret) -return c; - }nvme_free_ctrl (c);return NULL ; }
Signature · 1 line
2.41.0
Hi Sagi,
Quoted 13 lines · Sagi Grimberg
Instead of retrying again without it.
Signed-off-by Sagi Grimberg <[email protected]>--- src/nvme/fabrics.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)src/nvme/fabrics.c +0
-0
src/nvme/fabrics.c nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h, · line 1029
Quoted 5 lines
src/nvme/fabrics.c +1
-1@@ -1026,7 +1026,7 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,return NULL ; } -if (e->treq &NVMF_TREQ_DISABLE_SQFLOW ) +if (e->treq &NVMF_TREQ_DISABLE_SQFLOW && h->r->options->disable_sqflow)
How do we know options is initialized here? It looks like that's done in __nvmf_supported_options(), called from nvmf_add_ctrl(), which is called a few lines later in this function.
src/nvme/fabrics.c nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h, · line 1043
Quoted 10 lines
src/nvme/fabrics.c +0
-3c->cfg.disable_sqflow = true; if (e->trtype == NVMF_TRTYPE_TCP &&@@ -1038,16 +1038,6 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,if (!ret)return c; -if (errno ==EINVAL && c->cfg.disable_sqflow) { - errno =0 ; -/* disable_sqflow is unrecognized option on older kernels */
The kernel didn't add support for reporting its supported options until 5.17. If the kernel doesn't report this information, we fall back to default_supported_options, which represents the options the kernel supported when the reporting mechanism was added. These include disable_sqflow, so h->r->options->disable_sqflow will always be true (unless support for it is removed in the future), even if the kernel is an old version that doesn't support it. So if this disable_sqflow fallback behavior is necessary for older kernels, I don't think it can safely be replaced by the h->r->options->disable_sqflow check.
Quoted 11 lines
src/nvme/fabrics.c +0
-8-nvme_msg (h->r,LOG_INFO ,"failed to connect controller, " -"retry with disabling SQ flow control\n" ); - c->cfg.disable_sqflow = false; - ret =nvmf_add_ctrl (h, c, cfg); -if (!ret) -return c; - }nvme_free_ctrl (c);return NULL ; } --
Quoted 3 lines
2.41.0
Best,
Caleb
Sagi Grimberg
maintainerQuoted 20 lines
Hi Sagi,
Quoted 16 lines · Sagi Grimberg
Instead of retrying again without it.
Signed-off-by Sagi Grimberg <[email protected]>--- src/nvme/fabrics.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)src/nvme/fabrics.c +0
-0@@ -1026,7 +1026,7 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,return NULL ; }
Quoted 6 lines
src/nvme/fabrics.c nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h, · line 1029
Quoted 2 lines
src/nvme/fabrics.c +1
-1-if (e->treq &NVMF_TREQ_DISABLE_SQFLOW ) +if (e->treq &NVMF_TREQ_DISABLE_SQFLOW && h->r->options->disable_sqflow)How do we know options is initialized here? It looks like that's done in
__nvmf_supported_options(), called fromnvmf_add_ctrl(), which is called a few lines later in this function.
This is for connecting discovery log entries, so the kernel cap was already read once for the discovery controller.
Although granted, this can be udev driven on an existing discovery controller. Probably need to do it regardless of adding a controller.
I remember when adding the capability to check supported opts I added an interface to do it per feature. Not sure why it was changed, it is much more sane to just read it on demand given that there is just a simple and short string copy in the kernel...
Ideally this would become:
if (e->treq & NVMF_TREQ_DISABLE_SQFLOW &&
nvmf_check_cap("disable_sqflow"))
c->cfg.disable_sqflow = true;
else
c->cfg.disable_sqflow = false;Daniel? Any reason why we are caching these opts in an executable with a short lifetime? And apparently we need to be very precise when we rely on this cache to be stable.
If you prefer to cache it, at least do it in the start of every fabrics callback so we don't need to understand when this cache is valid...
Quoted 8 lines
Quoted 8 lines
src/nvme/fabrics.c +0
-0c->cfg.disable_sqflow = true; if (e->trtype == NVMF_TRTYPE_TCP &&@@ -1038,16 +1038,6 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,if (!ret)return c;
Quoted 13 lines
src/nvme/fabrics.c nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h, · line 1043
Quoted 3 lines
src/nvme/fabrics.c +0
-3-if (errno ==EINVAL && c->cfg.disable_sqflow) { - errno =0 ; -/* disable_sqflow is unrecognized option on older kernels */ The kernel didn't add support for reporting its supported options until 5.17. If the kernel doesn't report this information, we fall back to
default_supported_options, which represents the options the kernel supported when the reporting mechanism was added. These includedisable_sqflow, soh->r->options->disable_sqflowwill always be true (unless support for it is removed in the future), even if the kernel is an old version that doesn't support it. So if thisdisable_sqflowfallback behavior is necessary for older kernels, I don't think it can safely be replaced by theh->r->options->disable_sqflowcheck.
You right, it needs an else case, so we always set it based on the default/treq _and_ what the kernel supports.
I will hold off with this patch until Daniel will reply to what he thinks needs to be done here.
Quoted 28 lines · Sagi Grimberg
Quoted 21 lines
Hi Sagi,
Quoted 16 lines · Sagi Grimberg
Instead of retrying again without it.
Signed-off-by Sagi Grimberg <[email protected]>--- src/nvme/fabrics.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)src/nvme/fabrics.c +0
-0@@ -1026,7 +1026,7 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,return NULL ; }Quoted 6 lines
src/nvme/fabrics.c nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h, · line 1029
Quoted 2 lines
src/nvme/fabrics.c +1
-1-if (e->treq &NVMF_TREQ_DISABLE_SQFLOW ) +if (e->treq &NVMF_TREQ_DISABLE_SQFLOW && h->r->options->disable_sqflow)How do we know options is initialized here? It looks like that's done in
__nvmf_supported_options(), called fromnvmf_add_ctrl(), which is called a few lines later in this function.
Quoted 5 lines
This is for connecting discovery log entries, so the kernel cap was already read once for the discovery controller.
Although granted, this can be udev driven on an existing discovery controller. Probably need to do it regardless of adding a controller.
Yes, I would avoid depending on the assumption that a connection has already been made, especially since libnvme is designed to be a standalone library, not necessarily used by nvme-cli.
Quoted 13 lines
I remember when adding the capability to check supported opts I added an interface to do it per feature. Not sure why it was changed, it is much more sane to just read it on demand given that there is just a simple and short string copy in the kernel...
Ideally this would become:
if (e->treq & NVMF_TREQ_DISABLE_SQFLOW && nvmf_check_cap("disable_sqflow")) c->cfg.disable_sqflow = true; else c->cfg.disable_sqflow = false;
Quoted 3 lines
Daniel? Any reason why we are caching these opts in an executable with a short lifetime? And apparently we need to be very precise when we rely on this cache to be stable.
I agree an interface like that to get the supported options on demand would be much more ergonomic. I think the current design makes sense as long the options are only needed in build_options(). I do think it's good to minimize system calls to get this information; making one for each option passed would be a significant overhead. The type-checking provided by the nvme_fabric_options field names also seems beneficial over plain string comparisons. But we could easily add a nvmf_check_cap() wrapper around __nvmf_supported_options(), since __nvmf_supported_options() already caches the supported options. (I would personally prefer a name like "nvmef_option_supported" since "capability" has a different meaning in the NVMe specifications.)
#define nvmf_option_supported(r, tok) \
(!__nvmf_supported_options(r) && (r)->options->tok)Quoted 32 lines
If you prefer to cache it, at least do it in the start of every fabrics callback so we don't need to understand when this cache is valid...
Quoted 8 lines
Quoted 8 lines
src/nvme/fabrics.c +0
-0c->cfg.disable_sqflow = true; if (e->trtype == NVMF_TRTYPE_TCP &&@@ -1038,16 +1038,6 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,if (!ret)return c;Quoted 13 lines
src/nvme/fabrics.c nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h, · line 1043
Quoted 3 lines
src/nvme/fabrics.c +0
-3-if (errno ==EINVAL && c->cfg.disable_sqflow) { - errno =0 ; -/* disable_sqflow is unrecognized option on older kernels */ The kernel didn't add support for reporting its supported options until 5.17. If the kernel doesn't report this information, we fall back to
default_supported_options, which represents the options the kernel supported when the reporting mechanism was added. These includedisable_sqflow, soh->r->options->disable_sqflowwill always be true (unless support for it is removed in the future), even if the kernel is an old version that doesn't support it. So if thisdisable_sqflowfallback behavior is necessary for older kernels, I don't think it can safely be replaced by theh->r->options->disable_sqflowcheck.You right, it needs an else case, so we always set it based on the default/treq _and_ what the kernel supports.
I will hold off with this patch until Daniel will reply to what he thinks needs to be done here.
Quoted 3 lines · Sagi Grimberg
Quoted 3 lines
How do we know options is initialized here? It looks like that's done in
__nvmf_supported_options(), called fromnvmf_add_ctrl(), which is called a few lines later in this function.
I've paired __nvmf_supported_options() with build_options(). We can move the call to __nvmf_supported_options() further up if it helps.
Quoted 10 lines
This is for connecting discovery log entries, so the kernel cap was already read once for the discovery controller.
Although granted, this can be udev driven on an existing discovery controller. Probably need to do it regardless of adding a controller.
I remember when adding the capability to check supported opts I added an interface to do it per feature. Not sure why it was changed, it is much more sane to just read it on demand given that there is just a simple and short string copy in the kernel...
I was trying to avoid to do a open/read/parse/close cycle for each argument we are going append in the build_options() function.
Quoted 10 lines
Ideally this would become:
if (e->treq & NVMF_TREQ_DISABLE_SQFLOW && nvmf_check_cap("disable_sqflow")) c->cfg.disable_sqflow = true; else c->cfg.disable_sqflow = false;Daniel? Any reason why we are caching these opts in an executable with a short lifetime? And apparently we need to be very precise when we rely on this cache to be stable.
Ah I see, in this case let's bring nvmf_check_cap() (although I couldn't find it anywhere... I can remember I saw those patches)
Quoted 3 lines
If you prefer to cache it, at least do it in the start of every fabrics callback so we don't need to understand when this cache is valid...
I don't want to cache it, I just wanted to avoid the above mentioned open/read/parse/close cycle for each build options.
Sagi Grimberg
maintainerQuoted 7 lines · Daniel Wagner
Quoted 3 lines · Sagi Grimberg
Quoted 3 lines
How do we know options is initialized here? It looks like that's done in
__nvmf_supported_options(), called fromnvmf_add_ctrl(), which is called a few lines later in this function.I've paired
__nvmf_supported_options()withbuild_options(). We can move the call to__nvmf_supported_options()further up if it helps.
We really should just have an interface to check specific options, because that is what consumers care about, not the entire opts set.
Inside you can do the open/read/close once and cache it in memory (although I think this is a really unneeded optimization).
Quoted 22 lines
Quoted 11 lines
This is for connecting discovery log entries, so the kernel cap was already read once for the discovery controller.
Although granted, this can be udev driven on an existing discovery controller. Probably need to do it regardless of adding a controller.
I remember when adding the capability to check supported opts I added an interface to do it per feature. Not sure why it was changed, it is much more sane to just read it on demand given that there is just a simple and short string copy in the kernel...
I was trying to avoid to do a open/read/parse/close cycle for each argument we are going append in the
build_options()function.Quoted 7 lines
Ideally this would become:
if (e->treq & NVMF_TREQ_DISABLE_SQFLOW && nvmf_check_cap("disable_sqflow")) c->cfg.disable_sqflow = true; else c->cfg.disable_sqflow = false;
Quoted 6 lines
Quoted 3 lines
Daniel? Any reason why we are caching these opts in an executable with a short lifetime? And apparently we need to be very precise when we rely on this cache to be stable.
Ah I see, in this case let's bring
nvmf_check_cap()(although I couldn't find it anywhere... I can remember I saw those patches)
I also remember making disable_sqflow check instead of a retry, so maybe it got left behind...
Quoted 7 lines
Quoted 4 lines
If you prefer to cache it, at least do it in the start of every fabrics callback so we don't need to understand when this cache is valid...
I don't want to cache it, I just wanted to avoid the above mentioned open/read/parse/close cycle for each build options.
So do you want to add the interface? Or should I? (assuming you agree on individual opt check) ?
Quoted 8 lines · Sagi Grimberg
Quoted 2 lines
I've paired
__nvmf_supported_options()withbuild_options(). We can move the call to__nvmf_supported_options()further up if it helps.We really should just have an interface to check specific options, because that is what consumers care about, not the entire opts set.
Inside you can do the open/read/close once and cache it in memory (although I think this is a really unneeded optimization).
There are some users with bigger setups where 8 connections are initiated. We currently have 7 new options avaible which we are looking for. Thus at least 56 the open/read/close step in such a scenario. I found this a bit excessive hence the optimization.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Daniel? Any reason why we are caching these opts in an executable with a short lifetime? And apparently we need to be very precise when we rely on this cache to be stable.
Ah I see, in this case let's bring
nvmf_check_cap()(although I couldn't find it anywhere... I can remember I saw those patches)I also remember making
disable_sqflowcheck instead of a retry, so maybe it got left behind...
I couldn't find in my mail box or on lore. No idea what I did with it. Sorry.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
If you prefer to cache it, at least do it in the start of every fabrics callback so we don't need to understand when this cache is valid...
I don't want to cache it, I just wanted to avoid the above mentioned open/read/parse/close cycle for each build options.
So do you want to add the interface? Or should I? (assuming you agree on individual opt check) ?
Yes, no problems with an individual opt check. Just a sec...
PATCH 1/2 fabrics: Shorten/rename supported option function/vars names
No need to be extra verbose and using so many chars per line.
Also rename to __nvmf_supported_options to nvmf_read_options which describes better what the function actually is doing.
--- src/nvme/fabrics.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
src/nvme/fabrics.c +4 -4
@@ -202,7 +202,7 @@ const char *nvmf_cms_str(__u8 cm)* Not all of these options may actually be supported, * but we retain the old behavior of passing all that might be. */ -static const struct nvme_fabric_options default_supported_options = { +static const struct nvme_fabric_options default_options = { .ctrl_loss_tmo = true, .data_digest = true, .disable_sqflow = true,
@@ -652,7 +652,7 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)continue ; \ } -static int __nvmf_supported_options (nvme_root_t r) +static int nvmf_read_options (nvme_root_t r) {char buf[0x1000 ], *options, *p, *v;int fd, ret;
@@ -683,7 +683,7 @@ static int __nvmf_supported_options(nvme_root_t r)nvme_msg (r,LOG_DEBUG ,"Cannot read %s, using default options\n" , nvmf_dev); - *r->options = default_supported_options; + *r->options = default_options; ret =0 ; goto out_close; }
@@ -913,7 +913,7 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,free (traddr); } - ret =__nvmf_supported_options (h->r); + ret =nvmf_read_options (h->r);if (ret)return ret; ret =build_options (h, c, &argstr);
Signature · 1 line
2.41.0
PATCH 2/2 fabrics: Do not pass disable_sqflow if not supported
Only retry a connect attempt with disable_sqflow if the kernel actually supports this option.
--- src/nvme/fabrics.c | 85 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-)
src/nvme/fabrics.c +84 -1
@@ -227,6 +227,32 @@ static const struct nvme_fabric_options default_options = { .trsvcid = true, }; +static const char *default_options_strings[] = +{ +"ctrl_loss_tmo" , +"data_digest" , +"disable_sqflow" , +"discovery" , +"duplicate_connect" , +"fast_io_fail_tmo" , +"hdr_digest" , +"host_iface" , +"host_traddr" , +"hostid" , +"hostnqn" , +"keep_alive_tmo" , +"nqn" , +"nr_io_queues" , +"nr_poll_queues" , +"nr_write_queues" , +"queue_size" , +"reconnect_delay" , +"tos" , +"traddr" , +"transport" , +"trsvcid" , +}; +void nvmf_default_config (struct nvme_fabrics_config *cfg) {memset (cfg,0 ,sizeof (*cfg));
@@ -652,6 +678,62 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)continue ; \ } +static bool nvme_check_default_option (const char *opt) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (default_options_strings); i++) { +if (!strcmp (opt, default_options_strings[i])) +return true; + } +return false; +} + +static bool nvmf_check_option (const char *opt) +{ +char buf[0x1000 ], *options, *p, *v; +ssize_t len; +int fd; +bool supported = false; + + fd =open (nvmf_dev,O_RDONLY ); +if (fd <0 ) +return false; + + len =read (fd, buf,sizeof (buf) -1 ); +if (len <0 ) { +if (errno ==EINVAL ) { +/* +* Older Linux kernels don't allow reading from nvmf_dev +* to get supported options, so use a default set +*/ + supported =nvme_check_default_option (opt); + } + + goto out_close; + } + + buf[len] ='\0' ; + options = buf; +while ((p =strsep (&options,",\n" )) !=NULL ) { +if (!*p) +continue ; + v =strsep (&p,"= " ); +if (!v) +continue ; + +if (strcmp (opt, v)) +continue ; + + supported = true; +break ; + } + +out_close: +close (fd); +return supported; +} +static int nvmf_read_options (nvme_root_t r) {char buf[0x1000 ], *options, *p, *v;
@@ -1038,7 +1120,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 ("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
Sagi Grimberg
maintainerRe: [PATH libnvme v1 1/2] fabrics: Shorten/rename supported option function/vars names
In reply to Daniel WagnerQuoted 43 lines
No need to be extra verbose and using so many chars per line.
Also rename to
__nvmf_supported_optionstonvmf_read_optionswhich describes better what the function actually is doing.Signed-off-by Daniel Wagner <[email protected]>--- src/nvme/fabrics.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)src/nvme/fabrics.c +3
-3@@ -202,7 +202,7 @@ const char *nvmf_cms_str(__u8 cm)* Not all of these options may actually be supported, * but we retain the old behavior of passing all that might be. */ -static const struct nvme_fabric_options default_supported_options = { +static const struct nvme_fabric_options default_options = { .ctrl_loss_tmo = true, .data_digest = true, .disable_sqflow = true,@@ -652,7 +652,7 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)continue ; \ } -static int __nvmf_supported_options (nvme_root_t r) +static int nvmf_read_options (nvme_root_t r) {char buf[0x1000 ], *options, *p, *v;int fd, ret;@@ -683,7 +683,7 @@ static int __nvmf_supported_options(nvme_root_t r)nvme_msg (r,LOG_DEBUG ,"Cannot read %s, using default options\n" , nvmf_dev); - *r->options = default_supported_options; + *r->options = default_options; ret =0 ; goto out_close; }
src/nvme/fabrics.c int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, · line 919
Quoted 8 lines
src/nvme/fabrics.c +1
-1@@ -913,7 +913,7 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,free (traddr); } - ret =__nvmf_supported_options (h->r); + ret =nvmf_read_options (h->r);if (ret)return ret; ret =build_options (h, c, &argstr);
Why do we need an explicit call here?
Why it cannot be read on the first capability check?
Something like:
--
src/nvme/fabrics.c +12 -7
@@ -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;
--
Then, we can spray options check wherever we want...
--
@@ -1026,8 +1031,10 @@ nvme_ctrl_t nvmf_connect_disc_entry(nvme_host_t h,
return NULL;
}- 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 ||--
Re: [PATH libnvme v1 1/2] fabrics: Shorten/rename supported option function/vars names
Quoted 10 lines · Sagi Grimberg
src/nvme/fabrics.c int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c, · line 918
Quoted 8 lines
src/nvme/fabrics.c +1
-1@@ -913,7 +913,7 @@ int nvmf_add_ctrl(nvme_host_t h, nvme_ctrl_t c,free (traddr); } - ret =__nvmf_supported_options (h->r); + ret =nvmf_read_options (h->r);if (ret)return ret; ret =build_options (h, c, &argstr);Why do we need an explicit call here?
No particially reason.
Quoted 1 line
Why it cannot be read on the first capability check?
Ah good idea!
Quoted 26 lines
Something like:
--src/nvme/fabrics.c +9
-1@@ -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), \
Quoted 1 line
arg); \
Sure, makes sense!