From: Stanislav Kinsbursky <skinsbursky@parallels.com>
To: Trond.Myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org, xemul@parallels.com, neilb@suse.de,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
jbottomley@parallels.com, bfields@fieldses.org,
davem@davemloft.net, devel@openvz.org
Subject: [PATCH 2/5] SUNRPC: create unix gid cache per network namespace
Date: Thu, 19 Jan 2012 18:49:14 +0400 [thread overview]
Message-ID: <20120119144914.9957.73951.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20120119144517.9957.59143.stgit@localhost6.localdomain6>
This 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".
Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
---
net/sunrpc/netns.h | 1 +
net/sunrpc/sunrpc_syms.c | 14 ++++++++++----
net/sunrpc/svcauth_unix.c | 36 +++++++++++++++++++++++++++++++-----
3 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/net/sunrpc/netns.h b/net/sunrpc/netns.h
index 1fdeb1b..309f88d 100644
--- a/net/sunrpc/netns.h
+++ b/net/sunrpc/netns.h
@@ -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;
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index b4217dc..38a72a1 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -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();
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
index 2f8c426..c753ae4 100644
--- a/net/sunrpc/svcauth_unix.c
+++ b/net/sunrpc/svcauth_unix.c
@@ -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;
next prev parent reply other threads:[~2012-01-19 14:49 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-19 14:48 [PATCH 0/5] SUNRPC: make caches network namespace aware Stanislav Kinsbursky
2012-01-19 14:49 ` [PATCH 1/5] SUNRPC: cache creation and destruction routines introduced Stanislav Kinsbursky
2012-01-19 14:49 ` Stanislav Kinsbursky [this message]
2012-01-19 16:24 ` [PATCH 2/5] SUNRPC: create unix gid cache per network namespace J. Bruce Fields
2012-01-19 17:00 ` Stanislav Kinsbursky
2012-01-19 14:49 ` [PATCH 3/5] SUNRPC: create GSS auth " Stanislav Kinsbursky
[not found] ` <20120119144922.9957.39352.stgit-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2012-01-19 16:31 ` J. Bruce Fields
2012-01-19 17:04 ` Stanislav Kinsbursky
2012-01-19 17:40 ` J. Bruce Fields
2012-01-19 17:51 ` Stanislav Kinsbursky
2012-01-19 14:49 ` [PATCH 5/5] SUNRPC: generic cache register routines removed Stanislav Kinsbursky
[not found] ` <20120119144517.9957.59143.stgit-bi+AKbBUZKagILUCTcTcHdKyNwTtLsGr@public.gmane.org>
2012-01-19 14:49 ` [PATCH 4/5] SUNRPC: ip map cache per network namespace cleanup Stanislav Kinsbursky
2012-01-19 16:37 ` J. Bruce Fields
2012-01-19 17:10 ` Stanislav Kinsbursky
[not found] ` <4F184E70.5070902-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2012-01-19 22:21 ` J. Bruce Fields
2012-01-19 15:19 ` [PATCH 0/5] SUNRPC: make caches network namespace aware Trond Myklebust
2012-01-19 15:31 ` Stanislav Kinsbursky
2012-01-19 15:34 ` Myklebust, Trond
2012-01-19 15:43 ` Stanislav Kinsbursky
2012-01-19 15:47 ` bfields
2012-01-19 16:01 ` Stanislav Kinsbursky
2012-01-19 17:34 ` Myklebust, Trond
[not found] ` <1326986392.6114.1.camel-SyLVLa/KEI9HwK5hSS5vWB2eb7JE58TQ@public.gmane.org>
2012-01-19 22:40 ` J. Bruce Fields
2012-01-19 17:14 ` Stanislav Kinsbursky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120119144914.9957.73951.stgit@localhost6.localdomain6 \
--to=skinsbursky@parallels.com \
--cc=Trond.Myklebust@netapp.com \
--cc=bfields@fieldses.org \
--cc=davem@davemloft.net \
--cc=devel@openvz.org \
--cc=jbottomley@parallels.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=netdev@vger.kernel.org \
--cc=xemul@parallels.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).