nfsd41: nfsd DRC logic
authorAndy Adamson <andros@netapp.com>
Fri, 3 Apr 2009 05:28:22 +0000 (08:28 +0300)
committerJ. Bruce Fields <bfields@citi.umich.edu>
Sat, 4 Apr 2009 00:41:17 +0000 (17:41 -0700)
Replay a request in nfsd4_sequence.
Add a minorversion to struct nfsd4_compound_state.

Pass the current slot to nfs4svc_encode_compound res via struct
nfsd4_compoundres to set an NFSv4.1 DRC entry.

Signed-off-by: Andy Adamson<andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfsd41: use bool inuse for slot state]
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
[nfsd41: use cstate session in nfs4svc_encode_compoundres]
[nfsd41 replace nfsd4_set_cache_entry]
Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4state.c
fs/nfsd/nfs4xdr.c
include/linux/nfsd/xdr4.h

index ec51936d2ce2e9bdfbdddd85a2ca1d3f3c1510c0..9e2ee75e0f7cd30c5496119b99fb9c523a81fa0d 100644 (file)
@@ -936,6 +936,12 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
                        BUG_ON(op->status == nfs_ok);
 
 encode_op:
+               /* Only from SEQUENCE or CREATE_SESSION */
+               if (resp->cstate.status == nfserr_replay_cache) {
+                       dprintk("%s NFS4.1 replay from cache\n", __func__);
+                       status = op->status;
+                       goto out;
+               }
                if (op->status == nfserr_replay_me) {
                        op->replay = &cstate->replay_owner->so_replay;
                        nfsd4_encode_replay(resp, op);
@@ -964,6 +970,7 @@ encode_op:
                status = nfserr_jukebox;
        }
 
+       resp->cstate.status = status;
        fh_put(&resp->cstate.current_fh);
        fh_put(&resp->cstate.save_fh);
        BUG_ON(resp->cstate.replay_owner);
index a37b91dab1bf239634360ef21d9d14dfc02dc64f..e20d4345040fe5a62ceeb0219f3ea38eef2b6f99 100644 (file)
@@ -989,6 +989,8 @@ nfsd4_replay_cache_entry(struct nfsd4_compoundres *resp)
        }
 
        resp->rqstp->rq_resused = entry->ce_resused;
+       resp->opcnt = entry->ce_opcnt;
+       resp->cstate.iovlen = entry->ce_datav.iov_len + entry->ce_rpchdrlen;
        status = entry->ce_status;
 
        return status;
@@ -1214,6 +1216,10 @@ nfsd4_sequence(struct svc_rqst *rqstp,
        if (status == nfserr_replay_cache) {
                cstate->slot = slot;
                cstate->session = session;
+               /* Return the cached reply status and set cstate->status
+                * for nfsd4_svc_encode_compoundres processing*/
+               status = nfsd4_replay_cache_entry(resp);
+               cstate->status = nfserr_replay_cache;
                goto replay_cache;
        }
        if (status)
index 8556575480ce81b71b9b9a5c927653b9dd2cd093..09415bcf078e3b0fcaed2cf0d3ca2e3a25d506b5 100644 (file)
@@ -3049,6 +3049,17 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compo
                iov = &rqstp->rq_res.head[0];
        iov->iov_len = ((char*)resp->p) - (char*)iov->iov_base;
        BUG_ON(iov->iov_len > PAGE_SIZE);
+       if (resp->cstate.slot != NULL) {
+               if (resp->cstate.status == nfserr_replay_cache) {
+                       iov->iov_len = resp->cstate.iovlen;
+               } else {
+                       nfsd4_store_cache_entry(resp);
+                       dprintk("%s: SET SLOT STATE TO AVAILABLE\n", __func__);
+                       resp->cstate.slot->sl_inuse = 0;
+               }
+               if (resp->cstate.session)
+                       nfsd4_put_session(resp->cstate.session);
+       }
        return 1;
 }
 
index d091684325afcda55b47c8ea3acaaae08559c54b..69cb467cb720b1a50a014f8535434f5181548db4 100644 (file)
@@ -52,6 +52,7 @@ struct nfsd4_compound_state {
        struct nfsd4_session    *session;
        struct nfsd4_slot       *slot;
        __be32                  *statp;
+       size_t                  iovlen;
        u32                     status;
 };