RPC: kill cr_auth The cr_auth field is currently used only in order to figure out the name of the credential's flavour in debugging printks. Replace with a dedicated pointer in the statically allocated rpc_credops instead. Signed-off-by: Trond Myklebust --- include/linux/sunrpc/auth.h | 2 +- net/sunrpc/auth.c | 18 +++++++----------- net/sunrpc/auth_gss/auth_gss.c | 1 + net/sunrpc/auth_null.c | 1 + net/sunrpc/auth_unix.c | 1 + 5 files changed, 11 insertions(+), 12 deletions(-) Index: linux-2.6.11-rc3/net/sunrpc/auth.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth.c +++ linux-2.6.11-rc3/net/sunrpc/auth.c @@ -129,7 +129,6 @@ rpcauth_free_credcache(struct rpc_auth * for (i = 0; i < RPC_CREDCACHE_NR; i++) { list_for_each_safe(pos, next, &auth->au_credcache[i]) { cred = list_entry(pos, struct rpc_cred, cr_hash); - cred->cr_auth = NULL; list_move(&cred->cr_hash, &free); } } @@ -138,16 +137,14 @@ rpcauth_free_credcache(struct rpc_auth * } static void -rpcauth_prune_expired(struct rpc_cred *cred, struct list_head *free) +rpcauth_prune_expired(struct rpc_auth *auth, struct rpc_cred *cred, struct list_head *free) { if (atomic_read(&cred->cr_count) != 1) return; - if (time_after(jiffies, cred->cr_expire + cred->cr_auth->au_expire)) + if (time_after(jiffies, cred->cr_expire + auth->au_expire)) cred->cr_flags &= ~RPCAUTH_CRED_UPTODATE; - if (!(cred->cr_flags & RPCAUTH_CRED_UPTODATE)) { - cred->cr_auth = NULL; + if (!(cred->cr_flags & RPCAUTH_CRED_UPTODATE)) list_move(&cred->cr_hash, free); - } } /* @@ -164,7 +161,7 @@ rpcauth_gc_credcache(struct rpc_auth *au for (i = 0; i < RPC_CREDCACHE_NR; i++) { list_for_each_safe(pos, next, &auth->au_credcache[i]) { cred = list_entry(pos, struct rpc_cred, cr_hash); - rpcauth_prune_expired(cred, free); + rpcauth_prune_expired(auth, cred, free); } } auth->au_nextgc = jiffies + auth->au_expire; @@ -197,7 +194,7 @@ retry: cred = entry; break; } - rpcauth_prune_expired(entry, &free); + rpcauth_prune_expired(auth, entry, &free); } if (new) { if (cred) @@ -207,7 +204,6 @@ retry: } if (cred) { list_add(&cred->cr_hash, &auth->au_credcache[nr]); - cred->cr_auth = auth; get_rpccred(cred); } spin_unlock(&rpc_credcache_lock); @@ -328,7 +324,7 @@ rpcauth_wrap_req(struct rpc_task *task, struct rpc_cred *cred = task->tk_msg.rpc_cred; dprintk("RPC: %4d using %s cred %p to wrap rpc data\n", - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); + task->tk_pid, cred->cr_ops->cr_name, cred); if (cred->cr_ops->crwrap_req) return cred->cr_ops->crwrap_req(task, encode, rqstp, data, obj); /* By default, we encode the arguments normally. */ @@ -342,7 +338,7 @@ rpcauth_unwrap_resp(struct rpc_task *tas struct rpc_cred *cred = task->tk_msg.rpc_cred; dprintk("RPC: %4d using %s cred %p to unwrap rpc data\n", - task->tk_pid, cred->cr_auth->au_ops->au_name, cred); + task->tk_pid, cred->cr_ops->cr_name, cred); if (cred->cr_ops->crunwrap_resp) return cred->cr_ops->crunwrap_resp(task, decode, rqstp, data, obj); Index: linux-2.6.11-rc3/net/sunrpc/auth_null.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth_null.c +++ linux-2.6.11-rc3/net/sunrpc/auth_null.c @@ -150,6 +150,7 @@ struct rpc_authops authnull_ops = { static struct rpc_credops null_credops = { + .cr_name = "AUTH_NULL", .crdestroy = nul_destroy_cred, .crmatch = nul_match, .crmarshal = nul_marshal, Index: linux-2.6.11-rc3/net/sunrpc/auth_unix.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth_unix.c +++ linux-2.6.11-rc3/net/sunrpc/auth_unix.c @@ -240,6 +240,7 @@ struct rpc_authops authunix_ops = { static struct rpc_credops unix_credops = { + .cr_name = "AUTH_UNIX", .crdestroy = unx_destroy_cred, .crmatch = unx_match, .crmarshal = unx_marshal, Index: linux-2.6.11-rc3/include/linux/sunrpc/auth.h =================================================================== --- linux-2.6.11-rc3.orig/include/linux/sunrpc/auth.h +++ linux-2.6.11-rc3/include/linux/sunrpc/auth.h @@ -36,7 +36,6 @@ struct auth_cred { */ struct rpc_cred { struct list_head cr_hash; /* hash chain */ - struct rpc_auth * cr_auth; struct rpc_credops * cr_ops; unsigned long cr_expire; /* when to gc */ atomic_t cr_count; /* ref count */ @@ -96,6 +95,7 @@ struct rpc_authops { }; struct rpc_credops { + const char * cr_name; /* Name of the auth flavour */ void (*crdestroy)(struct rpc_cred *); int (*crmatch)(struct auth_cred *, struct rpc_cred *, int); Index: linux-2.6.11-rc3/net/sunrpc/auth_gss/auth_gss.c =================================================================== --- linux-2.6.11-rc3.orig/net/sunrpc/auth_gss/auth_gss.c +++ linux-2.6.11-rc3/net/sunrpc/auth_gss/auth_gss.c @@ -1018,6 +1018,7 @@ static struct rpc_authops authgss_ops = }; static struct rpc_credops gss_credops = { + .cr_name = "AUTH_GSS", .crdestroy = gss_destroy_cred, .crmatch = gss_match, .crmarshal = gss_marshal,