SUNRPC: make caches network namespace aware
Subsystems (4)
cover SUNRPC: make caches network namespace aware
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.
The following series consists of:
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removed
include/linux/sunrpc/cache.h | 6 + include/linux/sunrpc/svcauth_gss.h | 2 net/sunrpc/auth_gss/auth_gss.c | 21 +++++ net/sunrpc/auth_gss/svcauth_gss.c | 161 +++++++++++++++++++++++++----------- net/sunrpc/cache.c | 34 ++++++-- net/sunrpc/netns.h | 3 + net/sunrpc/sunrpc_syms.c | 15 ++- net/sunrpc/svcauth_unix.c | 107 ++++++++++++++---------- 8 files changed, 240 insertions(+), 109 deletions(-)
PATCH 1/5 SUNRPC: cache creation and destruction routines introduced
This patch prepares infrastructure for network namespace aware cache detail allocation.
One note about adding network namespace link to cache structure. It's going to be used later in NFS DNS cache parsing routine (nfs_dns_parse for rpc_pton() call).
--- include/linux/sunrpc/cache.h | 4 ++++ net/sunrpc/cache.c | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 0 deletions(-)
include/linux/sunrpc/cache.h +4 -0
@@ -117,6 +117,7 @@ struct cache_detail {struct cache_detail_procfs procfs;struct cache_detail_pipefs pipefs; } u; +struct net *net; };
@@ -202,6 +203,9 @@ 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 struct cache_detail *cache_create_net (struct cache_detail *tmpl,struct net *net); +extern void cache_destroy_net (struct cache_detail *cd,struct net *net); +extern void sunrpc_init_cache_detail (struct cache_detail *cd);extern void sunrpc_destroy_cache_detail (struct cache_detail *cd); extern int sunrpc_cache_register_pipefs(struct dentry *parent, const char *,
net/sunrpc/cache.c +26 -0
@@ -1662,6 +1662,32 @@ void cache_unregister(struct cache_detail *cd) }EXPORT_SYMBOL_GPL (cache_unregister); +struct cache_detail *cache_create_net (struct cache_detail *tmpl,struct net *net) +{ +struct cache_detail *cd; + + cd =kmemdup (tmpl,sizeof (struct cache_detail ),GFP_KERNEL ); +if (cd ==NULL ) +return ERR_PTR (-ENOMEM ); + + cd->hash_table =kzalloc (cd->hash_size *sizeof (struct cache_head *), +GFP_KERNEL ); +if (cd->hash_table ==NULL ) { +kfree (cd); +return ERR_PTR (-ENOMEM ); + } + cd->net = net; +return cd; +} +EXPORT_SYMBOL_GPL (cache_create_net); + +void cache_destroy_net (struct cache_detail *cd,struct net *net) +{ +kfree (cd->hash_table); +kfree (cd); +} +EXPORT_SYMBOL_GPL (cache_destroy_net); +static ssize_t cache_read_pipefs (struct file *filp,char __user *buf,size_t count,loff_t *ppos) {
PATCH 2/5 SUNRPC: create unix gid cache per network namespace
In reply to Stanislav KinsburskyThis patch makes unix_gid_cache cache detail allocated and registered per network namespace context.
Thus with this patch unix_gid_cache contents for network namespace "X" are controlled from proc file system mount for the same network namespace "X".
--- net/sunrpc/netns.h | 1 + net/sunrpc/sunrpc_syms.c | 14 ++++++++++---- net/sunrpc/svcauth_unix.c | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 9 deletions(-)
net/sunrpc/netns.h +1 -0
@@ -9,6 +9,7 @@ struct cache_detail;struct sunrpc_net {struct proc_dir_entry *proc_net_rpc;struct cache_detail *ip_map_cache; +struct cache_detail *unix_gid_cache;struct super_block *pipefs_sb;struct mutex pipefs_sb_lock;
net/sunrpc/sunrpc_syms.c +10 -4
@@ -26,6 +26,9 @@int sunrpc_net_id; +extern int unix_gid_cache_create (struct net *net); +extern int unix_gid_cache_destroy (struct net *net); +static __net_init int sunrpc_init_net (struct net *net) {int err;
@@ -39,11 +42,17 @@ static __net_init int sunrpc_init_net(struct net *net)if (err) goto err_ipmap; + err =unix_gid_cache_create (net); +if (err) + goto err_unixgid; +rpc_pipefs_init_net (net);INIT_LIST_HEAD (&sn->all_clients);spin_lock_init (&sn->rpc_client_lock);return 0 ; +err_unixgid: +ip_map_cache_destroy (net); err_ipmap:rpc_proc_exit (net); err_proc:
@@ -52,6 +61,7 @@ err_proc: static __net_exit void sunrpc_exit_net(struct net *net) { +unix_gid_cache_destroy (net);ip_map_cache_destroy (net);rpc_proc_exit (net); }
@@ -63,8 +73,6 @@ static struct pernet_operations sunrpc_net_ops = { .size = sizeof(struct sunrpc_net), }; -extern struct cache_detail unix_gid_cache; -static int __init init_sunrpc (void ) {
@@ -86,7 +94,6 @@ init_sunrpc(void)#ifdef RPC_DEBUG rpc_register_sysctl ();#endif -cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */ init_socket_xprt ();/* clnt sock transport */ return 0 ;
@@ -109,7 +116,6 @@ cleanup_sunrpc(void)svc_cleanup_xprt_sock ();unregister_rpc_pipefs ();rpc_destroy_mempool (); -cache_unregister (&unix_gid_cache);unregister_pernet_subsys (&sunrpc_net_ops);#ifdef RPC_DEBUG rpc_unregister_sysctl ();
net/sunrpc/svcauth_unix.c +31 -5
@@ -436,7 +436,6 @@ struct unix_gid {uid_t uid;struct group_info *gi; }; -static struct cache_head *gid_table[GID_HASHMAX ];static void unix_gid_put (struct kref *kref) {
@@ -495,7 +494,6 @@ static int unix_gid_upcall(struct cache_detail *cd, struct cache_head *h) }static struct unix_gid *unix_gid_lookup (uid_t uid); -extern struct cache_detail unix_gid_cache;static int unix_gid_parse (struct cache_detail *cd,char *mesg,int mlen)
@@ -544,14 +542,14 @@ static int unix_gid_parse(struct cache_detail *cd,struct cache_head *ch; ug.h.flags =0 ; ug.h.expiry_time = expiry; - ch =sunrpc_cache_update (&unix_gid_cache, + ch =sunrpc_cache_update (cd, &ug.h, &ugp->h,hash_long (uid,GID_HASHBITS ));if (!ch) err = -ENOMEM ;else { err =0 ; -cache_put (ch, &unix_gid_cache); +cache_put (ch, cd); } }else err = -ENOMEM ;
@@ -590,7 +588,6 @@ static int unix_gid_show(struct seq_file *m,struct cache_detail unix_gid_cache = { .owner =THIS_MODULE , .hash_size =GID_HASHMAX , - .hash_table = gid_table, .name ="auth.unix.gid" , .cache_put = unix_gid_put, .cache_upcall = unix_gid_upcall,
@@ -602,6 +599,35 @@ struct cache_detail unix_gid_cache = { .alloc = unix_gid_alloc, }; +int unix_gid_cache_create (struct net *net) +{ +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +struct cache_detail *cd; +int err; + + cd =cache_create_net (&unix_gid_cache, net); +if (IS_ERR (cd)) +return PTR_ERR (cd); + err =cache_register_net (cd, net); +if (err) { +cache_destroy_net (&unix_gid_cache, net); +return err; + } + sn->unix_gid_cache = cd; +return 0 ; +} + +void unix_gid_cache_destroy (struct net *net) +{ +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +struct cache_detail *cd = sn->unix_gid_cache; + + sn->unix_gid_cache =NULL ; +cache_purge (cd); +cache_unregister_net (cd, net); +cache_destroy_net (cd, net); +} +static struct unix_gid *unix_gid_lookup (uid_t uid) {struct unix_gid ug;
Re: [PATCH 2/5] SUNRPC: create unix gid cache per network namespace
Quoted 4 lines · Stanislav Kinsbursky
This patch makes
unix_gid_cachecache detail allocated and registered per network namespace context.
Thus with this patchunix_gid_cachecontents for network namespace "X" are controlled from proc file system mount for the same network namespace "X".
I'm confused--this seems half-done. I see that you're creating the gid caches dynamically, but there's still this static definition:
net/sunrpc/svcauth_unix.c static int unix_gid_show(struct seq_file *m, · line 593
Quoted 7 lines
struct
cache_detailunix_gid_cache= {net/sunrpc/svcauth_unix.c +0
-1.owner = THIS_MODULE, .hash_size = GID_HASHMAX, - .hash_table = gid_table, .name = "auth.unix.gid", .cache_put = unix_gid_put, .cache_upcall = unix_gid_upcall,
And it looks like unix_gid_lookup is still using this static unix_gid_cache. Maybe I'm missing something....
--b.
Re: [PATCH 2/5] SUNRPC: create unix gid cache per network namespace
19.01.2012 20:24, J. Bruce Fields пишет:
Quoted 9 lines · Stanislav Kinsbursky
Quoted 4 lines
This patch makes
unix_gid_cachecache detail allocated and registered per network namespace context.
Thus with this patchunix_gid_cachecontents for network namespace "X" are controlled from proc file system mount for the same network namespace "X".I'm confused--this seems half-done. I see that you're creating the gid caches dynamically, but there's still this static definition:
This static definition is used as a template now.
Have a look at the first path of the series: cache creation routine duplicates incomming cache_detail and initializes net and hash_table fields in freshly created copy. This copy is the new per-net cache_detail instance.
Quoted 11 lines
net/sunrpc/svcauth_unix.c static int unix_gid_show(struct seq_file *m, · line 593
Quoted 7 lines
struct cache_detail unix_gid_cache = { .owner = THIS_MODULE, .hash_size = GID_HASHMAX,net/sunrpc/svcauth_unix.c +0
-1- .hash_table = gid_table, .name = "auth.unix.gid", .cache_put = unix_gid_put, .cache_upcall = unix_gid_upcall,And it looks like
unix_gid_lookupis still using this staticunix_gid_cache. Maybe I'm missing something....
Yep, thanks for the catch.
My fault, I've missed this usage.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
PATCH 3/5 SUNRPC: create GSS auth cache per network namespace
In reply to Stanislav KinsburskyThis patch makes GSS auth cache details allocated and registered per network namespace context.
Thus with this patch rsi_cache and rsc_cache contents for network namespace "X" are controlled from proc file system mount for the same network namespace "X".
--- include/linux/sunrpc/svcauth_gss.h | 2 net/sunrpc/auth_gss/auth_gss.c | 21 +++++ net/sunrpc/auth_gss/svcauth_gss.c | 161 +++++++++++++++++++++++++----------- net/sunrpc/cache.c | 2 net/sunrpc/netns.h | 2 net/sunrpc/sunrpc_syms.c | 1 6 files changed, 141 insertions(+), 48 deletions(-)
include/linux/sunrpc/svcauth_gss.h +2 -0
@@ -18,6 +18,8 @@int gss_svc_init (void );void gss_svc_shutdown (void ); +int gss_svc_init_net (struct net *net); +void gss_svc_shutdown_net (struct net *net);int svcauth_gss_register_pseudoflavor (u32 pseudoflavor,char * name);u32 svcauth_gss_flavor (struct auth_domain *dom);char *svc_gss_principal (struct svc_rqst *);
net/sunrpc/auth_gss/auth_gss.c +21 -0
@@ -1662,6 +1662,21 @@ static const struct rpc_pipe_ops gss_upcall_ops_v1 = { .release_pipe = gss_pipe_release, }; +static __net_init int rpcsec_gss_init_net (struct net *net) +{ +return gss_svc_init_net (net); +} + +static __net_exit void rpcsec_gss_exit_net(struct net *net) +{ +gss_svc_shutdown_net (net); +} + +static struct pernet_operations rpcsec_gss_net_ops = { + .init = rpcsec_gss_init_net, + .exit = rpcsec_gss_exit_net, +}; +/* * Initialize RPCSEC_GSS module */
@@ -1675,8 +1690,13 @@ static int __init init_rpcsec_gss(void) err =gss_svc_init ();if (err) goto out_unregister; + err =register_pernet_subsys (&rpcsec_gss_net_ops); +if (err) + goto out_svc_exit;rpc_init_wait_queue (&pipe_version_rpc_waitqueue,"gss pipe version" );return 0 ; +out_svc_exit: +gss_svc_shutdown (); out_unregister:rpcauth_unregister (&authgss_ops); out:
@@ -1685,6 +1705,7 @@ out: static void __exit exit_rpcsec_gss(void) { +unregister_pernet_subsys (&rpcsec_gss_net_ops);gss_svc_shutdown ();rpcauth_unregister (&authgss_ops);rcu_barrier ();/* Wait for completion of call_rcu()'s */
net/sunrpc/auth_gss/svcauth_gss.c +113 -48
371 lines not on this page · raw message
net/sunrpc/cache.c +2 -0
@@ -1643,6 +1643,7 @@ int cache_register_net(struct cache_detail *cd, struct net *net)sunrpc_destroy_cache_detail (cd);return ret; } +EXPORT_SYMBOL_GPL (cache_register_net);int cache_register (struct cache_detail *cd) {
@@ -1655,6 +1656,7 @@ void cache_unregister_net(struct cache_detail *cd, struct net *net)remove_cache_proc_entries (cd, net);sunrpc_destroy_cache_detail (cd); } +EXPORT_SYMBOL_GPL (cache_unregister_net);void cache_unregister (struct cache_detail *cd) {
net/sunrpc/netns.h +2 -0
@@ -10,6 +10,8 @@ struct sunrpc_net {struct proc_dir_entry *proc_net_rpc;struct cache_detail *ip_map_cache;struct cache_detail *unix_gid_cache; +struct cache_detail *rsc_cache; +struct cache_detail *rsi_cache;struct super_block *pipefs_sb;struct mutex pipefs_sb_lock;
net/sunrpc/sunrpc_syms.c +1 -0
@@ -25,6 +25,7 @@#include "netns.h" int sunrpc_net_id; +EXPORT_SYMBOL_GPL (sunrpc_net_id);extern int unix_gid_cache_create (struct net *net);extern int unix_gid_cache_destroy (struct net *net);
Re: [PATCH 3/5] SUNRPC: create GSS auth cache per network namespace
net/sunrpc/auth_gss/svcauth_gss.c static int svcauth_gss_handle_init(struct svc_rqst *rqstp, · line 999
Quoted 5 lines · Stanislav Kinsbursky
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1000,6 +996,7 @@ static int svcauth_gss_handle_init(struct svc_rqst *rqstp,struct xdr_netobj tmpobj;struct rsi *rsip, rsikey;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);
OK, so you're getting the network namespace out of the rqstp, and, then passing it down, makes sense. And:
net/sunrpc/auth_gss/svcauth_gss.c svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp) · line 1079
Quoted 5 lines
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1079,6 +1076,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)__be32 *rpcstart;__be32 *reject_stat = resv->iov_base + resv->iov_len;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);
... same for the gss cache. Looks good.
How do you plan to test this?
--b.
--
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
Re: [PATCH 3/5] SUNRPC: create GSS auth cache per network namespace
19.01.2012 20:31, J. Bruce Fields пишет:
Quoted 18 lines · Stanislav Kinsbursky
net/sunrpc/auth_gss/svcauth_gss.c static int svcauth_gss_handle_init(struct svc_rqst *rqstp, · line 999
Quoted 5 lines
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1000,6 +996,7 @@ static int svcauth_gss_handle_init(struct svc_rqst *rqstp,struct xdr_netobj tmpobj;struct rsi *rsip, rsikey;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);OK, so you're getting the network namespace out of the rqstp, and, then passing it down, makes sense. And:
net/sunrpc/auth_gss/svcauth_gss.c svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp) · line 1079
Quoted 5 lines
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1079,6 +1076,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)__be32 *rpcstart;__be32 *reject_stat = resv->iov_base + resv->iov_len;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);... same for the gss cache. Looks good.
Quoted 2 lines
How do you plan to test this?
Do you mean something special or in general?
Currently I validate all my chages in container by using simple test environment. I would be appreciate for any hints to tests, than can help.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Re: [PATCH 3/5] SUNRPC: create GSS auth cache per network namespace
Quoted 19 lines · Stanislav Kinsbursky
19.01.2012 20:31, J. Bruce Fields пишет:
Quoted 18 lines · Stanislav Kinsbursky
net/sunrpc/auth_gss/svcauth_gss.c static int svcauth_gss_handle_init(struct svc_rqst *rqstp, · line 999
Quoted 5 lines
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1000,6 +996,7 @@ static int svcauth_gss_handle_init(struct svc_rqst *rqstp,struct xdr_netobj tmpobj;struct rsi *rsip, rsikey;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);OK, so you're getting the network namespace out of the rqstp, and, then passing it down, makes sense. And:
net/sunrpc/auth_gss/svcauth_gss.c svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp) · line 1079
Quoted 5 lines
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1079,6 +1076,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)__be32 *rpcstart;__be32 *reject_stat = resv->iov_base + resv->iov_len;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);... same for the gss cache. Looks good.
Quoted 6 lines
Quoted 2 lines
How do you plan to test this?
Do you mean something special or in general?
Currently I validate all my chages in container by using simple test environment. I would be appreciate for any hints to tests, than can help.
The server needs to be tested after these changes, and we need to make sure the caches affected still work.
(I suspect the gid cache code will oops if it's used after these patches, since the table is left NULl?)
And then we should also test in a container environment, with different instances of mountd and rpc.svcidmapd running in each container, to verify that the right thing happens.
--b.
Re: [PATCH 3/5] SUNRPC: create GSS auth cache per network namespace
19.01.2012 21:40, J. Bruce Fields пишет:
Quoted 30 lines · Stanislav Kinsbursky
Quoted 19 lines
19.01.2012 20:31, J. Bruce Fields пишет:
Quoted 18 lines · Stanislav Kinsbursky
net/sunrpc/auth_gss/svcauth_gss.c static int svcauth_gss_handle_init(struct svc_rqst *rqstp, · line 999
Quoted 5 lines
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1000,6 +996,7 @@ static int svcauth_gss_handle_init(struct svc_rqst *rqstp,struct xdr_netobj tmpobj;struct rsi *rsip, rsikey;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);OK, so you're getting the network namespace out of the rqstp, and, then passing it down, makes sense. And:
net/sunrpc/auth_gss/svcauth_gss.c svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp) · line 1079
Quoted 5 lines
net/sunrpc/auth_gss/svcauth_gss.c +1
-0@@ -1079,6 +1076,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)__be32 *rpcstart;__be32 *reject_stat = resv->iov_base + resv->iov_len;int ret; +struct sunrpc_net *sn =net_generic (rqstp->rq_xprt->xpt_net, sunrpc_net_id);... same for the gss cache. Looks good.
Quoted 6 lines
Quoted 2 lines
How do you plan to test this?
Do you mean something special or in general?
Currently I validate all my chages in container by using simple test environment. I would be appreciate for any hints to tests, than can help.The server needs to be tested after these changes, and we need to make sure the caches affected still work.
Quoted 7 lines
(I suspect the gid cache code will oops if it's used after these patches, since the table is left NULl?)
And then we should also test in a container environment, with different instances of mountd and rpc.svcidmapd running in each container, to verify that the right thing happens.
Ok. I'll test server with 2-nd version of these patches tomorrow and reply with the results. Thanks, Bruce.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
PATCH 4/5 SUNRPC: ip map cache per network namespace cleanup
In reply to Stanislav KinsburskyThis patch converts ip_map_cache per network namespace implemenetation to the same view, as other caches done in the series.
Besides generalization, code becomes shorter with this patch.
--- net/sunrpc/svcauth_unix.c | 71 +++++++++++++++++++-------------------------- 1 files changed, 30 insertions(+), 41 deletions(-)
net/sunrpc/svcauth_unix.c +30 -41
@@ -211,7 +211,7 @@ static int ip_map_parse(struct cache_detail *cd, len =qword_get (&mesg, buf, mlen);if (len <=0 )return -EINVAL ; -if (rpc_pton (&init_net, buf, len, &address.sa,sizeof (address)) ==0 ) +if (rpc_pton (cd->net, buf, len, &address.sa,sizeof (address)) ==0 )return -EINVAL ;switch (address.sa.sa_family) {case AF_INET :
@@ -875,56 +875,45 @@ struct auth_ops svcauth_unix = { .set_client = svcauth_unix_set_client, }; +struct cache_detail ip_map_cache = { + .owner =THIS_MODULE , + .hash_size =IP_HASHMAX , + .name ="auth.unix.ip" , + .cache_put = ip_map_put, + .cache_upcall = ip_map_upcall, + .cache_parse = ip_map_parse, + .cache_show = ip_map_show, + .match = ip_map_match, + .init = ip_map_init, + .update = update, + .alloc = ip_map_alloc, +}; +int ip_map_cache_create (struct net *net) { -int err = -ENOMEM ; -struct cache_detail *cd; -struct cache_head **tbl;struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +struct cache_detail *cd; +int err; - cd =kzalloc (sizeof (struct cache_detail ),GFP_KERNEL ); -if (cd ==NULL ) - goto err_cd; - - tbl =kzalloc (IP_HASHMAX *sizeof (struct cache_head *),GFP_KERNEL ); -if (tbl ==NULL ) - goto err_tbl; - - cd->owner =THIS_MODULE , - cd->hash_size =IP_HASHMAX , - cd->hash_table = tbl, - cd->name ="auth.unix.ip" , - cd->cache_put = ip_map_put, - cd->cache_upcall = ip_map_upcall, - cd->cache_parse = ip_map_parse, - cd->cache_show = ip_map_show, - cd->match = ip_map_match, - cd->init = ip_map_init, - cd->update = update, - cd->alloc = ip_map_alloc, - + cd =cache_create_net (&ip_map_cache, net); +if (IS_ERR (cd)) +return PTR_ERR (cd); err =cache_register_net (cd, net); -if (err) - goto err_reg; - +if (err) { +cache_destroy_net (cd, net); +return err; + } sn->ip_map_cache = cd;return 0 ; - -err_reg: -kfree (tbl); -err_tbl: -kfree (cd); -err_cd: -return err; }void ip_map_cache_destroy (struct net *net) { -struct sunrpc_net *sn; +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +struct cache_detail *cd = sn->ip_map_cache; - sn =net_generic (net, sunrpc_net_id); -cache_purge (sn->ip_map_cache); -cache_unregister_net (sn->ip_map_cache, net); -kfree (sn->ip_map_cache->hash_table); -kfree (sn->ip_map_cache); + sn->ip_map_cache =NULL ; +cache_purge (cd); +cache_unregister_net (cd, net); +cache_destroy_net (cd, net); }
--
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
Re: [PATCH 4/5] SUNRPC: ip map cache per network namespace cleanup
Quoted 3 lines · Stanislav Kinsbursky
This patch converts
ip_map_cacheper network namespace implemenetation to the same view, as other caches done in the series.
Besides generalization, code becomes shorter with this patch.
Again, isnt' it ip_map_cache, and not one of the dynamically created cache details, that's being passed to the lookup routines?
I may just be confused....
--b.
Quoted 107 lines
Signed-off-by Stanislav Kinsbursky <[email protected]>--- net/sunrpc/svcauth_unix.c | 71 +++++++++++++++++++-------------------------- 1 files changed, 30 insertions(+), 41 deletions(-)net/sunrpc/svcauth_unix.c +30
-41@@ -211,7 +211,7 @@ static int ip_map_parse(struct cache_detail *cd, len =qword_get (&mesg, buf, mlen);if (len <=0 )return -EINVAL ; -if (rpc_pton (&init_net, buf, len, &address.sa,sizeof (address)) ==0 ) +if (rpc_pton (cd->net, buf, len, &address.sa,sizeof (address)) ==0 )return -EINVAL ;switch (address.sa.sa_family) {case AF_INET :@@ -875,56 +875,45 @@ struct auth_ops svcauth_unix = { .set_client = svcauth_unix_set_client, }; +struct cache_detail ip_map_cache = { + .owner =THIS_MODULE , + .hash_size =IP_HASHMAX , + .name ="auth.unix.ip" , + .cache_put = ip_map_put, + .cache_upcall = ip_map_upcall, + .cache_parse = ip_map_parse, + .cache_show = ip_map_show, + .match = ip_map_match, + .init = ip_map_init, + .update = update, + .alloc = ip_map_alloc, +}; +int ip_map_cache_create (struct net *net) { -int err = -ENOMEM ; -struct cache_detail *cd; -struct cache_head **tbl;struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +struct cache_detail *cd; +int err; - cd =kzalloc (sizeof (struct cache_detail ),GFP_KERNEL ); -if (cd ==NULL ) - goto err_cd; - - tbl =kzalloc (IP_HASHMAX *sizeof (struct cache_head *),GFP_KERNEL ); -if (tbl ==NULL ) - goto err_tbl; - - cd->owner =THIS_MODULE , - cd->hash_size =IP_HASHMAX , - cd->hash_table = tbl, - cd->name ="auth.unix.ip" , - cd->cache_put = ip_map_put, - cd->cache_upcall = ip_map_upcall, - cd->cache_parse = ip_map_parse, - cd->cache_show = ip_map_show, - cd->match = ip_map_match, - cd->init = ip_map_init, - cd->update = update, - cd->alloc = ip_map_alloc, - + cd =cache_create_net (&ip_map_cache, net); +if (IS_ERR (cd)) +return PTR_ERR (cd); err =cache_register_net (cd, net); -if (err) - goto err_reg; - +if (err) { +cache_destroy_net (cd, net); +return err; + } sn->ip_map_cache = cd;return 0 ; - -err_reg: -kfree (tbl); -err_tbl: -kfree (cd); -err_cd: -return err; }void ip_map_cache_destroy (struct net *net) { -struct sunrpc_net *sn; +struct sunrpc_net *sn =net_generic (net, sunrpc_net_id); +struct cache_detail *cd = sn->ip_map_cache; - sn =net_generic (net, sunrpc_net_id); -cache_purge (sn->ip_map_cache); -cache_unregister_net (sn->ip_map_cache, net); -kfree (sn->ip_map_cache->hash_table); -kfree (sn->ip_map_cache); + sn->ip_map_cache =NULL ; +cache_purge (cd); +cache_unregister_net (cd, net); +cache_destroy_net (cd, net); }
Re: [PATCH 4/5] SUNRPC: ip map cache per network namespace cleanup
19.01.2012 20:37, J. Bruce Fields пишет:
Quoted 10 lines · Stanislav Kinsbursky
Quoted 3 lines
This patch converts
ip_map_cacheper network namespace implemenetation to the same view, as other caches done in the series.
Besides generalization, code becomes shorter with this patch.Again, isnt' it
ip_map_cache, and not one of the dynamically created cache details, that's being passed to the lookup routines?I may just be confused....
Nope. ip_map_cache was made per network namespace a long time ago.
But it was done in other way: no static templates - just allocation and initialization.
But static template looks clearer to me. So I've used this approach for other caches. And decided to update ip_map_cache management in the same way.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Re: [PATCH 4/5] SUNRPC: ip map cache per network namespace cleanup
Quoted 12 lines · Stanislav Kinsbursky
19.01.2012 20:37, J. Bruce Fields пишет:
Quoted 10 lines · Stanislav Kinsbursky
Quoted 3 lines
This patch converts
ip_map_cacheper network namespace implemenetation to the same view, as other caches done in the series.
Besides generalization, code becomes shorter with this patch.Again, isnt' it
ip_map_cache, and not one of the dynamically created cache details, that's being passed to the lookup routines?I may just be confused....
Quoted 6 lines
Nope.
ip_map_cachewas made per network namespace a long time ago. But it was done in other way: no static templates - just allocation and initialization.
But static template looks clearer to me. So I've used this approach for other caches. And decided to updateip_map_cachemanagement in the same way.
Going and reading the code.... OK, I see what you mean, makes sense. Thanks!
--b.
--
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
PATCH 5/5 SUNRPC: generic cache register routines removed
In reply to Stanislav KinsburskyAll cache users now uses network-namespace-aware routines, so generic ones are obsolete.
--- include/linux/sunrpc/cache.h | 2 -- net/sunrpc/cache.c | 12 ------------ 2 files changed, 0 insertions(+), 14 deletions(-)
include/linux/sunrpc/cache.h +0 -2
@@ -198,9 +198,7 @@ extern void cache_flush(void);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 struct cache_detail *cache_create_net (struct cache_detail *tmpl,struct net *net);
net/sunrpc/cache.c +0 -12
@@ -1645,12 +1645,6 @@ int cache_register_net(struct cache_detail *cd, struct net *net) }EXPORT_SYMBOL_GPL (cache_register_net); -int cache_register (struct cache_detail *cd) -{ -return cache_register_net (cd, &init_net); -} -EXPORT_SYMBOL_GPL (cache_register); -void cache_unregister_net (struct cache_detail *cd,struct net *net) {remove_cache_proc_entries (cd, net);
@@ -1658,12 +1652,6 @@ void cache_unregister_net(struct cache_detail *cd, struct net *net) }EXPORT_SYMBOL_GPL (cache_unregister_net); -void cache_unregister (struct cache_detail *cd) -{ -cache_unregister_net (cd, &init_net); -} -EXPORT_SYMBOL_GPL (cache_unregister); -struct cache_detail *cache_create_net (struct cache_detail *tmpl,struct net *net) {struct cache_detail *cd;
Quoted 5 lines · Stanislav Kinsbursky
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.The following series consists of:
Quoted 8 lines
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removed
The patches look good, and I've applied them for now in my 'devel' branch so we can test them, but I'd like to get an Ack/Nack from Bruce before committing to merging them.
Signature · 11 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com -- 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
19.01.2012 19:19, Trond Myklebust пишет:
Quoted 15 lines · Stanislav Kinsbursky
Quoted 5 lines
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.The following series consists of:
Quoted 8 lines
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removed
Quoted 4 lines
The patches look good, and I've applied them for now in my 'devel' branch so we can test them, but I'd like to get an Ack/Nack from Bruce before committing to merging them.
Cool, thanks.
BTW, these patches depends on patch "NFSd: use network-namespace-aware cache registering routines", which Bruce took already (and it's even in linux-next already), but not in your devel tree for some reason.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Quoted 31 lines
-----Original Message-----
From: Stanislav Kinsbursky [mailto:[email protected]]
Sent: Thursday, January 19, 2012 10:32 AM
To: Myklebust, Trond
Cc: Dr James Bruce Fields; [email protected]; Pavel Emelianov; [email protected]; [email protected]; [email protected]; James Bottomley; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 0/5] SUNRPC: make caches network namespace aware19.01.2012 19:19, Trond Myklebust пишет:
Quoted 15 lines · Stanislav Kinsbursky
Quoted 5 lines
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.The following series consists of:
Quoted 8 lines
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removedQuoted 4 lines
The patches look good, and I've applied them for now in my 'devel' branch so we can test them, but I'd like to get an Ack/Nack from Bruce before committing to merging them.
Quoted 4 lines
Cool, thanks.
BTW, these patches depends on patch "NFSd: use network-namespace- aware cache registering routines", which Bruce took already (and it's even in linux-next already), but not in your devel tree for some reason.
In that case, would it make more sense to carry them in Bruce's tree?
--
Trond Myklebust
Linux NFS client maintainer
NetApp
[email protected]
www.netapp.com
19.01.2012 19:34, Myklebust, Trond пишет:
Quoted 31 lines
Quoted 31 lines
-----Original Message-----
From: Stanislav Kinsbursky [mailto:[email protected]]
Sent: Thursday, January 19, 2012 10:32 AM
To: Myklebust, Trond
Cc: Dr James Bruce Fields; [email protected]; Pavel Emelianov; [email protected]; [email protected]; [email protected]; James Bottomley; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 0/5] SUNRPC: make caches network namespace aware19.01.2012 19:19, Trond Myklebust пишет:
Quoted 19 lines · Stanislav Kinsbursky
Quoted 5 lines
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.The following series consists of:
Quoted 8 lines
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removedThe patches look good, and I've applied them for now in my 'devel' branch so we can test them, but I'd like to get an Ack/Nack from Bruce before committing to merging them.
Quoted 7 lines
Quoted 4 lines
Cool, thanks.
BTW, these patches depends on patch "NFSd: use network-namespace- aware cache registering routines", which Bruce took already (and it's even in linux-next already), but not in your devel tree for some reason.In that case, would it make more sense to carry them in Bruce's tree?
It's up to you, of course. But, frankly, I don't think so.
To be more precise, only the last patch ("SUNRPC: generic cache register routines removed") depends on the patch, which is in linux-next already. IOW, those patch removed NFSd dependence on cache_register() and cache_unregister() routines and was commited to linux-next at Wed, 7 Dec 2011.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
Quoted 21 lines · Stanislav Kinsbursky
19.01.2012 19:19, Trond Myklebust пишет:
Quoted 15 lines · Stanislav Kinsbursky
Quoted 5 lines
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.The following series consists of:
Quoted 8 lines
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removedQuoted 4 lines
The patches look good, and I've applied them for now in my 'devel' branch so we can test them, but I'd like to get an Ack/Nack from Bruce before committing to merging them.
Quoted 5 lines
Cool, thanks.
BTW, these patches depends on patch "NFSd: use network-namespace-aware cache registering routines", which Bruce took already (and it's even in linux-next already), but not in your devel tree for some reason.
And Linus has pulled those, so if Trond bases his tree on -rc1, he'll have "NFSd: use network-namespace-aware cache registering routines".
You know best what you're planning to submit over the next cycle, and what the dependencies are, and which side (client or server) it's likely to touch more. So, your choice, I think. If necessary Trond and I can probably do a merge between us at some point.
Either way, I'll go take a look at them now....--b.
--b.
19.01.2012 19:47, [email protected] пишет:
Quoted 28 lines · Stanislav Kinsbursky
Quoted 21 lines
19.01.2012 19:19, Trond Myklebust пишет:
Quoted 15 lines · Stanislav Kinsbursky
Quoted 5 lines
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.The following series consists of:
Quoted 8 lines
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removedQuoted 4 lines
The patches look good, and I've applied them for now in my 'devel' branch so we can test them, but I'd like to get an Ack/Nack from Bruce before committing to merging them.
Quoted 5 lines
Cool, thanks.
BTW, these patches depends on patch "NFSd: use network-namespace-aware cache registering routines", which Bruce took already (and it's even in linux-next already), but not in your devel tree for some reason.
Quoted 8 lines
And Linus has pulled those, so if Trond bases his tree on -rc1, he'll have "NFSd: use network-namespace-aware cache registering routines".
You know best what you're planning to submit over the next cycle, and what the dependencies are, and which side (client or server) it's likely to touch more. So, your choice, I think. If necessary Trond and I can probably do a merge between us at some point.
Actually, I'm not going to patch NFSd in this cycle. Some more NFS and Lockd patches will follow soon. So, probably, Trond's tree suits better.
Signature · 2 lines
Best regards, Stanislav Kinsbursky
PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBiZmllbGRzQGZpZWxkc2VzLm9y ZyBbbWFpbHRvOmJmaWVsZHNAZmllbGRzZXMub3JnXQ0KPiBTZW50OiBUaHVyc2RheSwgSmFudWFy eSAxOSwg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oYXMgcHVsbGVkIHRob3Nl LCBzbyBpZiBUcm9uZCBiYXNlcyBoaXMgdHJlZSBvbiAtcmMxLCBoZSdsbCBoYXZlDQo+ICJORlNk OiB1c2UgbmV0d29yay1uYW1lc3BhY2UtYXdhcmUgY2FjaGUgcmVnaXN0ZXJpbmcgcm91dGluZXMi Lg0KDQpPSy4gSW4gdGhhdCBjYXNlIEkgc2hvdWxkIGhhdmUgdGhlbS4uLiANCg0K
Quoted 15 lines · Trond Myklebust
Quoted 5 lines · Stanislav Kinsbursky
One more step towards to "NFS in container".
With this patch set caches are allocated per network namespace.The following series consists of:
Quoted 8 lines
---
Stanislav Kinsbursky (5):
SUNRPC: cache creation and destruction routines introduced
SUNRPC: create unix gid cache per network namespace
SUNRPC: create GSS auth cache per network namespace
SUNRPC: ip map cache per network namespace cleanup
SUNRPC: generic cache register routines removed
Quoted 3 lines
The patches look good, and I've applied them for now in my 'devel' branch so we can test them, but I'd like to get an Ack/Nack from Bruce before committing to merging them.
They look good to me. I'd like to hear how they've been tested--that done, they'll have my ack.
--b.
--
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
Sorry, this patch set has some bugs.
I'll resend fixed version soon.
Signature · 2 lines
Best regards, Stanislav Kinsbursky