sunrpc: Virtualize ip_map_cache
Subsystems (3)
v2 cover sunrpc: Virtualize ip_map_cache
Hello everyone!
This is the set I sent previously re-based on thegit://linux-nfs.org/~bfields/linux.git nfsd-next branch and with fixed comment from Bruce.
Please, consider it for inclusion.
Thanks,
Pavel
PATCH v2 1/9 sunrpc: Pass the ip_map_parse's cd to lower calls
The target is to have many ip_map_cache-s in the system. This particular patch handles its usage by the ip_map_parse callback.
--- net/sunrpc/svcauth_unix.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-)
net/sunrpc/svcauth_unix.c +21 -10
@@ -178,8 +178,8 @@ static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h)return sunrpc_cache_pipe_upcall (cd, h, ip_map_request); } -static struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr); -static int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry); +static struct ip_map *__ip_map_lookup (struct cache_detail *cd,char *class,struct in6_addr *addr); +static int __ip_map_update (struct cache_detail *cd,struct ip_map *ipm,struct unix_domain *udom,time_t expiry);static int ip_map_parse (struct cache_detail *cd,char *mesg,int mlen)
@@ -249,9 +249,9 @@ static int ip_map_parse(struct cache_detail *cd, dom =NULL ;/* IPv6 scope IDs are ignored for now */ - ipmp =ip_map_lookup (class, &sin6.sin6_addr); + ipmp =__ip_map_lookup (cd, class, &sin6.sin6_addr);if (ipmp) { - err =ip_map_update (ipmp, + err =__ip_map_update (cd, ipmp, container_of(dom, struct unix_domain, h), expiry); }else
@@ -309,14 +309,15 @@ struct cache_detail ip_map_cache = { .alloc = ip_map_alloc, }; -static struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr) +static struct ip_map *__ip_map_lookup (struct cache_detail *cd,char *class, +struct in6_addr *addr) {struct ip_map ip;struct cache_head *ch;strcpy (ip.m_class, class);ipv6_addr_copy (&ip.m_addr, addr); - ch =sunrpc_cache_lookup (&ip_map_cache, &ip.h, + ch =sunrpc_cache_lookup (cd, &ip.h,hash_str (class,IP_HASHBITS ) ^hash_ip6 (*addr));
@@ -326,7 +327,13 @@ static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr)return NULL ; } -static int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry) +static inline struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr) +{ +return __ip_map_lookup (&ip_map_cache, class, addr); +} + +static int __ip_map_update (struct cache_detail *cd,struct ip_map *ipm, +struct unix_domain *udom,time_t expiry) {struct ip_map ip;struct cache_head *ch;
@@ -344,16 +351,20 @@ static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t ex ip.m_add_change++; } ip.h.expiry_time = expiry; - ch =sunrpc_cache_update (&ip_map_cache, - &ip.h, &ipm->h, + ch =sunrpc_cache_update (cd, &ip.h, &ipm->h,hash_str (ipm->m_class,IP_HASHBITS ) ^hash_ip6 (ipm->m_addr));if (!ch)return -ENOMEM ; -cache_put (ch, &ip_map_cache); +cache_put (ch, cd);return 0 ; } +static inline int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry) +{ +return __ip_map_update (&ip_map_cache, ipm, udom, expiry); +} +int auth_unix_add_addr (struct in6_addr *addr,struct auth_domain *dom) {struct unix_domain *udom;
Signature · 1 line
1.5.5.6
PATCH v2 2/9 sunrpc: Make xprt auth cache release work with the xprt
In reply to Pavel EmelyanovThis is done in order to facilitate getting the ip_map_cache from which to put the ip_map.
--- include/linux/sunrpc/svcauth.h | 3 ++- net/sunrpc/svc_xprt.c | 5 ++--- net/sunrpc/svcauth_unix.c | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-)
include/linux/sunrpc/svcauth.h +2 -1
@@ -116,6 +116,7 @@ struct auth_ops {#define SVC_PENDING 9#define SVC_COMPLETE 10 +struct svc_xprt ;extern int svc_authenticate (struct svc_rqst *rqstp,__be32 *authp);extern int svc_authorise (struct svc_rqst *rqstp);
@@ -131,7 +132,7 @@ extern struct auth_domain *auth_domain_find(char *name);extern struct auth_domain *auth_unix_lookup (struct in6_addr *addr);extern int auth_unix_forget_old (struct auth_domain *dom);extern void svcauth_unix_purge (void ); -extern void svcauth_unix_info_release (void *); +extern void svcauth_unix_info_release (struct svc_xprt *xpt);extern int svcauth_unix_set_client (struct svc_rqst *rqstp);static inline unsigned long hash_str (char *name,int bits)
net/sunrpc/svc_xprt.c +2 -3
@@ -128,9 +128,8 @@ static void svc_xprt_free(struct kref *kref)struct svc_xprt *xprt = container_of(kref, struct svc_xprt, xpt_ref);struct module *owner = xprt->xpt_class->xcl_owner; -if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags) && - xprt->xpt_auth_cache !=NULL ) -svcauth_unix_info_release (xprt->xpt_auth_cache); +if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags)) +svcauth_unix_info_release (xprt); xprt->xpt_ops->xpo_free (xprt);module_put (owner); }
net/sunrpc/svcauth_unix.c +6 -3
@@ -472,10 +472,13 @@ ip_map_cached_put(struct svc_rqst *rqstp, struct ip_map *ipm) }void -svcauth_unix_info_release (void *info) +svcauth_unix_info_release (struct svc_xprt *xpt) { -struct ip_map *ipm = info; -cache_put (&ipm->h, &ip_map_cache); +struct ip_map *ipm; + + ipm = xpt->xpt_auth_cache; +if (ipm !=NULL ) +cache_put (&ipm->h, &ip_map_cache); }/****************************************************************************
Signature · 1 line
1.5.5.6
PATCH v2 3/9 sunrpc: Pass xprt to cached get/put routines
In reply to Pavel EmelyanovThey do not require the rqst actually and having the xprt simplifies further patching.
--- net/sunrpc/svcauth_unix.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
net/sunrpc/svcauth_unix.c +5 -7
@@ -426,10 +426,9 @@ void svcauth_unix_purge(void)EXPORT_SYMBOL_GPL (svcauth_unix_purge);static inline struct ip_map * -ip_map_cached_get (struct svc_rqst *rqstp) +ip_map_cached_get (struct svc_xprt *xprt) {struct ip_map *ipm =NULL ; -struct svc_xprt *xprt = rqstp->rq_xprt;if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags)) {spin_lock (&xprt->xpt_lock);
@@ -454,10 +453,8 @@ ip_map_cached_get(struct svc_rqst *rqstp) }static inline void -ip_map_cached_put (struct svc_rqst *rqstp,struct ip_map *ipm) +ip_map_cached_put (struct svc_xprt *xprt,struct ip_map *ipm) { -struct svc_xprt *xprt = rqstp->rq_xprt; -if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags)) {spin_lock (&xprt->xpt_lock);if (xprt->xpt_auth_cache ==NULL ) {
@@ -707,6 +704,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)struct ip_map *ipm;struct group_info *gi;struct svc_cred *cred = &rqstp->rq_cred; +struct svc_xprt *xprt = rqstp->rq_xprt;switch (rqstp->rq_addr.ss_family) {case AF_INET :
@@ -725,7 +723,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)if (rqstp->rq_proc ==0 )return SVC_OK ; - ipm =ip_map_cached_get (rqstp); + ipm =ip_map_cached_get (xprt);if (ipm ==NULL ) ipm =ip_map_lookup (rqstp->rq_server->sv_program->pg_class, &sin6->sin6_addr);
@@ -745,7 +743,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)case 0 : rqstp->rq_client = &ipm->m_client->h;kref_get (&rqstp->rq_client->ref); -ip_map_cached_put (rqstp, ipm); +ip_map_cached_put (xprt, ipm);break ; }
Signature · 1 line
1.5.5.6
PATCH v2 4/9 sunrpc: Add net to pure API calls
In reply to Pavel EmelyanovThere are two calls that operate on ip_map_cache and are directly called from the nfsd code. Other places will be handled in a different way.
--- fs/nfsd/export.c | 2 +- fs/nfsd/nfsctl.c | 4 ++-- include/linux/sunrpc/svcauth.h | 4 ++-- net/sunrpc/svcauth_unix.c | 18 ++++++++++-------- 4 files changed, 15 insertions(+), 13 deletions(-)
fs/nfsd/export.c +1 -1
@@ -1575,7 +1575,7 @@ exp_addclient(struct nfsctl_client *ncp)/* Insert client into hashtable. */ for (i =0 ; i < ncp->cl_naddr; i++) {ipv6_addr_set_v4mapped (ncp->cl_addrlist[i].s_addr, &addr6); -auth_unix_add_addr (&addr6, dom); +auth_unix_add_addr (&init_net, &addr6, dom); }auth_unix_forget_old (dom);auth_domain_put (dom);
fs/nfsd/nfsctl.c +2 -2
@@ -416,7 +416,7 @@ static ssize_t write_getfs(struct file *file, char *buf, size_t size)ipv6_addr_set_v4mapped (sin->sin_addr.s_addr, &in6); - clp =auth_unix_lookup (&in6); + clp =auth_unix_lookup (&init_net, &in6);if (!clp) err = -EPERM ;else {
@@ -479,7 +479,7 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size)ipv6_addr_set_v4mapped (sin->sin_addr.s_addr, &in6); - clp =auth_unix_lookup (&in6); + clp =auth_unix_lookup (&init_net, &in6);if (!clp) err = -EPERM ;else {
include/linux/sunrpc/svcauth.h +2 -2
@@ -126,10 +126,10 @@ extern void svc_auth_unregister(rpc_authflavor_t flavor);extern struct auth_domain *unix_domain_find (char *name);extern void auth_domain_put (struct auth_domain *item); -extern int auth_unix_add_addr (struct in6_addr *addr,struct auth_domain *dom); +extern int auth_unix_add_addr (struct net *net,struct in6_addr *addr,struct auth_domain *dom);extern struct auth_domain *auth_domain_lookup (char *name,struct auth_domain *new);extern struct auth_domain *auth_domain_find (char *name); -extern struct auth_domain *auth_unix_lookup (struct in6_addr *addr); +extern struct auth_domain *auth_unix_lookup (struct net *net,struct in6_addr *addr);extern int auth_unix_forget_old (struct auth_domain *dom);extern void svcauth_unix_purge (void );extern void svcauth_unix_info_release (struct svc_xprt *xpt);
net/sunrpc/svcauth_unix.c +10 -8
@@ -327,7 +327,8 @@ static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class,return NULL ; } -static inline struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr) +static inline struct ip_map *ip_map_lookup (struct net *net,char *class, +struct in6_addr *addr) {return __ip_map_lookup (&ip_map_cache, class, addr); }
@@ -360,12 +361,13 @@ static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm,return 0 ; } -static inline int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry) +static inline int ip_map_update (struct net *net,struct ip_map *ipm, +struct unix_domain *udom,time_t expiry) {return __ip_map_update (&ip_map_cache, ipm, udom, expiry); } -int auth_unix_add_addr (struct in6_addr *addr,struct auth_domain *dom) +int auth_unix_add_addr (struct net *net,struct in6_addr *addr,struct auth_domain *dom) {struct unix_domain *udom;struct ip_map *ipmp;
@@ -373,10 +375,10 @@ int auth_unix_add_addr(struct in6_addr *addr, struct auth_domain *dom)if (dom->flavour != &svcauth_unix)return -EINVAL ; udom = container_of(dom, struct unix_domain, h); - ipmp =ip_map_lookup ("nfsd" , addr); + ipmp =ip_map_lookup (net,"nfsd" , addr);if (ipmp) -return ip_map_update (ipmp, udom,NEVER ); +return ip_map_update (net, ipmp, udom,NEVER );else return -ENOMEM ; }
@@ -394,12 +396,12 @@ int auth_unix_forget_old(struct auth_domain *dom) }EXPORT_SYMBOL_GPL (auth_unix_forget_old); -struct auth_domain *auth_unix_lookup (struct in6_addr *addr) +struct auth_domain *auth_unix_lookup (struct net *net,struct in6_addr *addr) {struct ip_map *ipm;struct auth_domain *rv; - ipm =ip_map_lookup ("nfsd" , addr); + ipm =ip_map_lookup (net,"nfsd" , addr);if (!ipm)return NULL ;
@@ -725,7 +727,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) ipm =ip_map_cached_get (xprt);if (ipm ==NULL ) - ipm =ip_map_lookup (rqstp->rq_server->sv_program->pg_class, + ipm =ip_map_lookup (&init_net, rqstp->rq_server->sv_program->pg_class, &sin6->sin6_addr);if (ipm ==NULL )
Signature · 1 line
1.5.5.6
PATCH v2 5/9 sunrpc: Add routines that allow registering per-net caches
In reply to Pavel EmelyanovExisting calls do the same, but for the init_net.
--- include/linux/sunrpc/cache.h | 2 ++ net/sunrpc/cache.c | 27 +++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-)
include/linux/sunrpc/cache.h +2 -0
@@ -197,7 +197,9 @@ extern void cache_purge(struct cache_detail *detail);#define NEVER (0x7FFFFFFF)extern void __init cache_initialize (void );extern int cache_register (struct cache_detail *cd); +extern int cache_register_net (struct cache_detail *cd,struct net *net);extern void cache_unregister (struct cache_detail *cd); +extern void cache_unregister_net (struct cache_detail *cd,struct net *net);extern int sunrpc_cache_register_pipefs (struct dentry *parent,const char *,mode_t ,struct cache_detail *);
net/sunrpc/cache.c +19 -8
@@ -34,6 +34,7 @@#include <linux/sunrpc/cache.h> #include <linux/sunrpc/stats.h> #include <linux/sunrpc/rpc_pipe_fs.h> +#include <net/net_namespace.h> #define RPCDBG_FACILITY RPCDBG_CACHE
@@ -1537,7 +1538,7 @@ static const struct file_operations cache_flush_operations_procfs = { .release = release_flush_procfs, }; -static void remove_cache_proc_entries (struct cache_detail *cd) +static void remove_cache_proc_entries (struct cache_detail *cd,struct net *net) {if (cd->u.procfs.proc_ent ==NULL )return ;
@@ -1552,7 +1553,7 @@ static void remove_cache_proc_entries(struct cache_detail *cd) }#ifdef CONFIG_PROC_FS -static int create_cache_proc_entries (struct cache_detail *cd) +static int create_cache_proc_entries (struct cache_detail *cd,struct net *net) {struct proc_dir_entry *p;
@@ -1587,11 +1588,11 @@ static int create_cache_proc_entries(struct cache_detail *cd) }return 0 ; out_nomem: -remove_cache_proc_entries (cd); +remove_cache_proc_entries (cd, net);return -ENOMEM ; }#else /* CONFIG_PROC_FS */ -static int create_cache_proc_entries (struct cache_detail *cd) +static int create_cache_proc_entries (struct cache_detail *cd,struct net *net) {return 0 ; }
@@ -1602,23 +1603,33 @@ void __init cache_initialize(void)INIT_DELAYED_WORK_DEFERRABLE (&cache_cleaner, do_cache_clean); } -int cache_register (struct cache_detail *cd) +int cache_register_net (struct cache_detail *cd,struct net *net) {int ret;sunrpc_init_cache_detail (cd); - ret =create_cache_proc_entries (cd); + ret =create_cache_proc_entries (cd, net);if (ret)sunrpc_destroy_cache_detail (cd);return ret; } + +int cache_register (struct cache_detail *cd) +{ +return cache_register_net (cd, &init_net); +}EXPORT_SYMBOL_GPL (cache_register); -void cache_unregister (struct cache_detail *cd) +void cache_unregister_net (struct cache_detail *cd,struct net *net) { -remove_cache_proc_entries (cd); +remove_cache_proc_entries (cd, net);sunrpc_destroy_cache_detail (cd); } + +void cache_unregister (struct cache_detail *cd) +{ +cache_unregister_net (cd, &init_net); +}EXPORT_SYMBOL_GPL (cache_unregister); static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
Signature · 1 line
1.5.5.6
PATCH v2 6/9 sunrpc: Tag svc_xprt with net
In reply to Pavel EmelyanovThe transport representation should be per-net of course.
--- include/linux/sunrpc/svc_xprt.h | 2 ++ net/sunrpc/svc_xprt.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
include/linux/sunrpc/svc_xprt.h +2 -0
@@ -66,6 +66,8 @@ struct svc_xprt {struct sockaddr_storage xpt_remote;/* remote peer's address */ size_t xpt_remotelen;/* length of address */ struct rpc_wait_queue xpt_bc_pending;/* backchannel wait queue */ + +struct net *xpt_net; };int svc_reg_xprt_class (struct svc_xprt_class *);
net/sunrpc/svc_xprt.c +2 -0
@@ -130,6 +130,7 @@ static void svc_xprt_free(struct kref *kref)struct module *owner = xprt->xpt_class->xcl_owner;if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags))svcauth_unix_info_release (xprt); +put_net (xprt->xpt_net); xprt->xpt_ops->xpo_free (xprt);module_put (owner); }
@@ -159,6 +160,7 @@ void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xprt,spin_lock_init (&xprt->xpt_lock);set_bit (XPT_BUSY , &xprt->xpt_flags);rpc_init_wait_queue (&xprt->xpt_bc_pending,"xpt_bc_pending" ); + xprt->xpt_net =get_net (&init_net); }EXPORT_SYMBOL_GPL (svc_xprt_init);
Signature · 1 line
1.5.5.6
PATCH v2 7/9 sunrpc: The per-net skeleton
In reply to Pavel EmelyanovRegister empty per-net operations for the sunrpc layer.
--- net/sunrpc/netns.h | 12 ++++++++++++ net/sunrpc/sunrpc_syms.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletions(-) create mode 100644 net/sunrpc/netns.h
net/sunrpc/netns.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __SUNRPC_NETNS_H__ +#define __SUNRPC_NETNS_H__ + +#include <net/net_namespace.h> +#include <net/netns/generic.h> + +struct sunrpc_net { +}; + +extern int sunrpc_net_id; + +#endif
net/sunrpc/sunrpc_syms.c +30 -1
@@ -22,6 +22,26 @@#include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/xprtsock.h> +#include "netns.h" + +int sunrpc_net_id; + +static __net_init int sunrpc_init_net (struct net *net) +{ +return 0 ; +} + +static __net_exit void sunrpc_exit_net(struct net *net) +{ +} + +static struct pernet_operations sunrpc_net_ops = { + .init = sunrpc_init_net, + .exit = sunrpc_exit_net, + .id = &sunrpc_net_id, + .size =sizeof (struct sunrpc_net ), +}; +extern struct cache_detail ip_map_cache, unix_gid_cache;extern void cleanup_rpcb_clnt (void );
@@ -38,18 +58,26 @@ init_sunrpc(void) err =rpcauth_init_module ();if (err) goto out3; + +cache_initialize (); + + err =register_pernet_subsys (&sunrpc_net_ops); +if (err) + goto out4;#ifdef RPC_DEBUG rpc_register_sysctl ();#endif #ifdef CONFIG_PROC_FS rpc_proc_init ();#endif -cache_initialize ();cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */ init_socket_xprt ();/* clnt sock transport */ return 0 ; + +out4: +rpcauth_remove_module (); out3:rpc_destroy_mempool (); out2:
@@ -69,6 +97,7 @@ cleanup_sunrpc(void)rpc_destroy_mempool ();cache_unregister (&ip_map_cache);cache_unregister (&unix_gid_cache); +unregister_pernet_subsys (&sunrpc_net_ops);#ifdef RPC_DEBUG rpc_unregister_sysctl ();#endif
Signature · 1 line
1.5.5.6
PATCH v2 8/9 sunrpc: Make the /proc/net/rpc appear in net namespaces
In reply to Pavel Emelyanov--- include/linux/sunrpc/stats.h | 23 ++++++++++++++------- net/sunrpc/cache.c | 11 +++++++-- net/sunrpc/netns.h | 1 + net/sunrpc/stats.c | 43 ++++++++++++++++++++++++----------------- net/sunrpc/sunrpc_syms.c | 16 +++++++++----- 5 files changed, 59 insertions(+), 35 deletions(-)
include/linux/sunrpc/stats.h +15 -8
@@ -38,8 +38,21 @@ struct svc_stat { rpcbadclnt; }; -void rpc_proc_init (void ); -void rpc_proc_exit (void ); +struct net ; +#ifdef CONFIG_PROC_FS +int rpc_proc_init (struct net *); +void rpc_proc_exit (struct net *); +#else +static inline int rpc_proc_init (struct net *net) +{ +return 0 ; +} + +static inline void rpc_proc_exit (struct net *net) +{ +} +#endif +#ifdef MODULE void rpc_modcount (struct inode *,int );#endif
@@ -54,9 +67,6 @@ void svc_proc_unregister(const char *);void svc_seq_show (struct seq_file *,const struct svc_stat *); - -extern struct proc_dir_entry *proc_net_rpc; -#else static inline struct proc_dir_entry *rpc_proc_register (struct rpc_stat *s) {return NULL ; }
@@ -69,9 +79,6 @@ static inline void svc_proc_unregister(const char *p) {}static inline void svc_seq_show (struct seq_file *seq,const struct svc_stat *st) {} - -#define proc_net_rpc NULL -#endif #endif /* _LINUX_SUNRPC_STATS_H */
net/sunrpc/cache.c +8 -3
@@ -34,7 +34,7 @@#include <linux/sunrpc/cache.h> #include <linux/sunrpc/stats.h> #include <linux/sunrpc/rpc_pipe_fs.h> -#include <net/net_namespace.h> +#include "netns.h" #define RPCDBG_FACILITY RPCDBG_CACHE
@@ -1540,6 +1540,8 @@ static const struct file_operations cache_flush_operations_procfs = {static void remove_cache_proc_entries (struct cache_detail *cd,struct net *net) { +struct sunrpc_net *sn; +if (cd->u.procfs.proc_ent ==NULL )return ;if (cd->u.procfs.flush_ent)
@@ -1549,15 +1551,18 @@ static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net)if (cd->u.procfs.content_ent)remove_proc_entry ("content" , cd->u.procfs.proc_ent); cd->u.procfs.proc_ent =NULL ; -remove_proc_entry (cd->name, proc_net_rpc); + sn =net_generic (net, sunrpc_net_id); +remove_proc_entry (cd->name, sn->proc_net_rpc); }#ifdef CONFIG_PROC_FS static int create_cache_proc_entries (struct cache_detail *cd,struct net *net) {struct proc_dir_entry *p; +struct sunrpc_net *sn; - cd->u.procfs.proc_ent =proc_mkdir (cd->name, proc_net_rpc); + sn =net_generic (net, sunrpc_net_id); + cd->u.procfs.proc_ent =proc_mkdir (cd->name, sn->proc_net_rpc);if (cd->u.procfs.proc_ent ==NULL ) goto out_nomem; cd->u.procfs.channel_ent =NULL ;
net/sunrpc/netns.h +1 -0
@@ -5,6 +5,7 @@#include <net/netns/generic.h> struct sunrpc_net { +struct proc_dir_entry *proc_net_rpc; };extern int sunrpc_net_id;
net/sunrpc/stats.c +25 -18
78 lines not on this page · raw message
net/sunrpc/sunrpc_syms.c +10 -6
@@ -28,11 +28,21 @@ int sunrpc_net_id;static __net_init int sunrpc_init_net (struct net *net) { +int err; + + err =rpc_proc_init (net); +if (err) + goto err_proc; +return 0 ; + +err_proc: +return err; } static __net_exit void sunrpc_exit_net(struct net *net) { +rpc_proc_exit (net); }static struct pernet_operations sunrpc_net_ops = {
@@ -67,9 +77,6 @@ init_sunrpc(void)#ifdef RPC_DEBUG rpc_register_sysctl ();#endif -#ifdef CONFIG_PROC_FS -rpc_proc_init (); -#endif cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */
@@ -101,9 +108,6 @@ cleanup_sunrpc(void)#ifdef RPC_DEBUG rpc_unregister_sysctl ();#endif -#ifdef CONFIG_PROC_FS -rpc_proc_exit (); -#endif rcu_barrier ();/* Wait for completion of call_rcu()'s */ }MODULE_LICENSE ("GPL" );
Signature · 1 line
1.5.5.6
PATCH v2 9/9 sunrpc: Make the ip_map_cache be per-net
In reply to Pavel EmelyanovEverything that is required for that already exists:
* the per-net cache registration with respective proc entries
* the context (struct net) is available in all the users
--- net/sunrpc/netns.h | 6 ++ net/sunrpc/sunrpc_syms.c | 11 +++- net/sunrpc/svcauth_unix.c | 122 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 108 insertions(+), 31 deletions(-)
net/sunrpc/netns.h +6 -0
@@ -4,10 +4,16 @@#include <net/net_namespace.h> #include <net/netns/generic.h> +struct cache_detail ; +struct sunrpc_net {struct proc_dir_entry *proc_net_rpc; +struct cache_detail *ip_map_cache; };extern int sunrpc_net_id; +int ip_map_cache_create (struct net *); +void ip_map_cache_destroy (struct net *); +#endif
net/sunrpc/sunrpc_syms.c +8 -3
@@ -34,14 +34,21 @@ static __net_init int sunrpc_init_net(struct net *net)if (err) goto err_proc; + err =ip_map_cache_create (net); +if (err) + goto err_ipmap; +return 0 ; +err_ipmap: +rpc_proc_exit (net); err_proc:return err; } static __net_exit void sunrpc_exit_net(struct net *net) { +ip_map_cache_destroy (net);rpc_proc_exit (net); }
@@ -52,7 +59,7 @@ static struct pernet_operations sunrpc_net_ops = { .size = sizeof(struct sunrpc_net), }; -extern struct cache_detail ip_map_cache, unix_gid_cache; +extern struct cache_detail unix_gid_cache;extern void cleanup_rpcb_clnt (void );
@@ -77,7 +84,6 @@ init_sunrpc(void)#ifdef RPC_DEBUG rpc_register_sysctl ();#endif -cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */ init_socket_xprt ();/* clnt sock transport */
@@ -102,7 +108,6 @@ cleanup_sunrpc(void)svc_cleanup_xprt_sock ();unregister_rpc_pipefs ();rpc_destroy_mempool (); -cache_unregister (&ip_map_cache);cache_unregister (&unix_gid_cache);unregister_pernet_subsys (&sunrpc_net_ops);#ifdef RPC_DEBUG
net/sunrpc/svcauth_unix.c +94 -28
221 lines not on this page · raw message
Signature · 1 line
1.5.5.6
Quoted 7 lines · Pavel Emelyanov
Hello everyone!
This is the set I sent previously re-based on the
git://linux-nfs.org/~bfields/linux.gitnfsd-next branch and with fixed comment from Bruce.Please, consider it for inclusion.
The patches look fine to me, and it sounds like there's a plan for finishing the work that Trond and Chuck are both OK with....
So I'll queue those up for 2.6.37 soon if nobody spots any further problem.
--b.