diff mbox series

[v2,4/4] net/p9: load default transports

Message ID 20211103193823.111007-5-linux@weissschuh.net (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series net/9p: optimize transport module loading | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Thomas Weißschuh Nov. 3, 2021, 7:38 p.m. UTC
Now that all transports are split into modules it may happen that no
transports are registered when v9fs_get_default_trans() is called.
When that is the case try to load more transports from modules.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
 net/9p/mod.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Thomas Weißschuh Nov. 8, 2021, 6:50 p.m. UTC | #1
Hi Dominique,

On 2021-11-03 20:38+0100, Thomas Weißschuh wrote:
> Now that all transports are split into modules it may happen that no
> transports are registered when v9fs_get_default_trans() is called.
> When that is the case try to load more transports from modules.
> 
> Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
> ---
>  net/9p/mod.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/net/9p/mod.c b/net/9p/mod.c
> index 8f1d067b272e..7bb875cd279f 100644
> --- a/net/9p/mod.c
> +++ b/net/9p/mod.c
> @@ -128,6 +128,10 @@ struct p9_trans_module *v9fs_get_trans_by_name(const char *s)
>  }
>  EXPORT_SYMBOL(v9fs_get_trans_by_name);
>  
> +static const char * const v9fs_default_transports[] = {
> +	"virtio", "tcp", "fd", "unix", "xen", "rdma",
> +};
> +
>  /**
>   * v9fs_get_default_trans - get the default transport
>   *
> @@ -136,6 +140,7 @@ EXPORT_SYMBOL(v9fs_get_trans_by_name);
>  struct p9_trans_module *v9fs_get_default_trans(void)
>  {
>  	struct p9_trans_module *t, *found = NULL;
> +	int i;
>  
>  	spin_lock(&v9fs_trans_lock);
>  
> @@ -153,6 +158,10 @@ struct p9_trans_module *v9fs_get_default_trans(void)
>  			}
>  
>  	spin_unlock(&v9fs_trans_lock);
> +
> +	for (i = 0; !found && i < ARRAY_SIZE(v9fs_default_transports); i++)
> +		found = v9fs_get_trans_by_name(v9fs_default_transports[i]);
> +
>  	return found;
>  }
>  EXPORT_SYMBOL(v9fs_get_default_trans);
> -- 
> 2.33.1

I did not notice that you already had applied "net/9p: autoload transport modules"
to your tree when sending this series.

Please note that in this series I modified patch 1 a bit, from the ony you
applied, to prevent warnings in patch 4.
Concretely I modified the prototypes of `v9fs_get_trans_by_name()` and
`_p9_get_trans_by_name()` to take const parameters.

Feel free to roll those changes into this patch when applying or I can resend
the patch/series.

Thomas
Dominique Martinet Nov. 8, 2021, 10:31 p.m. UTC | #2
Hi,

Thomas Weißschuh wrote on Mon, Nov 08, 2021 at 07:50:34PM +0100:
> I did not notice that you already had applied "net/9p: autoload transport modules"
> to your tree when sending this series.
> 
> Please note that in this series I modified patch 1 a bit, from the ony you
> applied, to prevent warnings in patch 4.
> Concretely I modified the prototypes of `v9fs_get_trans_by_name()` and
> `_p9_get_trans_by_name()` to take const parameters.
> 
> Feel free to roll those changes into this patch when applying or I can resend
> the patch/series.

Thanks for the heads up, it's ok -- I'll move the constification of
these functions to patch 4 myself.

I've just sent my pull request to Linus so will take your patches to
my for-next branch when that's merged.
diff mbox series

Patch

diff --git a/net/9p/mod.c b/net/9p/mod.c
index 8f1d067b272e..7bb875cd279f 100644
--- a/net/9p/mod.c
+++ b/net/9p/mod.c
@@ -128,6 +128,10 @@  struct p9_trans_module *v9fs_get_trans_by_name(const char *s)
 }
 EXPORT_SYMBOL(v9fs_get_trans_by_name);
 
+static const char * const v9fs_default_transports[] = {
+	"virtio", "tcp", "fd", "unix", "xen", "rdma",
+};
+
 /**
  * v9fs_get_default_trans - get the default transport
  *
@@ -136,6 +140,7 @@  EXPORT_SYMBOL(v9fs_get_trans_by_name);
 struct p9_trans_module *v9fs_get_default_trans(void)
 {
 	struct p9_trans_module *t, *found = NULL;
+	int i;
 
 	spin_lock(&v9fs_trans_lock);
 
@@ -153,6 +158,10 @@  struct p9_trans_module *v9fs_get_default_trans(void)
 			}
 
 	spin_unlock(&v9fs_trans_lock);
+
+	for (i = 0; !found && i < ARRAY_SIZE(v9fs_default_transports); i++)
+		found = v9fs_get_trans_by_name(v9fs_default_transports[i]);
+
 	return found;
 }
 EXPORT_SYMBOL(v9fs_get_default_trans);