RPC: Unify the AUTH_UNIX credential cache. AUTH_UNIX credentials really only depend on the process uid/gid/groups information. In particular there is no dependency on any strict rpc_client specific information. Might as well share them all between all RPC clients. Signed-off-by: Trond Myklebust --- auth_unix.c | 27 +++++++++++++-------------- 1 files changed, 13 insertions(+), 14 deletions(-) Index: linux-2.6.11-rc2/net/sunrpc/auth_unix.c =================================================================== --- linux-2.6.11-rc2.orig/net/sunrpc/auth_unix.c +++ linux-2.6.11-rc2/net/sunrpc/auth_unix.c @@ -36,25 +36,16 @@ struct unx_cred { # define RPCDBG_FACILITY RPCDBG_AUTH #endif +static struct rpc_auth unix_auth; static struct rpc_credops unix_credops; static struct rpc_auth * unx_create(struct rpc_clnt *clnt, rpc_authflavor_t flavor) { - struct rpc_auth *auth; - dprintk("RPC: creating UNIX authenticator for client %p\n", clnt); - if (!(auth = (struct rpc_auth *) kmalloc(sizeof(*auth), GFP_KERNEL))) - return NULL; - auth->au_cslack = UNX_WRITESLACK; - auth->au_rslack = 2; /* assume AUTH_NULL verf */ - auth->au_expire = UNX_CRED_EXPIRE; - auth->au_ops = &authunix_ops; - atomic_set(&auth->au_count, 1); - - rpcauth_init_credcache(auth); - - return auth; + if (atomic_inc_return(&unix_auth.au_count) == 0) + unix_auth.au_nextgc = jiffies + (unix_auth.au_expire >> 1); + return &unix_auth; } static void @@ -62,7 +53,6 @@ unx_destroy(struct rpc_auth *auth) { dprintk("RPC: destroying UNIX authenticator %p\n", auth); rpcauth_free_credcache(auth); - kfree(auth); } /* @@ -239,6 +229,15 @@ struct rpc_authops authunix_ops = { }; static +struct rpc_auth unix_auth = { + .au_cslack = UNX_WRITESLACK, + .au_rslack = 2, /* assume AUTH_NULL verf */ + .au_expire = UNX_CRED_EXPIRE, + .au_ops = &authunix_ops, + .au_count = ATOMIC_INIT(0), +}; + +static struct rpc_credops unix_credops = { .cr_name = "AUTH_UNIX", .crdestroy = unx_destroy_cred,