[PATCH 10/35] fabrics: export do_discover(), build_options() and config

Hannes Reinecke hare at suse.de
Thu Feb 4 02:09:21 EST 2021


On 1/26/21 9:32 PM, mwilck at suse.com wrote:
> From: Martin Wilck <mwilck at suse.com>
> 
> These functions will be called by the monitor code.
> Also export BUF_SIZE as the size of argstr.
> 
> Being able to access struct config and the "cfg" variable
> from fabrics.c is essential for the monitor to leverage the existing,
> well tested code as much as possible.
> 
> Signed-off-by: Martin Wilck <mwilck at suse.com>
> ---
>   fabrics.c | 33 ++++-----------------------------
>   fabrics.h | 34 ++++++++++++++++++++++++++++++++++
>   2 files changed, 38 insertions(+), 29 deletions(-)
> 
> diff --git a/fabrics.c b/fabrics.c
> index 555b6b4..c1a4bb5 100644
> --- a/fabrics.c
> +++ b/fabrics.c
> @@ -69,31 +69,7 @@ const char *conarg_traddr = "traddr";
>   const char *conarg_trsvcid = "trsvcid";
>   const char *conarg_host_traddr = "host_traddr";
>   
> -static struct config {
> -	char *nqn;
> -	char *transport;
> -	char *traddr;
> -	char *trsvcid;
> -	char *host_traddr;
> -	char *hostnqn;
> -	char *hostid;
> -	int  nr_io_queues;
> -	int  nr_write_queues;
> -	int  nr_poll_queues;
> -	int  queue_size;
> -	int  keep_alive_tmo;
> -	int  reconnect_delay;
> -	int  ctrl_loss_tmo;
> -	int  tos;
> -	char *raw;
> -	char *device;
> -	int  duplicate_connect;
> -	int  disable_sqflow;
> -	int  hdr_digest;
> -	int  data_digest;
> -	bool persistent;
> -	bool matching_only;
> -} cfg = { .ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO };
> +struct config cfg = { .ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO };
>   
>   struct connect_args {
>   	char *subsysnqn;
> @@ -107,7 +83,6 @@ struct connect_args {
>   
>   struct connect_args *tracked_ctrls;
>   
> -#define BUF_SIZE		4096
>   #define PATH_NVME_FABRICS	"/dev/nvme-fabrics"
>   #define PATH_NVMF_DISC		"/etc/nvme/discovery.conf"
>   #define PATH_NVMF_HOSTNQN	"/etc/nvme/hostnqn"
> @@ -226,7 +201,7 @@ static const char *cms_str(__u8 cm)
>   	return arg_str(cms, ARRAY_SIZE(cms), cm);
>   }
>   
> -static int do_discover(char *argstr, bool connect);
> +int do_discover(char *argstr, bool connect);
>   
>   /*
>    * parse strings with connect arguments to find a particular field.
> @@ -855,7 +830,7 @@ add_argument(char **argstr, int *max_len, char *arg_str, char *arg)
>   	return 0;
>   }
>   
> -static int build_options(char *argstr, int max_len, bool discover)
> +int build_options(char *argstr, int max_len, bool discover)
>   {
>   	int len;
>   
> @@ -1264,7 +1239,7 @@ static void nvmf_get_host_identifiers(int ctrl_instance)
>   	cfg.hostid = nvme_get_ctrl_attr(path, "hostid");
>   }
>   
> -static int do_discover(char *argstr, bool connect)
> +int do_discover(char *argstr, bool connect)
>   {
>   	struct nvmf_disc_rsp_page_hdr *log = NULL;
>   	char *dev_name;
> diff --git a/fabrics.h b/fabrics.h
> index f5b8eaf..ce965a3 100644
> --- a/fabrics.h
> +++ b/fabrics.h
> @@ -10,4 +10,38 @@ extern int fabrics_connect(const char *desc, int argc, char **argv);
>   extern int fabrics_disconnect(const char *desc, int argc, char **argv);
>   extern int fabrics_disconnect_all(const char *desc, int argc, char **argv);
>   
> +/* Symbols used by monitor.c */
> +
> +struct config {
> +	char *nqn;
> +	char *transport;
> +	char *traddr;
> +	char *trsvcid;
> +	char *host_traddr;
> +	char *hostnqn;
> +	char *hostid;
> +	int  nr_io_queues;
> +	int  nr_write_queues;
> +	int  nr_poll_queues;
> +	int  queue_size;
> +	int  keep_alive_tmo;
> +	int  reconnect_delay;
> +	int  ctrl_loss_tmo;
> +	int  tos;
> +	char *raw;
> +	char *device;
> +	int  duplicate_connect;
> +	int  disable_sqflow;
> +	int  hdr_digest;
> +	int  data_digest;
> +	bool persistent;
> +	bool matching_only;
> +};
> +extern struct config cfg;
> +
> +#define BUF_SIZE 4096
> +
> +int build_options(char *argstr, int max_len, bool discover);
> +int do_discover(char *argstr, bool connect);
> +
>   #endif
> 

Please name is 'struct config fabrics_cfg'. 'cfg' is used as a generic 
name throughout the code, and using the same name in a header might lead 
to an accidental name clash.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare at suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer



More information about the Linux-nvme mailing list