Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp804556pxb; Wed, 3 Nov 2021 12:41:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx8udxemkD/mbd+rB03I2sKsXnfMLb2vA1NbWlKUU0UKxdd3PX4N2l535gDFg93GsHfry6 X-Received: by 2002:a17:907:3e0a:: with SMTP id hp10mr26731362ejc.318.1635968474266; Wed, 03 Nov 2021 12:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635968474; cv=none; d=google.com; s=arc-20160816; b=ArE1k6ZF4fF/yTNiWn4PzvrxsjMeeQQ+2szmcFj4mlS1nO8KKwgZMiDWJuE938Pjk4 XO67LFMVZ4Ntx+36Ashc5euifzfiZL9hE4/wMK2CnXqYp+bVp77XriWhhTfc5AzvMNhT g9yDx9NIjQZrVvVlFq32Xjhur/eOpaa816TVjXrBQ88XOladxFXWusKZC74R8e+1M2+O GSIKDvp9dTezzzqLPj/fuPcdY9rRUuEK34WKKcK4WMG+fRClwo6MBd4WOWZIROaIt8TU 6oAT3mt+Ocj24VsJ4+2QFNSSjIGzMMGV2882Br1+EAxCBzB9yhaz4EO3Xdan4bxm3aJ8 d2og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :from; bh=bPtZ5urCGG1Bf0l9RxaKyoUoElkp5/py7sel8jQo8mI=; b=D7hG5QUms8L+46PBTd04hsjAVBhxFgGZnMXbqtluUvWDWoRQ7wWjsyJmJ93UWYhR0k Zj3+NqmjHYGVy3ACPT2UVFBHXOJ16wZWJ0E+Y8rlyjaARL8XQsULVGVrwdaF73J6dOtR H1f3GGnDYUlMEKWdHWW8qQjtXgMzmlKA4I/GJIXPLnqKjeW2WGq5TMKpIPu3cRPK5Kwq /dLROYY2rYSc5mVMAfdDaAcBOUzWOV1UXx9xx0ClMaSz7XSTMWRcyNH6mbXYWjDXCL3F lcXqizfoM/+lN3jdx2fgzu4SKsp/MM7fPNMscWM4Yh9aXegJdzIghmWLNAjkT8/TyyBC F53w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=sA+3LazF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb3si5174199ejc.117.2021.11.03.12.40.50; Wed, 03 Nov 2021 12:41:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@weissschuh.net header.s=mail header.b=sA+3LazF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231343AbhKCTlO (ORCPT + 99 others); Wed, 3 Nov 2021 15:41:14 -0400 Received: from todd.t-8ch.de ([159.69.126.157]:55531 "EHLO todd.t-8ch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230441AbhKCTlH (ORCPT ); Wed, 3 Nov 2021 15:41:07 -0400 From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1635968309; bh=R/4AG9vLH5gheMs6GHXMBsH1IwvhwsPI0SJ8kMELE9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sA+3LazFHbb2drW5DJ9iQnl4eWVgM0XsJF3P5woPPasdkd9cZYA1LHi8WQJ7L0Zog S3DVJ2BXAH4hL3NYr1M10MgAcdnkQs11cuq6iXAOUxwjySWJbS7M+Xi+JLALEPwwME z6xfjt9R4MotGtI/jR1aI4B4VWxSz4nfyBG/0Q1I= To: v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Cc: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Dominique Martinet , Eric Van Hensbergen , Latchesar Ionkov , "David S. Miller" , Jakub Kicinski , Stefano Stabellini , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] net/9p: autoload transport modules Date: Wed, 3 Nov 2021 20:38:20 +0100 Message-Id: <20211103193823.111007-2-linux@weissschuh.net> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211103193823.111007-1-linux@weissschuh.net> References: <20211103193823.111007-1-linux@weissschuh.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Automatically load transport modules based on the trans= parameter passed to mount. This removes the requirement for the user to know which module to use. Signed-off-by: Thomas Weißschuh --- include/net/9p/transport.h | 8 +++++++- net/9p/mod.c | 30 ++++++++++++++++++++++++------ net/9p/trans_rdma.c | 1 + net/9p/trans_virtio.c | 1 + net/9p/trans_xen.c | 1 + 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h index 3eb4261b2958..b9a009534f99 100644 --- a/include/net/9p/transport.h +++ b/include/net/9p/transport.h @@ -11,6 +11,8 @@ #ifndef NET_9P_TRANSPORT_H #define NET_9P_TRANSPORT_H +#include + #define P9_DEF_MIN_RESVPORT (665U) #define P9_DEF_MAX_RESVPORT (1023U) @@ -52,7 +54,11 @@ struct p9_trans_module { void v9fs_register_trans(struct p9_trans_module *m); void v9fs_unregister_trans(struct p9_trans_module *m); -struct p9_trans_module *v9fs_get_trans_by_name(char *s); +struct p9_trans_module *v9fs_get_trans_by_name(const char *s); struct p9_trans_module *v9fs_get_default_trans(void); void v9fs_put_trans(struct p9_trans_module *m); + +#define MODULE_ALIAS_9P(transport) \ + MODULE_ALIAS("9p-" transport) + #endif /* NET_9P_TRANSPORT_H */ diff --git a/net/9p/mod.c b/net/9p/mod.c index 5126566850bd..c95416c1d1a2 100644 --- a/net/9p/mod.c +++ b/net/9p/mod.c @@ -12,6 +12,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include #include #include @@ -87,12 +88,7 @@ void v9fs_unregister_trans(struct p9_trans_module *m) } EXPORT_SYMBOL(v9fs_unregister_trans); -/** - * v9fs_get_trans_by_name - get transport with the matching name - * @s: string identifying transport - * - */ -struct p9_trans_module *v9fs_get_trans_by_name(char *s) +static struct p9_trans_module *_p9_get_trans_by_name(const char *s) { struct p9_trans_module *t, *found = NULL; @@ -106,6 +102,28 @@ struct p9_trans_module *v9fs_get_trans_by_name(char *s) } spin_unlock(&v9fs_trans_lock); + + return found; +} + +/** + * v9fs_get_trans_by_name - get transport with the matching name + * @s: string identifying transport + * + */ +struct p9_trans_module *v9fs_get_trans_by_name(const char *s) +{ + struct p9_trans_module *found = NULL; + + found = _p9_get_trans_by_name(s); + +#ifdef CONFIG_MODULES + if (!found) { + request_module("9p-%s", s); + found = _p9_get_trans_by_name(s); + } +#endif + return found; } EXPORT_SYMBOL(v9fs_get_trans_by_name); diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index af0a8a6cd3fd..480fd27760d7 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c @@ -767,6 +767,7 @@ static void __exit p9_trans_rdma_exit(void) module_init(p9_trans_rdma_init); module_exit(p9_trans_rdma_exit); +MODULE_ALIAS_9P("rdma"); MODULE_AUTHOR("Tom Tucker "); MODULE_DESCRIPTION("RDMA Transport for 9P"); diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 490a4c900339..bd5a89c4960d 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -794,6 +794,7 @@ static void __exit p9_virtio_cleanup(void) module_init(p9_virtio_init); module_exit(p9_virtio_cleanup); +MODULE_ALIAS_9P("virtio"); MODULE_DEVICE_TABLE(virtio, id_table); MODULE_AUTHOR("Eric Van Hensbergen "); diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c index 3ec1a51a6944..e264dcee019a 100644 --- a/net/9p/trans_xen.c +++ b/net/9p/trans_xen.c @@ -552,6 +552,7 @@ static int p9_trans_xen_init(void) return rc; } module_init(p9_trans_xen_init); +MODULE_ALIAS_9P("xen"); static void p9_trans_xen_exit(void) { -- 2.33.1