NFSD: Save location of NFSv4 COMPOUND status
authorChuck Lever <chuck.lever@oracle.com>
Wed, 13 Oct 2021 14:40:59 +0000 (10:40 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 13 Oct 2021 15:34:49 +0000 (11:34 -0400)
Refactor: Currently nfs4svc_encode_compoundres() relies on the NFS
dispatcher to pass in the buffer location of the COMPOUND status.
Instead, save that buffer location in struct nfsd4_compoundres.

The compound tag follows immediately after.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4proc.c
fs/nfsd/nfs4xdr.c
fs/nfsd/xdr4.h

index 5895bbeba373b8be07748f83394bcf200cc64429..a36261f89bdfac91a528153105cace78236faeb4 100644 (file)
@@ -2461,11 +2461,11 @@ nfsd4_proc_compound(struct svc_rqst *rqstp)
        __be32          status;
 
        resp->xdr = &rqstp->rq_res_stream;
+       resp->statusp = resp->xdr->p;
 
        /* reserve space for: NFS status code */
        xdr_reserve_space(resp->xdr, XDR_UNIT);
 
-       resp->tagp = resp->xdr->p;
        /* reserve space for: taglen, tag, and opcnt */
        xdr_reserve_space(resp->xdr, XDR_UNIT * 2 + args->taglen);
        resp->taglen = args->taglen;
index dd1ee9ada7ddd7042782adea7afb2b9125a83e05..c6623080ad9858f288f0b1bb515652fde0d8c632 100644 (file)
@@ -5435,11 +5435,16 @@ nfs4svc_encode_compoundres(struct svc_rqst *rqstp, __be32 *p)
        WARN_ON_ONCE(buf->len != buf->head[0].iov_len + buf->page_len +
                                 buf->tail[0].iov_len);
 
-       *p = resp->cstate.status;
+       /*
+        * Send buffer space for the following items is reserved
+        * at the top of nfsd4_proc_compound().
+        */
+       p = resp->statusp;
+
+       *p++ = resp->cstate.status;
 
        rqstp->rq_next_page = resp->xdr->page_ptr + 1;
 
-       p = resp->tagp;
        *p++ = htonl(resp->taglen);
        memcpy(p, resp->tag, resp->taglen);
        p += XDR_QUADLEN(resp->taglen);
index 8812256cd520f7cd504e0ae271f3cde9f3b3b99c..6aeb6755278f538cc33a76f1b040f80129ea7d5e 100644 (file)
@@ -702,10 +702,11 @@ struct nfsd4_compoundres {
        struct xdr_stream               *xdr;
        struct svc_rqst *               rqstp;
 
+       __be32                          *statusp;
        u32                             taglen;
        char *                          tag;
        u32                             opcnt;
-       __be32 *                        tagp; /* tag, opcount encode location */
+
        struct nfsd4_compound_state     cstate;
 };