aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorBenny Halevy <bhalevy@panasas.com>2009-04-01 09:22:09 -0400
committerBenny Halevy <bhalevy@panasas.com>2009-06-17 13:46:34 -0400
commit28f566942c6b1d929f5e240e69e7081b77b238d3 (patch)
tree65b60263ac95d17de9a68f5245b52070d2bfb2e1 /fs/nfs/nfs4xdr.c
parentdadf0c2767ce7772fc4ff82044f3ba5823e5b79f (diff)
NFS: use dynamically computed compound_hdr.replen for xdr_inline_pages offset
As Trond suggested, rather than passing a constant to xdr_inline_pages, keep a running count of the expected reply bytes. In preparation for nfs41, where additional op sequence are expteced when talking to nfs41 servers. [NFS: cb_compoundhdr.replen is in words not bytes] Signed-off-by: Benny Halevy <bhalevy@panasas.com> [nfs41: get fs_locations replen before encoding the GETATTR] Signed-off-by: Benny Halevy <bhalevy@panasas.com> [nfs41: get getacl replen before encoding the GETATTR] Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c48
1 files changed, 10 insertions, 38 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 746c6a52794c..68889469d114 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1721,20 +1721,13 @@ static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct n
1721 struct compound_hdr hdr = { 1721 struct compound_hdr hdr = {
1722 .nops = 0, 1722 .nops = 0,
1723 }; 1723 };
1724 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1725 unsigned int replen;
1726 1724
1727 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1725 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1728 encode_compound_hdr(&xdr, req, &hdr); 1726 encode_compound_hdr(&xdr, req, &hdr);
1729 encode_putfh(&xdr, args->fh, &hdr); 1727 encode_putfh(&xdr, args->fh, &hdr);
1730 encode_readlink(&xdr, args, req, &hdr); 1728 encode_readlink(&xdr, args, req, &hdr);
1731 1729
1732 /* set up reply kvec 1730 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
1733 * toplevel_status + taglen + rescount + OP_PUTFH + status
1734 * + OP_READLINK + status + string length = 8
1735 */
1736 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readlink_sz) << 2;
1737 xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages,
1738 args->pgbase, args->pglen); 1731 args->pgbase, args->pglen);
1739 encode_nops(&hdr); 1732 encode_nops(&hdr);
1740 return 0; 1733 return 0;
@@ -1749,23 +1742,16 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
1749 struct compound_hdr hdr = { 1742 struct compound_hdr hdr = {
1750 .nops = 0, 1743 .nops = 0,
1751 }; 1744 };
1752 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1753 int replen;
1754 1745
1755 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1746 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1756 encode_compound_hdr(&xdr, req, &hdr); 1747 encode_compound_hdr(&xdr, req, &hdr);
1757 encode_putfh(&xdr, args->fh, &hdr); 1748 encode_putfh(&xdr, args->fh, &hdr);
1758 encode_readdir(&xdr, args, req, &hdr); 1749 encode_readdir(&xdr, args, req, &hdr);
1759 1750
1760 /* set up reply kvec 1751 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
1761 * toplevel_status + taglen + rescount + OP_PUTFH + status
1762 * + OP_READDIR + status + verifer(2) = 9
1763 */
1764 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readdir_sz) << 2;
1765 xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages,
1766 args->pgbase, args->count); 1752 args->pgbase, args->count);
1767 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n", 1753 dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
1768 __func__, replen, args->pages, 1754 __func__, hdr.replen << 2, args->pages,
1769 args->pgbase, args->count); 1755 args->pgbase, args->count);
1770 encode_nops(&hdr); 1756 encode_nops(&hdr);
1771 return 0; 1757 return 0;
@@ -1776,24 +1762,17 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
1776 */ 1762 */
1777static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) 1763static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args)
1778{ 1764{
1779 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1780 struct xdr_stream xdr; 1765 struct xdr_stream xdr;
1781 struct compound_hdr hdr = { 1766 struct compound_hdr hdr = {
1782 .nops = 0, 1767 .nops = 0,
1783 }; 1768 };
1784 int replen;
1785 1769
1786 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1770 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1787 encode_compound_hdr(&xdr, req, &hdr); 1771 encode_compound_hdr(&xdr, req, &hdr);
1788 encode_putfh(&xdr, args->fh, &hdr); 1772 encode_putfh(&xdr, args->fh, &hdr);
1789 encode_read(&xdr, args, &hdr); 1773 encode_read(&xdr, args, &hdr);
1790 1774
1791 /* set up reply kvec 1775 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
1792 * toplevel status + taglen=0 + rescount + OP_PUTFH + status
1793 * + OP_READ + status + eof + datalen = 9
1794 */
1795 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_read_sz) << 2;
1796 xdr_inline_pages(&req->rq_rcv_buf, replen,
1797 args->pages, args->pgbase, args->count); 1776 args->pages, args->pgbase, args->count);
1798 req->rq_rcv_buf.flags |= XDRBUF_READ; 1777 req->rq_rcv_buf.flags |= XDRBUF_READ;
1799 encode_nops(&hdr); 1778 encode_nops(&hdr);
@@ -1827,20 +1806,18 @@ nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p,
1827 struct nfs_getaclargs *args) 1806 struct nfs_getaclargs *args)
1828{ 1807{
1829 struct xdr_stream xdr; 1808 struct xdr_stream xdr;
1830 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
1831 struct compound_hdr hdr = { 1809 struct compound_hdr hdr = {
1832 .nops = 0, 1810 .nops = 0,
1833 }; 1811 };
1834 int replen; 1812 uint32_t replen;
1835 1813
1836 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1814 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
1837 encode_compound_hdr(&xdr, req, &hdr); 1815 encode_compound_hdr(&xdr, req, &hdr);
1838 encode_putfh(&xdr, args->fh, &hdr); 1816 encode_putfh(&xdr, args->fh, &hdr);
1817 replen = hdr.replen + nfs4_fattr_bitmap_maxsz + 1;
1839 encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); 1818 encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr);
1840 1819
1841 /* set up reply buffer: */ 1820 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
1842 replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_getacl_sz) << 2;
1843 xdr_inline_pages(&req->rq_rcv_buf, replen,
1844 args->acl_pages, args->acl_pgbase, args->acl_len); 1821 args->acl_pages, args->acl_pgbase, args->acl_len);
1845 encode_nops(&hdr); 1822 encode_nops(&hdr);
1846 return 0; 1823 return 0;
@@ -2045,21 +2022,16 @@ static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs
2045 struct compound_hdr hdr = { 2022 struct compound_hdr hdr = {
2046 .nops = 0, 2023 .nops = 0,
2047 }; 2024 };
2048 struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth; 2025 uint32_t replen;
2049 int replen;
2050 2026
2051 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2027 xdr_init_encode(&xdr, &req->rq_snd_buf, p);
2052 encode_compound_hdr(&xdr, req, &hdr); 2028 encode_compound_hdr(&xdr, req, &hdr);
2053 encode_putfh(&xdr, args->dir_fh, &hdr); 2029 encode_putfh(&xdr, args->dir_fh, &hdr);
2054 encode_lookup(&xdr, args->name, &hdr); 2030 encode_lookup(&xdr, args->name, &hdr);
2031 replen = hdr.replen; /* get the attribute into args->page */
2055 encode_fs_locations(&xdr, args->bitmask, &hdr); 2032 encode_fs_locations(&xdr, args->bitmask, &hdr);
2056 2033
2057 /* set up reply 2034 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page,
2058 * toplevel_status + OP_PUTFH + status
2059 * + OP_LOOKUP + status + OP_GETATTR + status = 7
2060 */
2061 replen = (RPC_REPHDRSIZE + auth->au_rslack + 7) << 2;
2062 xdr_inline_pages(&req->rq_rcv_buf, replen, &args->page,
2063 0, PAGE_SIZE); 2035 0, PAGE_SIZE);
2064 encode_nops(&hdr); 2036 encode_nops(&hdr);
2065 return 0; 2037 return 0;