Commit cb18eca4 authored by Chuck Lever's avatar Chuck Lever

NFSD: Remove svc_rqst::rq_cacherep

Over time I'd like to see NFS-specific fields moved out of struct
svc_rqst, which is an RPC layer object. These fields are layering
violations.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent c135e126
...@@ -84,8 +84,10 @@ int nfsd_net_reply_cache_init(struct nfsd_net *nn); ...@@ -84,8 +84,10 @@ int nfsd_net_reply_cache_init(struct nfsd_net *nn);
void nfsd_net_reply_cache_destroy(struct nfsd_net *nn); void nfsd_net_reply_cache_destroy(struct nfsd_net *nn);
int nfsd_reply_cache_init(struct nfsd_net *); int nfsd_reply_cache_init(struct nfsd_net *);
void nfsd_reply_cache_shutdown(struct nfsd_net *); void nfsd_reply_cache_shutdown(struct nfsd_net *);
int nfsd_cache_lookup(struct svc_rqst *); int nfsd_cache_lookup(struct svc_rqst *rqstp,
void nfsd_cache_update(struct svc_rqst *, int, __be32 *); struct svc_cacherep **cacherep);
void nfsd_cache_update(struct svc_rqst *rqstp, struct svc_cacherep *rp,
int cachetype, __be32 *statp);
int nfsd_reply_cache_stats_show(struct seq_file *m, void *v); int nfsd_reply_cache_stats_show(struct seq_file *m, void *v);
#endif /* NFSCACHE_H */ #endif /* NFSCACHE_H */
...@@ -465,6 +465,7 @@ nfsd_cache_insert(struct nfsd_drc_bucket *b, struct svc_cacherep *key, ...@@ -465,6 +465,7 @@ nfsd_cache_insert(struct nfsd_drc_bucket *b, struct svc_cacherep *key,
/** /**
* nfsd_cache_lookup - Find an entry in the duplicate reply cache * nfsd_cache_lookup - Find an entry in the duplicate reply cache
* @rqstp: Incoming Call to find * @rqstp: Incoming Call to find
* @cacherep: OUT: DRC entry for this request
* *
* Try to find an entry matching the current call in the cache. When none * Try to find an entry matching the current call in the cache. When none
* is found, we try to grab the oldest expired entry off the LRU list. If * is found, we try to grab the oldest expired entry off the LRU list. If
...@@ -477,7 +478,7 @@ nfsd_cache_insert(struct nfsd_drc_bucket *b, struct svc_cacherep *key, ...@@ -477,7 +478,7 @@ nfsd_cache_insert(struct nfsd_drc_bucket *b, struct svc_cacherep *key,
* %RC_REPLY: Reply from cache * %RC_REPLY: Reply from cache
* %RC_DROPIT: Do not process the request further * %RC_DROPIT: Do not process the request further
*/ */
int nfsd_cache_lookup(struct svc_rqst *rqstp) int nfsd_cache_lookup(struct svc_rqst *rqstp, struct svc_cacherep **cacherep)
{ {
struct nfsd_net *nn; struct nfsd_net *nn;
struct svc_cacherep *rp, *found; struct svc_cacherep *rp, *found;
...@@ -488,7 +489,6 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp) ...@@ -488,7 +489,6 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp)
LIST_HEAD(dispose); LIST_HEAD(dispose);
int rtn = RC_DOIT; int rtn = RC_DOIT;
rqstp->rq_cacherep = NULL;
if (type == RC_NOCACHE) { if (type == RC_NOCACHE) {
nfsd_stats_rc_nocache_inc(); nfsd_stats_rc_nocache_inc();
goto out; goto out;
...@@ -510,7 +510,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp) ...@@ -510,7 +510,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp)
found = nfsd_cache_insert(b, rp, nn); found = nfsd_cache_insert(b, rp, nn);
if (found != rp) if (found != rp)
goto found_entry; goto found_entry;
rqstp->rq_cacherep = rp; *cacherep = rp;
rp->c_state = RC_INPROG; rp->c_state = RC_INPROG;
nfsd_prune_bucket_locked(nn, b, 3, &dispose); nfsd_prune_bucket_locked(nn, b, 3, &dispose);
spin_unlock(&b->cache_lock); spin_unlock(&b->cache_lock);
...@@ -568,6 +568,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp) ...@@ -568,6 +568,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp)
/** /**
* nfsd_cache_update - Update an entry in the duplicate reply cache. * nfsd_cache_update - Update an entry in the duplicate reply cache.
* @rqstp: svc_rqst with a finished Reply * @rqstp: svc_rqst with a finished Reply
* @rp: IN: DRC entry for this request
* @cachetype: which cache to update * @cachetype: which cache to update
* @statp: pointer to Reply's NFS status code, or NULL * @statp: pointer to Reply's NFS status code, or NULL
* *
...@@ -585,10 +586,10 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp) ...@@ -585,10 +586,10 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp)
* nfsd failed to encode a reply that otherwise would have been cached. * nfsd failed to encode a reply that otherwise would have been cached.
* In this case, nfsd_cache_update is called with statp == NULL. * In this case, nfsd_cache_update is called with statp == NULL.
*/ */
void nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp) void nfsd_cache_update(struct svc_rqst *rqstp, struct svc_cacherep *rp,
int cachetype, __be32 *statp)
{ {
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id); struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
struct svc_cacherep *rp = rqstp->rq_cacherep;
struct kvec *resv = &rqstp->rq_res.head[0], *cachv; struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
struct nfsd_drc_bucket *b; struct nfsd_drc_bucket *b;
int len; int len;
......
...@@ -1046,6 +1046,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp) ...@@ -1046,6 +1046,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp)
{ {
const struct svc_procedure *proc = rqstp->rq_procinfo; const struct svc_procedure *proc = rqstp->rq_procinfo;
__be32 *statp = rqstp->rq_accept_statp; __be32 *statp = rqstp->rq_accept_statp;
struct svc_cacherep *rp;
/* /*
* Give the xdr decoder a chance to change this if it wants * Give the xdr decoder a chance to change this if it wants
...@@ -1056,7 +1057,8 @@ int nfsd_dispatch(struct svc_rqst *rqstp) ...@@ -1056,7 +1057,8 @@ int nfsd_dispatch(struct svc_rqst *rqstp)
if (!proc->pc_decode(rqstp, &rqstp->rq_arg_stream)) if (!proc->pc_decode(rqstp, &rqstp->rq_arg_stream))
goto out_decode_err; goto out_decode_err;
switch (nfsd_cache_lookup(rqstp)) { rp = NULL;
switch (nfsd_cache_lookup(rqstp, &rp)) {
case RC_DOIT: case RC_DOIT:
break; break;
case RC_REPLY: case RC_REPLY:
...@@ -1072,7 +1074,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp) ...@@ -1072,7 +1074,7 @@ int nfsd_dispatch(struct svc_rqst *rqstp)
if (!proc->pc_encode(rqstp, &rqstp->rq_res_stream)) if (!proc->pc_encode(rqstp, &rqstp->rq_res_stream))
goto out_encode_err; goto out_encode_err;
nfsd_cache_update(rqstp, rqstp->rq_cachetype, statp + 1); nfsd_cache_update(rqstp, rp, rqstp->rq_cachetype, statp + 1);
out_cached_reply: out_cached_reply:
return 1; return 1;
...@@ -1082,13 +1084,13 @@ int nfsd_dispatch(struct svc_rqst *rqstp) ...@@ -1082,13 +1084,13 @@ int nfsd_dispatch(struct svc_rqst *rqstp)
return 1; return 1;
out_update_drop: out_update_drop:
nfsd_cache_update(rqstp, RC_NOCACHE, NULL); nfsd_cache_update(rqstp, rp, RC_NOCACHE, NULL);
out_dropit: out_dropit:
return 0; return 0;
out_encode_err: out_encode_err:
trace_nfsd_cant_encode_err(rqstp); trace_nfsd_cant_encode_err(rqstp);
nfsd_cache_update(rqstp, RC_NOCACHE, NULL); nfsd_cache_update(rqstp, rp, RC_NOCACHE, NULL);
*statp = rpc_system_err; *statp = rpc_system_err;
return 1; return 1;
} }
......
...@@ -265,7 +265,6 @@ struct svc_rqst { ...@@ -265,7 +265,6 @@ struct svc_rqst {
/* Catering to nfsd */ /* Catering to nfsd */
struct auth_domain * rq_client; /* RPC peer info */ struct auth_domain * rq_client; /* RPC peer info */
struct auth_domain * rq_gssclient; /* "gss/"-style peer info */ struct auth_domain * rq_gssclient; /* "gss/"-style peer info */
struct svc_cacherep * rq_cacherep; /* cache info */
struct task_struct *rq_task; /* service thread */ struct task_struct *rq_task; /* service thread */
struct net *rq_bc_net; /* pointer to backchannel's struct net *rq_bc_net; /* pointer to backchannel's
* net namespace * net namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment