nvme: print out valid arguments when reading from /dev/nvme-fabrics
PATCH 1/1 nvme: print out valid arguments when reading from /dev/nvme-fabrics
Currently applications have a hard time figuring out which nvme-over-fabrics arguments are supported for any given kernel; the ioctl will return an error code on failure, and the application has to guess whether this was due to an invalid argument or due to a connection or controller error.
With this patch applications can read a list of supported arguments by simply reading from /dev/nvme-fabrics, allowing them to validate the connection string.
--- drivers/nvme/host/fabrics.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/nvme/host/fabrics.c +12 -1
@@ -1144,7 +1144,18 @@ static int nvmf_dev_show(struct seq_file *seq_file, void *private)mutex_lock (&nvmf_dev_mutex); ctrl = seq_file->private;if (!ctrl) { - ret = -EINVAL ; +const struct match_token *tok; +int idx; + +for (idx =0 ; idx <ARRAY_SIZE (opt_tokens); idx++) { + tok = &opt_tokens[idx]; +if (tok->token ==NVMF_OPT_ERR ) +continue ; +if (idx) +seq_puts (seq_file,"," ); +seq_puts (seq_file, tok->pattern); + } +seq_puts (seq_file,"\n" ); goto out_unlock; }
Signature · 1 line
2.29.2
Quoted 10 lines · Hannes Reinecke
Currently applications have a hard time figuring out which nvme-over-fabrics arguments are supported for any given kernel; the ioctl will return an error code on failure, and the application has to guess whether this was due to an invalid argument or due to a connection or controller error.
With this patch applications can read a list of supported arguments by simply reading from/dev/nvme-fabrics, allowing them to validate the connection string.Signed-off-by Hannes Reinecke <[email protected]>
this seems useful and will avoid a trip to the source code.
Looks good.
Christoph Hellwig
maintainerThe subject should use a nvme-fabrics prefix.
drivers/nvme/host/fabrics.c static int nvmf_dev_show(struct seq_file *seq_file, void *private) · line 1158
Quoted 12 lines
drivers/nvme/host/fabrics.c +12
-0+const struct match_token *tok; +int idx; + +for (idx =0 ; idx <ARRAY_SIZE (opt_tokens); idx++) { + tok = &opt_tokens[idx]; +if (tok->token ==NVMF_OPT_ERR ) +continue ; +if (idx) +seq_puts (seq_file,"," ); +seq_puts (seq_file, tok->pattern); + } +seq_puts (seq_file,"\n" );
A helper for this logic would be nice. Also shouldn't be there some kind of token to distinguish from the case where a controller has already been created?
Quoted 19 lines · Christoph Hellwig
The subject should use a nvme-fabrics prefix.
drivers/nvme/host/fabrics.c static int nvmf_dev_show(struct seq_file *seq_file, void *private) · line 1158
Quoted 12 lines
drivers/nvme/host/fabrics.c +12
-0+const struct match_token *tok; +int idx; + +for (idx =0 ; idx <ARRAY_SIZE (opt_tokens); idx++) { + tok = &opt_tokens[idx]; +if (tok->token ==NVMF_OPT_ERR ) +continue ; +if (idx) +seq_puts (seq_file,"," ); +seq_puts (seq_file, tok->pattern); + } +seq_puts (seq_file,"\n" );A helper for this logic would be nice. Also shouldn't be there some kind of token to distinguish from the case where a controller has already been created?
Helper: sure.
But we don't need to distinguish the case where the controller has already been created as this is handled by the if condition further up.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Christoph Hellwig
maintainerQuoted 3 lines · Hannes Reinecke
Helper: sure.
But we don't need to distinguish the case where the controller has already been created as this is handled by the if condition further up.
Well, a token that the reader clearly sees that there is no controller yet
Quoted 8 lines · Christoph Hellwig
Quoted 3 lines · Hannes Reinecke
Helper: sure.
But we don't need to distinguish the case where the controller has already been created as this is handled by the if condition further up.Well, a token that the reader clearly sees that there is no controller yet
Ah. That. Sure, can do.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer