SUNRPC: pipefs virtualization
Subsystems (4)
cover SUNRPC: pipefs virtualization
This patch set is a part of further RPC layer virtualization and it's aim is to make RPC pipefs mount creation and destruction per network namespace context. It moves RPC pipefs internal data to sunrpc_net instance of network namespace context.
With this patch set all calls to pipefs infrastructure are performed with "&init_net" except rpc_new_client() and rpc_setup_pipedir() functions (but they still passes pointer to "init_net" by current design).
This "init_net" pointer will be replaced later with NFS virtualization.
The following series consists of:
---
Stanislav Kinsbursky (2):
SUNRPC: make rpc pipefs mount per network namespace
SUNRPC: RPC pipefs virtualization
fs/nfs/blocklayout/blocklayout.c | 2 +- fs/nfs/cache_lib.c | 7 ++++--- include/linux/sunrpc/rpc_pipe_fs.h | 4 ++-- net/sunrpc/clnt.c | 8 ++++---- net/sunrpc/netns.h | 3 +++ net/sunrpc/rpc_pipe.c | 23 +++++++++++++++-------- 6 files changed, 29 insertions(+), 18 deletions(-)
Signature · 1 line
Signature
PATCH 1/2 SUNRPC: make rpc pipefs mount per network namespace
This is another part of RPC layer virtualization.
RPC pipefs inner data was attached to per-net sunrpc_net instance. Network namespace counter is increased and decreased with every RPC mount reference. This is not hardly requred from my pow, but it looks safer since we relay on network namespace presence.
--- include/linux/sunrpc/rpc_pipe_fs.h | 4 ++-- net/sunrpc/netns.h | 3 +++ net/sunrpc/rpc_pipe.c | 23 +++++++++++++++-------- 3 files changed, 20 insertions(+), 10 deletions(-)
include/linux/sunrpc/rpc_pipe_fs.h +2 -2
@@ -60,8 +60,8 @@ extern void rpc_remove_cache_dir(struct dentry *);extern struct dentry *rpc_mkpipe (struct dentry *,const char *,void *,const struct rpc_pipe_ops *,int flags);extern int rpc_unlink (struct dentry *); -extern struct vfsmount *rpc_get_mount (void ); -extern void rpc_put_mount (void ); +extern struct vfsmount *rpc_get_mount (struct net *net); +extern void rpc_put_mount (struct net *net);extern int register_rpc_pipefs (void );extern void unregister_rpc_pipefs (void );
net/sunrpc/netns.h +3 -0
@@ -9,6 +9,9 @@ struct cache_detail;struct sunrpc_net {struct proc_dir_entry *proc_net_rpc;struct cache_detail *ip_map_cache; + +struct vfsmount *rpc_mnt; +int rpc_mount_count; };extern int sunrpc_net_id;
net/sunrpc/rpc_pipe.c +15 -8
@@ -28,8 +28,7 @@#include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/cache.h> -static struct vfsmount *rpc_mnt__read_mostly ; -static int rpc_mount_count; +#include "netns.h" static struct file_system_type rpc_pipe_fs_type;
@@ -421,20 +420,28 @@ struct rpc_filelist {umode_t mode; }; -struct vfsmount *rpc_get_mount (void ) +struct vfsmount *rpc_get_mount (struct net *net) {int err; +struct sunrpc_net *sn; - err =simple_pin_fs (&rpc_pipe_fs_type, &rpc_mnt, &rpc_mount_count); -if (err !=0 ) + sn =net_generic (get_net (net), sunrpc_net_id); + err =simple_pin_fs (&rpc_pipe_fs_type, &sn->rpc_mnt, &sn->rpc_mount_count); +if (err !=0 ) { +put_net (net);return ERR_PTR (err); -return rpc_mnt; + } +return sn->rpc_mnt; }EXPORT_SYMBOL_GPL (rpc_get_mount); -void rpc_put_mount (void ) +void rpc_put_mount (struct net *net) { -simple_release_fs (&rpc_mnt, &rpc_mount_count); +struct sunrpc_net *sn; + + sn =net_generic (net, sunrpc_net_id); +simple_release_fs (&sn->rpc_mnt, &sn->rpc_mount_count); +put_net (net); }EXPORT_SYMBOL_GPL (rpc_put_mount);
PATCH 2/2 SUNRPC: RPC pipefs virtualization
In reply to Stanislav KinsburskyParametrize rpc_mount_get() and rpc_mount_put() with network namespace pointer. Currently init_net is used, but later proper network context will be used instead.
It actually means, that in future NFS cache have to be virtualied as well.
--- fs/nfs/blocklayout/blocklayout.c | 2 +- fs/nfs/cache_lib.c | 7 ++++--- net/sunrpc/clnt.c | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-)
fs/nfs/blocklayout/blocklayout.c +1 -1
@@ -979,7 +979,7 @@ static int __init nfs4blocklayout_init(void)init_waitqueue_head (&bl_wq); - mnt =rpc_get_mount (); + mnt =rpc_get_mount (&init_net);if (IS_ERR (mnt)) { ret =PTR_ERR (mnt); goto out_remove;
fs/nfs/cache_lib.c +4 -3
@@ -11,6 +11,7 @@#include <linux/mount.h> #include <linux/namei.h> #include <linux/slab.h> +#include <net/net_namespace.h> #include <linux/sunrpc/cache.h> #include <linux/sunrpc/rpc_pipe_fs.h>
@@ -117,7 +118,7 @@ int nfs_cache_register(struct cache_detail *cd)struct path path;int ret; - mnt =rpc_get_mount (); + mnt =rpc_get_mount (&init_net);if (IS_ERR (mnt))return PTR_ERR (mnt); ret =vfs_path_lookup (mnt->mnt_root, mnt,"/cache" ,0 , &path);
@@ -128,13 +129,13 @@ int nfs_cache_register(struct cache_detail *cd)if (!ret)return ret; err: -rpc_put_mount (); +rpc_put_mount (&init_net);return ret; }void nfs_cache_unregister (struct cache_detail *cd) {sunrpc_cache_unregister_pipefs (cd); -rpc_put_mount (); +rpc_put_mount (&init_net); }
net/sunrpc/clnt.c +4 -4
@@ -109,7 +109,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name)if (dir_name ==NULL )return 0 ; - path.mnt =rpc_get_mount (); + path.mnt =rpc_get_mount (clnt->cl_xprt->xprt_net);if (IS_ERR (path.mnt))return PTR_ERR (path.mnt); error =vfs_path_lookup (path.mnt->mnt_root, path.mnt, dir_name,0 , &dir);
@@ -137,7 +137,7 @@ rpc_setup_pipedir(struct rpc_clnt *clnt, char *dir_name) err_path_put:path_put (&dir); err: -rpc_put_mount (); +rpc_put_mount (clnt->cl_xprt->xprt_net);return error; }
@@ -248,7 +248,7 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru out_no_auth:if (!IS_ERR (clnt->cl_path.dentry)) {rpc_remove_client_dir (clnt->cl_path.dentry); -rpc_put_mount (); +rpc_put_mount (clnt->cl_xprt->xprt_net); } out_no_path:kfree (clnt->cl_principal);
@@ -476,7 +476,7 @@ rpc_free_client(struct rpc_clnt *clnt) clnt->cl_protname, clnt->cl_server);if (!IS_ERR (clnt->cl_path.dentry)) {rpc_remove_client_dir (clnt->cl_path.dentry); -rpc_put_mount (); +rpc_put_mount (clnt->cl_xprt->xprt_net); }if (clnt->cl_parent != clnt) {rpc_release_client (clnt->cl_parent);
Probably, holding mount point of network namespace is not a good solution. There is another one. But I really hope for discussion of it.
RPC pipefs can be virtualized in the way like sysfs done.
But the main problem here is that currently we have only one RPC pipefs mount point (superblock, root) for all.
New mount point can be created per every pipefs mount call. We can even have some shared privates on dentries with the same name, like sysfs does (but I don't see any good reason for this). But with many mount points we have a problem with RPC pipes creation. I.e. we have to find proper mount point for current network namespace, which is required for vfs_path_lookup(), which is done prior to pipe creation. And thus we have to store this per-netns mount points somewhere. It could be some static variable. But we have to implement search function for them.
This approach can hide all pipefs virtualization from it's users. But it's still look ugly from my pow.
Maybe, somebody have suggest better solution for this problem?
12.09.2011 18:19, Stanislav Kinsbursky пишет:
Quoted 26 lines
This patch set is a part of further RPC layer virtualization and it's aim is to make RPC pipefs mount creation and destruction per network namespace context. It moves RPC pipefs internal data to
sunrpc_netinstance of network namespace context.
With this patch set all calls to pipefs infrastructure are performed with "&init_net" exceptrpc_new_client()andrpc_setup_pipedir()functions (but they still passes pointer to "init_net" by current design).
This "init_net" pointer will be replaced later with NFS virtualization.The following series consists of:
---
Stanislav Kinsbursky (2):
SUNRPC: make rpc pipefs mount per network namespace
SUNRPC: RPC pipefs virtualizationfs/nfs/blocklayout/blocklayout.c | 2 +- fs/nfs/cache_lib.c | 7 ++++--- include/linux/sunrpc/rpc_pipe_fs.h | 4 ++-- net/sunrpc/clnt.c | 8 ++++---- net/sunrpc/netns.h | 3 +++ net/sunrpc/rpc_pipe.c | 23 +++++++++++++++-------- 6 files changed, 29 insertions(+), 18 deletions(-)
Signature · 6 lines
Best regards, Stanislav Kinsbursky -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html