[PATH libnvme v1 1/2] fabrics: Shorten/rename supported option function/vars names

Daniel Wagner dwagner at suse.de
Fri Jul 28 02:39:15 PDT 2023


On Tue, Jul 25, 2023 at 01:55:00PM +0300, Sagi Grimberg wrote:
> > @@ -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.

> Why it cannot be read on the first capability check?

Ah good idea!

> Something like:
> --
> diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c
> index 800293e2a8e7..bb4bf2979eb0 100644
> --- a/src/nvme/fabrics.c
> +++ b/src/nvme/fabrics.c
> @@ -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);                         \

Sure, makes sense!



More information about the Linux-nvme mailing list