aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2010-12-14 09:59:18 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-12-16 12:37:25 -0500
commit9f06c719f474be7003763284a990bed6377bb0d4 (patch)
tree409ebc3505f943bfdb933ab0acd76ffb5347b372 /fs/nfs/nfs4xdr.c
parent1ac7c23e4af5e83525137661595000099f1ce94f (diff)
SUNRPC: New xdr_streams XDR encoder API
Now that all client-side XDR encoder routines use xdr_streams, there should be no need to support the legacy calling sequence [rpc_rqst *, __be32 *, RPC arg *] anywhere. We can construct an xdr_stream in the generic RPC code, instead of in each encoder function. Also, all the client-side encoder functions return 0 now, making a return value superfluous. Take this opportunity to convert them to return void instead. This is a refactoring change. It should not cause different behavior. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Tested-by: J. Bruce Fields <bfields@redhat.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c663
1 files changed, 291 insertions, 372 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index a15fe99fea86..6ec38b3e4a3d 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1510,7 +1510,7 @@ encode_restorefh(struct xdr_stream *xdr, struct compound_hdr *hdr)
1510 hdr->replen += decode_restorefh_maxsz; 1510 hdr->replen += decode_restorefh_maxsz;
1511} 1511}
1512 1512
1513static int 1513static void
1514encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr) 1514encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compound_hdr *hdr)
1515{ 1515{
1516 __be32 *p; 1516 __be32 *p;
@@ -1521,14 +1521,12 @@ encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg, struct compoun
1521 p = reserve_space(xdr, 2*4); 1521 p = reserve_space(xdr, 2*4);
1522 *p++ = cpu_to_be32(1); 1522 *p++ = cpu_to_be32(1);
1523 *p = cpu_to_be32(FATTR4_WORD0_ACL); 1523 *p = cpu_to_be32(FATTR4_WORD0_ACL);
1524 if (arg->acl_len % 4) 1524 BUG_ON(arg->acl_len % 4);
1525 return -EINVAL;
1526 p = reserve_space(xdr, 4); 1525 p = reserve_space(xdr, 4);
1527 *p = cpu_to_be32(arg->acl_len); 1526 *p = cpu_to_be32(arg->acl_len);
1528 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len); 1527 xdr_write_pages(xdr, arg->acl_pages, arg->acl_pgbase, arg->acl_len);
1529 hdr->nops++; 1528 hdr->nops++;
1530 hdr->replen += decode_setacl_maxsz; 1529 hdr->replen += decode_setacl_maxsz;
1531 return 0;
1532} 1530}
1533 1531
1534static void 1532static void
@@ -1833,393 +1831,362 @@ static u32 nfs4_xdr_minorversion(const struct nfs4_sequence_args *args)
1833/* 1831/*
1834 * Encode an ACCESS request 1832 * Encode an ACCESS request
1835 */ 1833 */
1836static int nfs4_xdr_enc_access(struct rpc_rqst *req, __be32 *p, const struct nfs4_accessargs *args) 1834static void nfs4_xdr_enc_access(struct rpc_rqst *req, struct xdr_stream *xdr,
1835 const struct nfs4_accessargs *args)
1837{ 1836{
1838 struct xdr_stream xdr;
1839 struct compound_hdr hdr = { 1837 struct compound_hdr hdr = {
1840 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1838 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1841 }; 1839 };
1842 1840
1843 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1841 encode_compound_hdr(xdr, req, &hdr);
1844 encode_compound_hdr(&xdr, req, &hdr); 1842 encode_sequence(xdr, &args->seq_args, &hdr);
1845 encode_sequence(&xdr, &args->seq_args, &hdr); 1843 encode_putfh(xdr, args->fh, &hdr);
1846 encode_putfh(&xdr, args->fh, &hdr); 1844 encode_access(xdr, args->access, &hdr);
1847 encode_access(&xdr, args->access, &hdr); 1845 encode_getfattr(xdr, args->bitmask, &hdr);
1848 encode_getfattr(&xdr, args->bitmask, &hdr);
1849 encode_nops(&hdr); 1846 encode_nops(&hdr);
1850 return 0;
1851} 1847}
1852 1848
1853/* 1849/*
1854 * Encode LOOKUP request 1850 * Encode LOOKUP request
1855 */ 1851 */
1856static int nfs4_xdr_enc_lookup(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_arg *args) 1852static void nfs4_xdr_enc_lookup(struct rpc_rqst *req, struct xdr_stream *xdr,
1853 const struct nfs4_lookup_arg *args)
1857{ 1854{
1858 struct xdr_stream xdr;
1859 struct compound_hdr hdr = { 1855 struct compound_hdr hdr = {
1860 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1856 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1861 }; 1857 };
1862 1858
1863 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1859 encode_compound_hdr(xdr, req, &hdr);
1864 encode_compound_hdr(&xdr, req, &hdr); 1860 encode_sequence(xdr, &args->seq_args, &hdr);
1865 encode_sequence(&xdr, &args->seq_args, &hdr); 1861 encode_putfh(xdr, args->dir_fh, &hdr);
1866 encode_putfh(&xdr, args->dir_fh, &hdr); 1862 encode_lookup(xdr, args->name, &hdr);
1867 encode_lookup(&xdr, args->name, &hdr); 1863 encode_getfh(xdr, &hdr);
1868 encode_getfh(&xdr, &hdr); 1864 encode_getfattr(xdr, args->bitmask, &hdr);
1869 encode_getfattr(&xdr, args->bitmask, &hdr);
1870 encode_nops(&hdr); 1865 encode_nops(&hdr);
1871 return 0;
1872} 1866}
1873 1867
1874/* 1868/*
1875 * Encode LOOKUP_ROOT request 1869 * Encode LOOKUP_ROOT request
1876 */ 1870 */
1877static int nfs4_xdr_enc_lookup_root(struct rpc_rqst *req, __be32 *p, const struct nfs4_lookup_root_arg *args) 1871static void nfs4_xdr_enc_lookup_root(struct rpc_rqst *req,
1872 struct xdr_stream *xdr,
1873 const struct nfs4_lookup_root_arg *args)
1878{ 1874{
1879 struct xdr_stream xdr;
1880 struct compound_hdr hdr = { 1875 struct compound_hdr hdr = {
1881 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1876 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1882 }; 1877 };
1883 1878
1884 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1879 encode_compound_hdr(xdr, req, &hdr);
1885 encode_compound_hdr(&xdr, req, &hdr); 1880 encode_sequence(xdr, &args->seq_args, &hdr);
1886 encode_sequence(&xdr, &args->seq_args, &hdr); 1881 encode_putrootfh(xdr, &hdr);
1887 encode_putrootfh(&xdr, &hdr); 1882 encode_getfh(xdr, &hdr);
1888 encode_getfh(&xdr, &hdr); 1883 encode_getfattr(xdr, args->bitmask, &hdr);
1889 encode_getfattr(&xdr, args->bitmask, &hdr);
1890 encode_nops(&hdr); 1884 encode_nops(&hdr);
1891 return 0;
1892} 1885}
1893 1886
1894/* 1887/*
1895 * Encode REMOVE request 1888 * Encode REMOVE request
1896 */ 1889 */
1897static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args) 1890static void nfs4_xdr_enc_remove(struct rpc_rqst *req, struct xdr_stream *xdr,
1891 const struct nfs_removeargs *args)
1898{ 1892{
1899 struct xdr_stream xdr;
1900 struct compound_hdr hdr = { 1893 struct compound_hdr hdr = {
1901 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1894 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1902 }; 1895 };
1903 1896
1904 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1897 encode_compound_hdr(xdr, req, &hdr);
1905 encode_compound_hdr(&xdr, req, &hdr); 1898 encode_sequence(xdr, &args->seq_args, &hdr);
1906 encode_sequence(&xdr, &args->seq_args, &hdr); 1899 encode_putfh(xdr, args->fh, &hdr);
1907 encode_putfh(&xdr, args->fh, &hdr); 1900 encode_remove(xdr, &args->name, &hdr);
1908 encode_remove(&xdr, &args->name, &hdr); 1901 encode_getfattr(xdr, args->bitmask, &hdr);
1909 encode_getfattr(&xdr, args->bitmask, &hdr);
1910 encode_nops(&hdr); 1902 encode_nops(&hdr);
1911 return 0;
1912} 1903}
1913 1904
1914/* 1905/*
1915 * Encode RENAME request 1906 * Encode RENAME request
1916 */ 1907 */
1917static int nfs4_xdr_enc_rename(struct rpc_rqst *req, __be32 *p, const struct nfs_renameargs *args) 1908static void nfs4_xdr_enc_rename(struct rpc_rqst *req, struct xdr_stream *xdr,
1909 const struct nfs_renameargs *args)
1918{ 1910{
1919 struct xdr_stream xdr;
1920 struct compound_hdr hdr = { 1911 struct compound_hdr hdr = {
1921 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1912 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1922 }; 1913 };
1923 1914
1924 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1915 encode_compound_hdr(xdr, req, &hdr);
1925 encode_compound_hdr(&xdr, req, &hdr); 1916 encode_sequence(xdr, &args->seq_args, &hdr);
1926 encode_sequence(&xdr, &args->seq_args, &hdr); 1917 encode_putfh(xdr, args->old_dir, &hdr);
1927 encode_putfh(&xdr, args->old_dir, &hdr); 1918 encode_savefh(xdr, &hdr);
1928 encode_savefh(&xdr, &hdr); 1919 encode_putfh(xdr, args->new_dir, &hdr);
1929 encode_putfh(&xdr, args->new_dir, &hdr); 1920 encode_rename(xdr, args->old_name, args->new_name, &hdr);
1930 encode_rename(&xdr, args->old_name, args->new_name, &hdr); 1921 encode_getfattr(xdr, args->bitmask, &hdr);
1931 encode_getfattr(&xdr, args->bitmask, &hdr); 1922 encode_restorefh(xdr, &hdr);
1932 encode_restorefh(&xdr, &hdr); 1923 encode_getfattr(xdr, args->bitmask, &hdr);
1933 encode_getfattr(&xdr, args->bitmask, &hdr);
1934 encode_nops(&hdr); 1924 encode_nops(&hdr);
1935 return 0;
1936} 1925}
1937 1926
1938/* 1927/*
1939 * Encode LINK request 1928 * Encode LINK request
1940 */ 1929 */
1941static int nfs4_xdr_enc_link(struct rpc_rqst *req, __be32 *p, const struct nfs4_link_arg *args) 1930static void nfs4_xdr_enc_link(struct rpc_rqst *req, struct xdr_stream *xdr,
1931 const struct nfs4_link_arg *args)
1942{ 1932{
1943 struct xdr_stream xdr;
1944 struct compound_hdr hdr = { 1933 struct compound_hdr hdr = {
1945 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1934 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1946 }; 1935 };
1947 1936
1948 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1937 encode_compound_hdr(xdr, req, &hdr);
1949 encode_compound_hdr(&xdr, req, &hdr); 1938 encode_sequence(xdr, &args->seq_args, &hdr);
1950 encode_sequence(&xdr, &args->seq_args, &hdr); 1939 encode_putfh(xdr, args->fh, &hdr);
1951 encode_putfh(&xdr, args->fh, &hdr); 1940 encode_savefh(xdr, &hdr);
1952 encode_savefh(&xdr, &hdr); 1941 encode_putfh(xdr, args->dir_fh, &hdr);
1953 encode_putfh(&xdr, args->dir_fh, &hdr); 1942 encode_link(xdr, args->name, &hdr);
1954 encode_link(&xdr, args->name, &hdr); 1943 encode_getfattr(xdr, args->bitmask, &hdr);
1955 encode_getfattr(&xdr, args->bitmask, &hdr); 1944 encode_restorefh(xdr, &hdr);
1956 encode_restorefh(&xdr, &hdr); 1945 encode_getfattr(xdr, args->bitmask, &hdr);
1957 encode_getfattr(&xdr, args->bitmask, &hdr);
1958 encode_nops(&hdr); 1946 encode_nops(&hdr);
1959 return 0;
1960} 1947}
1961 1948
1962/* 1949/*
1963 * Encode CREATE request 1950 * Encode CREATE request
1964 */ 1951 */
1965static int nfs4_xdr_enc_create(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args) 1952static void nfs4_xdr_enc_create(struct rpc_rqst *req, struct xdr_stream *xdr,
1953 const struct nfs4_create_arg *args)
1966{ 1954{
1967 struct xdr_stream xdr;
1968 struct compound_hdr hdr = { 1955 struct compound_hdr hdr = {
1969 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1956 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
1970 }; 1957 };
1971 1958
1972 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1959 encode_compound_hdr(xdr, req, &hdr);
1973 encode_compound_hdr(&xdr, req, &hdr); 1960 encode_sequence(xdr, &args->seq_args, &hdr);
1974 encode_sequence(&xdr, &args->seq_args, &hdr); 1961 encode_putfh(xdr, args->dir_fh, &hdr);
1975 encode_putfh(&xdr, args->dir_fh, &hdr); 1962 encode_savefh(xdr, &hdr);
1976 encode_savefh(&xdr, &hdr); 1963 encode_create(xdr, args, &hdr);
1977 encode_create(&xdr, args, &hdr); 1964 encode_getfh(xdr, &hdr);
1978 encode_getfh(&xdr, &hdr); 1965 encode_getfattr(xdr, args->bitmask, &hdr);
1979 encode_getfattr(&xdr, args->bitmask, &hdr); 1966 encode_restorefh(xdr, &hdr);
1980 encode_restorefh(&xdr, &hdr); 1967 encode_getfattr(xdr, args->bitmask, &hdr);
1981 encode_getfattr(&xdr, args->bitmask, &hdr);
1982 encode_nops(&hdr); 1968 encode_nops(&hdr);
1983 return 0;
1984} 1969}
1985 1970
1986/* 1971/*
1987 * Encode SYMLINK request 1972 * Encode SYMLINK request
1988 */ 1973 */
1989static int nfs4_xdr_enc_symlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_create_arg *args) 1974static void nfs4_xdr_enc_symlink(struct rpc_rqst *req, struct xdr_stream *xdr,
1975 const struct nfs4_create_arg *args)
1990{ 1976{
1991 return nfs4_xdr_enc_create(req, p, args); 1977 nfs4_xdr_enc_create(req, xdr, args);
1992} 1978}
1993 1979
1994/* 1980/*
1995 * Encode GETATTR request 1981 * Encode GETATTR request
1996 */ 1982 */
1997static int nfs4_xdr_enc_getattr(struct rpc_rqst *req, __be32 *p, const struct nfs4_getattr_arg *args) 1983static void nfs4_xdr_enc_getattr(struct rpc_rqst *req, struct xdr_stream *xdr,
1984 const struct nfs4_getattr_arg *args)
1998{ 1985{
1999 struct xdr_stream xdr;
2000 struct compound_hdr hdr = { 1986 struct compound_hdr hdr = {
2001 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 1987 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2002 }; 1988 };
2003 1989
2004 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 1990 encode_compound_hdr(xdr, req, &hdr);
2005 encode_compound_hdr(&xdr, req, &hdr); 1991 encode_sequence(xdr, &args->seq_args, &hdr);
2006 encode_sequence(&xdr, &args->seq_args, &hdr); 1992 encode_putfh(xdr, args->fh, &hdr);
2007 encode_putfh(&xdr, args->fh, &hdr); 1993 encode_getfattr(xdr, args->bitmask, &hdr);
2008 encode_getfattr(&xdr, args->bitmask, &hdr);
2009 encode_nops(&hdr); 1994 encode_nops(&hdr);
2010 return 0;
2011} 1995}
2012 1996
2013/* 1997/*
2014 * Encode a CLOSE request 1998 * Encode a CLOSE request
2015 */ 1999 */
2016static int nfs4_xdr_enc_close(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args) 2000static void nfs4_xdr_enc_close(struct rpc_rqst *req, struct xdr_stream *xdr,
2001 struct nfs_closeargs *args)
2017{ 2002{
2018 struct xdr_stream xdr;
2019 struct compound_hdr hdr = { 2003 struct compound_hdr hdr = {
2020 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2004 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2021 }; 2005 };
2022 2006
2023 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2007 encode_compound_hdr(xdr, req, &hdr);
2024 encode_compound_hdr(&xdr, req, &hdr); 2008 encode_sequence(xdr, &args->seq_args, &hdr);
2025 encode_sequence(&xdr, &args->seq_args, &hdr); 2009 encode_putfh(xdr, args->fh, &hdr);
2026 encode_putfh(&xdr, args->fh, &hdr); 2010 encode_close(xdr, args, &hdr);
2027 encode_close(&xdr, args, &hdr); 2011 encode_getfattr(xdr, args->bitmask, &hdr);
2028 encode_getfattr(&xdr, args->bitmask, &hdr);
2029 encode_nops(&hdr); 2012 encode_nops(&hdr);
2030 return 0;
2031} 2013}
2032 2014
2033/* 2015/*
2034 * Encode an OPEN request 2016 * Encode an OPEN request
2035 */ 2017 */
2036static int nfs4_xdr_enc_open(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args) 2018static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr,
2019 struct nfs_openargs *args)
2037{ 2020{
2038 struct xdr_stream xdr;
2039 struct compound_hdr hdr = { 2021 struct compound_hdr hdr = {
2040 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2022 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2041 }; 2023 };
2042 2024
2043 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2025 encode_compound_hdr(xdr, req, &hdr);
2044 encode_compound_hdr(&xdr, req, &hdr); 2026 encode_sequence(xdr, &args->seq_args, &hdr);
2045 encode_sequence(&xdr, &args->seq_args, &hdr); 2027 encode_putfh(xdr, args->fh, &hdr);
2046 encode_putfh(&xdr, args->fh, &hdr); 2028 encode_savefh(xdr, &hdr);
2047 encode_savefh(&xdr, &hdr); 2029 encode_open(xdr, args, &hdr);
2048 encode_open(&xdr, args, &hdr); 2030 encode_getfh(xdr, &hdr);
2049 encode_getfh(&xdr, &hdr); 2031 encode_getfattr(xdr, args->bitmask, &hdr);
2050 encode_getfattr(&xdr, args->bitmask, &hdr); 2032 encode_restorefh(xdr, &hdr);
2051 encode_restorefh(&xdr, &hdr); 2033 encode_getfattr(xdr, args->bitmask, &hdr);
2052 encode_getfattr(&xdr, args->bitmask, &hdr);
2053 encode_nops(&hdr); 2034 encode_nops(&hdr);
2054 return 0;
2055} 2035}
2056 2036
2057/* 2037/*
2058 * Encode an OPEN_CONFIRM request 2038 * Encode an OPEN_CONFIRM request
2059 */ 2039 */
2060static int nfs4_xdr_enc_open_confirm(struct rpc_rqst *req, __be32 *p, struct nfs_open_confirmargs *args) 2040static void nfs4_xdr_enc_open_confirm(struct rpc_rqst *req,
2041 struct xdr_stream *xdr,
2042 struct nfs_open_confirmargs *args)
2061{ 2043{
2062 struct xdr_stream xdr;
2063 struct compound_hdr hdr = { 2044 struct compound_hdr hdr = {
2064 .nops = 0, 2045 .nops = 0,
2065 }; 2046 };
2066 2047
2067 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2048 encode_compound_hdr(xdr, req, &hdr);
2068 encode_compound_hdr(&xdr, req, &hdr); 2049 encode_putfh(xdr, args->fh, &hdr);
2069 encode_putfh(&xdr, args->fh, &hdr); 2050 encode_open_confirm(xdr, args, &hdr);
2070 encode_open_confirm(&xdr, args, &hdr);
2071 encode_nops(&hdr); 2051 encode_nops(&hdr);
2072 return 0;
2073} 2052}
2074 2053
2075/* 2054/*
2076 * Encode an OPEN request with no attributes. 2055 * Encode an OPEN request with no attributes.
2077 */ 2056 */
2078static int nfs4_xdr_enc_open_noattr(struct rpc_rqst *req, __be32 *p, struct nfs_openargs *args) 2057static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req,
2058 struct xdr_stream *xdr,
2059 struct nfs_openargs *args)
2079{ 2060{
2080 struct xdr_stream xdr;
2081 struct compound_hdr hdr = { 2061 struct compound_hdr hdr = {
2082 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2062 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2083 }; 2063 };
2084 2064
2085 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2065 encode_compound_hdr(xdr, req, &hdr);
2086 encode_compound_hdr(&xdr, req, &hdr); 2066 encode_sequence(xdr, &args->seq_args, &hdr);
2087 encode_sequence(&xdr, &args->seq_args, &hdr); 2067 encode_putfh(xdr, args->fh, &hdr);
2088 encode_putfh(&xdr, args->fh, &hdr); 2068 encode_open(xdr, args, &hdr);
2089 encode_open(&xdr, args, &hdr); 2069 encode_getfattr(xdr, args->bitmask, &hdr);
2090 encode_getfattr(&xdr, args->bitmask, &hdr);
2091 encode_nops(&hdr); 2070 encode_nops(&hdr);
2092 return 0;
2093} 2071}
2094 2072
2095/* 2073/*
2096 * Encode an OPEN_DOWNGRADE request 2074 * Encode an OPEN_DOWNGRADE request
2097 */ 2075 */
2098static int nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req, __be32 *p, struct nfs_closeargs *args) 2076static void nfs4_xdr_enc_open_downgrade(struct rpc_rqst *req,
2077 struct xdr_stream *xdr,
2078 struct nfs_closeargs *args)
2099{ 2079{
2100 struct xdr_stream xdr;
2101 struct compound_hdr hdr = { 2080 struct compound_hdr hdr = {
2102 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2081 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2103 }; 2082 };
2104 2083
2105 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2084 encode_compound_hdr(xdr, req, &hdr);
2106 encode_compound_hdr(&xdr, req, &hdr); 2085 encode_sequence(xdr, &args->seq_args, &hdr);
2107 encode_sequence(&xdr, &args->seq_args, &hdr); 2086 encode_putfh(xdr, args->fh, &hdr);
2108 encode_putfh(&xdr, args->fh, &hdr); 2087 encode_open_downgrade(xdr, args, &hdr);
2109 encode_open_downgrade(&xdr, args, &hdr); 2088 encode_getfattr(xdr, args->bitmask, &hdr);
2110 encode_getfattr(&xdr, args->bitmask, &hdr);
2111 encode_nops(&hdr); 2089 encode_nops(&hdr);
2112 return 0;
2113} 2090}
2114 2091
2115/* 2092/*
2116 * Encode a LOCK request 2093 * Encode a LOCK request
2117 */ 2094 */
2118static int nfs4_xdr_enc_lock(struct rpc_rqst *req, __be32 *p, struct nfs_lock_args *args) 2095static void nfs4_xdr_enc_lock(struct rpc_rqst *req, struct xdr_stream *xdr,
2096 struct nfs_lock_args *args)
2119{ 2097{
2120 struct xdr_stream xdr;
2121 struct compound_hdr hdr = { 2098 struct compound_hdr hdr = {
2122 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2099 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2123 }; 2100 };
2124 2101
2125 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2102 encode_compound_hdr(xdr, req, &hdr);
2126 encode_compound_hdr(&xdr, req, &hdr); 2103 encode_sequence(xdr, &args->seq_args, &hdr);
2127 encode_sequence(&xdr, &args->seq_args, &hdr); 2104 encode_putfh(xdr, args->fh, &hdr);
2128 encode_putfh(&xdr, args->fh, &hdr); 2105 encode_lock(xdr, args, &hdr);
2129 encode_lock(&xdr, args, &hdr);
2130 encode_nops(&hdr); 2106 encode_nops(&hdr);
2131 return 0;
2132} 2107}
2133 2108
2134/* 2109/*
2135 * Encode a LOCKT request 2110 * Encode a LOCKT request
2136 */ 2111 */
2137static int nfs4_xdr_enc_lockt(struct rpc_rqst *req, __be32 *p, struct nfs_lockt_args *args) 2112static void nfs4_xdr_enc_lockt(struct rpc_rqst *req, struct xdr_stream *xdr,
2113 struct nfs_lockt_args *args)
2138{ 2114{
2139 struct xdr_stream xdr;
2140 struct compound_hdr hdr = { 2115 struct compound_hdr hdr = {
2141 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2116 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2142 }; 2117 };
2143 2118
2144 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2119 encode_compound_hdr(xdr, req, &hdr);
2145 encode_compound_hdr(&xdr, req, &hdr); 2120 encode_sequence(xdr, &args->seq_args, &hdr);
2146 encode_sequence(&xdr, &args->seq_args, &hdr); 2121 encode_putfh(xdr, args->fh, &hdr);
2147 encode_putfh(&xdr, args->fh, &hdr); 2122 encode_lockt(xdr, args, &hdr);
2148 encode_lockt(&xdr, args, &hdr);
2149 encode_nops(&hdr); 2123 encode_nops(&hdr);
2150 return 0;
2151} 2124}
2152 2125
2153/* 2126/*
2154 * Encode a LOCKU request 2127 * Encode a LOCKU request
2155 */ 2128 */
2156static int nfs4_xdr_enc_locku(struct rpc_rqst *req, __be32 *p, struct nfs_locku_args *args) 2129static void nfs4_xdr_enc_locku(struct rpc_rqst *req, struct xdr_stream *xdr,
2130 struct nfs_locku_args *args)
2157{ 2131{
2158 struct xdr_stream xdr;
2159 struct compound_hdr hdr = { 2132 struct compound_hdr hdr = {
2160 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2133 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2161 }; 2134 };
2162 2135
2163 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2136 encode_compound_hdr(xdr, req, &hdr);
2164 encode_compound_hdr(&xdr, req, &hdr); 2137 encode_sequence(xdr, &args->seq_args, &hdr);
2165 encode_sequence(&xdr, &args->seq_args, &hdr); 2138 encode_putfh(xdr, args->fh, &hdr);
2166 encode_putfh(&xdr, args->fh, &hdr); 2139 encode_locku(xdr, args, &hdr);
2167 encode_locku(&xdr, args, &hdr);
2168 encode_nops(&hdr); 2140 encode_nops(&hdr);
2169 return 0;
2170} 2141}
2171 2142
2172static int nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, __be32 *p, struct nfs_release_lockowner_args *args) 2143static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req,
2144 struct xdr_stream *xdr,
2145 struct nfs_release_lockowner_args *args)
2173{ 2146{
2174 struct xdr_stream xdr;
2175 struct compound_hdr hdr = { 2147 struct compound_hdr hdr = {
2176 .minorversion = 0, 2148 .minorversion = 0,
2177 }; 2149 };
2178 2150
2179 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2151 encode_compound_hdr(xdr, req, &hdr);
2180 encode_compound_hdr(&xdr, req, &hdr); 2152 encode_release_lockowner(xdr, &args->lock_owner, &hdr);
2181 encode_release_lockowner(&xdr, &args->lock_owner, &hdr);
2182 encode_nops(&hdr); 2153 encode_nops(&hdr);
2183 return 0;
2184} 2154}
2185 2155
2186/* 2156/*
2187 * Encode a READLINK request 2157 * Encode a READLINK request
2188 */ 2158 */
2189static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct nfs4_readlink *args) 2159static void nfs4_xdr_enc_readlink(struct rpc_rqst *req, struct xdr_stream *xdr,
2160 const struct nfs4_readlink *args)
2190{ 2161{
2191 struct xdr_stream xdr;
2192 struct compound_hdr hdr = { 2162 struct compound_hdr hdr = {
2193 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2163 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2194 }; 2164 };
2195 2165
2196 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2166 encode_compound_hdr(xdr, req, &hdr);
2197 encode_compound_hdr(&xdr, req, &hdr); 2167 encode_sequence(xdr, &args->seq_args, &hdr);
2198 encode_sequence(&xdr, &args->seq_args, &hdr); 2168 encode_putfh(xdr, args->fh, &hdr);
2199 encode_putfh(&xdr, args->fh, &hdr); 2169 encode_readlink(xdr, args, req, &hdr);
2200 encode_readlink(&xdr, args, req, &hdr);
2201 2170
2202 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, 2171 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2203 args->pgbase, args->pglen); 2172 args->pgbase, args->pglen);
2204 encode_nops(&hdr); 2173 encode_nops(&hdr);
2205 return 0;
2206} 2174}
2207 2175
2208/* 2176/*
2209 * Encode a READDIR request 2177 * Encode a READDIR request
2210 */ 2178 */
2211static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nfs4_readdir_arg *args) 2179static void nfs4_xdr_enc_readdir(struct rpc_rqst *req, struct xdr_stream *xdr,
2180 const struct nfs4_readdir_arg *args)
2212{ 2181{
2213 struct xdr_stream xdr;
2214 struct compound_hdr hdr = { 2182 struct compound_hdr hdr = {
2215 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2183 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2216 }; 2184 };
2217 2185
2218 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2186 encode_compound_hdr(xdr, req, &hdr);
2219 encode_compound_hdr(&xdr, req, &hdr); 2187 encode_sequence(xdr, &args->seq_args, &hdr);
2220 encode_sequence(&xdr, &args->seq_args, &hdr); 2188 encode_putfh(xdr, args->fh, &hdr);
2221 encode_putfh(&xdr, args->fh, &hdr); 2189 encode_readdir(xdr, args, req, &hdr);
2222 encode_readdir(&xdr, args, req, &hdr);
2223 2190
2224 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages, 2191 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, args->pages,
2225 args->pgbase, args->count); 2192 args->pgbase, args->count);
@@ -2227,428 +2194,387 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
2227 __func__, hdr.replen << 2, args->pages, 2194 __func__, hdr.replen << 2, args->pages,
2228 args->pgbase, args->count); 2195 args->pgbase, args->count);
2229 encode_nops(&hdr); 2196 encode_nops(&hdr);
2230 return 0;
2231} 2197}
2232 2198
2233/* 2199/*
2234 * Encode a READ request 2200 * Encode a READ request
2235 */ 2201 */
2236static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) 2202static void nfs4_xdr_enc_read(struct rpc_rqst *req, struct xdr_stream *xdr,
2203 struct nfs_readargs *args)
2237{ 2204{
2238 struct xdr_stream xdr;
2239 struct compound_hdr hdr = { 2205 struct compound_hdr hdr = {
2240 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2206 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2241 }; 2207 };
2242 2208
2243 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2209 encode_compound_hdr(xdr, req, &hdr);
2244 encode_compound_hdr(&xdr, req, &hdr); 2210 encode_sequence(xdr, &args->seq_args, &hdr);
2245 encode_sequence(&xdr, &args->seq_args, &hdr); 2211 encode_putfh(xdr, args->fh, &hdr);
2246 encode_putfh(&xdr, args->fh, &hdr); 2212 encode_read(xdr, args, &hdr);
2247 encode_read(&xdr, args, &hdr);
2248 2213
2249 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2, 2214 xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
2250 args->pages, args->pgbase, args->count); 2215 args->pages, args->pgbase, args->count);
2251 req->rq_rcv_buf.flags |= XDRBUF_READ; 2216 req->rq_rcv_buf.flags |= XDRBUF_READ;
2252 encode_nops(&hdr); 2217 encode_nops(&hdr);
2253 return 0;
2254} 2218}
2255 2219
2256/* 2220/*
2257 * Encode an SETATTR request 2221 * Encode an SETATTR request
2258 */ 2222 */
2259static int nfs4_xdr_enc_setattr(struct rpc_rqst *req, __be32 *p, struct nfs_setattrargs *args) 2223static void nfs4_xdr_enc_setattr(struct rpc_rqst *req, struct xdr_stream *xdr,
2224 struct nfs_setattrargs *args)
2260{ 2225{
2261 struct xdr_stream xdr;
2262 struct compound_hdr hdr = { 2226 struct compound_hdr hdr = {
2263 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2227 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2264 }; 2228 };
2265 2229
2266 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2230 encode_compound_hdr(xdr, req, &hdr);
2267 encode_compound_hdr(&xdr, req, &hdr); 2231 encode_sequence(xdr, &args->seq_args, &hdr);
2268 encode_sequence(&xdr, &args->seq_args, &hdr); 2232 encode_putfh(xdr, args->fh, &hdr);
2269 encode_putfh(&xdr, args->fh, &hdr); 2233 encode_setattr(xdr, args, args->server, &hdr);
2270 encode_setattr(&xdr, args, args->server, &hdr); 2234 encode_getfattr(xdr, args->bitmask, &hdr);
2271 encode_getfattr(&xdr, args->bitmask, &hdr);
2272 encode_nops(&hdr); 2235 encode_nops(&hdr);
2273 return 0;
2274} 2236}
2275 2237
2276/* 2238/*
2277 * Encode a GETACL request 2239 * Encode a GETACL request
2278 */ 2240 */
2279static int 2241static void nfs4_xdr_enc_getacl(struct rpc_rqst *req, struct xdr_stream *xdr,
2280nfs4_xdr_enc_getacl(struct rpc_rqst *req, __be32 *p, 2242 struct nfs_getaclargs *args)
2281 struct nfs_getaclargs *args)
2282{ 2243{
2283 struct xdr_stream xdr;
2284 struct compound_hdr hdr = { 2244 struct compound_hdr hdr = {
2285 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2245 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2286 }; 2246 };
2287 uint32_t replen; 2247 uint32_t replen;
2288 2248
2289 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2249 encode_compound_hdr(xdr, req, &hdr);
2290 encode_compound_hdr(&xdr, req, &hdr); 2250 encode_sequence(xdr, &args->seq_args, &hdr);
2291 encode_sequence(&xdr, &args->seq_args, &hdr); 2251 encode_putfh(xdr, args->fh, &hdr);
2292 encode_putfh(&xdr, args->fh, &hdr);
2293 replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1; 2252 replen = hdr.replen + op_decode_hdr_maxsz + nfs4_fattr_bitmap_maxsz + 1;
2294 encode_getattr_two(&xdr, FATTR4_WORD0_ACL, 0, &hdr); 2253 encode_getattr_two(xdr, FATTR4_WORD0_ACL, 0, &hdr);
2295 2254
2296 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, 2255 xdr_inline_pages(&req->rq_rcv_buf, replen << 2,
2297 args->acl_pages, args->acl_pgbase, args->acl_len); 2256 args->acl_pages, args->acl_pgbase, args->acl_len);
2298 encode_nops(&hdr); 2257 encode_nops(&hdr);
2299 return 0;
2300} 2258}
2301 2259
2302/* 2260/*
2303 * Encode a WRITE request 2261 * Encode a WRITE request
2304 */ 2262 */
2305static int nfs4_xdr_enc_write(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) 2263static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr,
2264 struct nfs_writeargs *args)
2306{ 2265{
2307 struct xdr_stream xdr;
2308 struct compound_hdr hdr = { 2266 struct compound_hdr hdr = {
2309 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2267 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2310 }; 2268 };
2311 2269
2312 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2270 encode_compound_hdr(xdr, req, &hdr);
2313 encode_compound_hdr(&xdr, req, &hdr); 2271 encode_sequence(xdr, &args->seq_args, &hdr);
2314 encode_sequence(&xdr, &args->seq_args, &hdr); 2272 encode_putfh(xdr, args->fh, &hdr);
2315 encode_putfh(&xdr, args->fh, &hdr); 2273 encode_write(xdr, args, &hdr);
2316 encode_write(&xdr, args, &hdr);
2317 req->rq_snd_buf.flags |= XDRBUF_WRITE; 2274 req->rq_snd_buf.flags |= XDRBUF_WRITE;
2318 encode_getfattr(&xdr, args->bitmask, &hdr); 2275 encode_getfattr(xdr, args->bitmask, &hdr);
2319 encode_nops(&hdr); 2276 encode_nops(&hdr);
2320 return 0;
2321} 2277}
2322 2278
2323/* 2279/*
2324 * a COMMIT request 2280 * a COMMIT request
2325 */ 2281 */
2326static int nfs4_xdr_enc_commit(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) 2282static void nfs4_xdr_enc_commit(struct rpc_rqst *req, struct xdr_stream *xdr,
2283 struct nfs_writeargs *args)
2327{ 2284{
2328 struct xdr_stream xdr;
2329 struct compound_hdr hdr = { 2285 struct compound_hdr hdr = {
2330 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2286 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2331 }; 2287 };
2332 2288
2333 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2289 encode_compound_hdr(xdr, req, &hdr);
2334 encode_compound_hdr(&xdr, req, &hdr); 2290 encode_sequence(xdr, &args->seq_args, &hdr);
2335 encode_sequence(&xdr, &args->seq_args, &hdr); 2291 encode_putfh(xdr, args->fh, &hdr);
2336 encode_putfh(&xdr, args->fh, &hdr); 2292 encode_commit(xdr, args, &hdr);
2337 encode_commit(&xdr, args, &hdr); 2293 encode_getfattr(xdr, args->bitmask, &hdr);
2338 encode_getfattr(&xdr, args->bitmask, &hdr);
2339 encode_nops(&hdr); 2294 encode_nops(&hdr);
2340 return 0;
2341} 2295}
2342 2296
2343/* 2297/*
2344 * FSINFO request 2298 * FSINFO request
2345 */ 2299 */
2346static int nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, __be32 *p, struct nfs4_fsinfo_arg *args) 2300static void nfs4_xdr_enc_fsinfo(struct rpc_rqst *req, struct xdr_stream *xdr,
2301 struct nfs4_fsinfo_arg *args)
2347{ 2302{
2348 struct xdr_stream xdr;
2349 struct compound_hdr hdr = { 2303 struct compound_hdr hdr = {
2350 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2304 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2351 }; 2305 };
2352 2306
2353 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2307 encode_compound_hdr(xdr, req, &hdr);
2354 encode_compound_hdr(&xdr, req, &hdr); 2308 encode_sequence(xdr, &args->seq_args, &hdr);
2355 encode_sequence(&xdr, &args->seq_args, &hdr); 2309 encode_putfh(xdr, args->fh, &hdr);
2356 encode_putfh(&xdr, args->fh, &hdr); 2310 encode_fsinfo(xdr, args->bitmask, &hdr);
2357 encode_fsinfo(&xdr, args->bitmask, &hdr);
2358 encode_nops(&hdr); 2311 encode_nops(&hdr);
2359 return 0;
2360} 2312}
2361 2313
2362/* 2314/*
2363 * a PATHCONF request 2315 * a PATHCONF request
2364 */ 2316 */
2365static int nfs4_xdr_enc_pathconf(struct rpc_rqst *req, __be32 *p, const struct nfs4_pathconf_arg *args) 2317static void nfs4_xdr_enc_pathconf(struct rpc_rqst *req, struct xdr_stream *xdr,
2318 const struct nfs4_pathconf_arg *args)
2366{ 2319{
2367 struct xdr_stream xdr;
2368 struct compound_hdr hdr = { 2320 struct compound_hdr hdr = {
2369 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2321 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2370 }; 2322 };
2371 2323
2372 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2324 encode_compound_hdr(xdr, req, &hdr);
2373 encode_compound_hdr(&xdr, req, &hdr); 2325 encode_sequence(xdr, &args->seq_args, &hdr);
2374 encode_sequence(&xdr, &args->seq_args, &hdr); 2326 encode_putfh(xdr, args->fh, &hdr);
2375 encode_putfh(&xdr, args->fh, &hdr); 2327 encode_getattr_one(xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0],
2376 encode_getattr_one(&xdr, args->bitmask[0] & nfs4_pathconf_bitmap[0],
2377 &hdr); 2328 &hdr);
2378 encode_nops(&hdr); 2329 encode_nops(&hdr);
2379 return 0;
2380} 2330}
2381 2331
2382/* 2332/*
2383 * a STATFS request 2333 * a STATFS request
2384 */ 2334 */
2385static int nfs4_xdr_enc_statfs(struct rpc_rqst *req, __be32 *p, const struct nfs4_statfs_arg *args) 2335static void nfs4_xdr_enc_statfs(struct rpc_rqst *req, struct xdr_stream *xdr,
2336 const struct nfs4_statfs_arg *args)
2386{ 2337{
2387 struct xdr_stream xdr;
2388 struct compound_hdr hdr = { 2338 struct compound_hdr hdr = {
2389 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2339 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2390 }; 2340 };
2391 2341
2392 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2342 encode_compound_hdr(xdr, req, &hdr);
2393 encode_compound_hdr(&xdr, req, &hdr); 2343 encode_sequence(xdr, &args->seq_args, &hdr);
2394 encode_sequence(&xdr, &args->seq_args, &hdr); 2344 encode_putfh(xdr, args->fh, &hdr);
2395 encode_putfh(&xdr, args->fh, &hdr); 2345 encode_getattr_two(xdr, args->bitmask[0] & nfs4_statfs_bitmap[0],
2396 encode_getattr_two(&xdr, args->bitmask[0] & nfs4_statfs_bitmap[0],
2397 args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr); 2346 args->bitmask[1] & nfs4_statfs_bitmap[1], &hdr);
2398 encode_nops(&hdr); 2347 encode_nops(&hdr);
2399 return 0;
2400} 2348}
2401 2349
2402/* 2350/*
2403 * GETATTR_BITMAP request 2351 * GETATTR_BITMAP request
2404 */ 2352 */
2405static int nfs4_xdr_enc_server_caps(struct rpc_rqst *req, __be32 *p, 2353static void nfs4_xdr_enc_server_caps(struct rpc_rqst *req,
2406 struct nfs4_server_caps_arg *args) 2354 struct xdr_stream *xdr,
2355 struct nfs4_server_caps_arg *args)
2407{ 2356{
2408 struct xdr_stream xdr;
2409 struct compound_hdr hdr = { 2357 struct compound_hdr hdr = {
2410 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2358 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2411 }; 2359 };
2412 2360
2413 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2361 encode_compound_hdr(xdr, req, &hdr);
2414 encode_compound_hdr(&xdr, req, &hdr); 2362 encode_sequence(xdr, &args->seq_args, &hdr);
2415 encode_sequence(&xdr, &args->seq_args, &hdr); 2363 encode_putfh(xdr, args->fhandle, &hdr);
2416 encode_putfh(&xdr, args->fhandle, &hdr); 2364 encode_getattr_one(xdr, FATTR4_WORD0_SUPPORTED_ATTRS|
2417 encode_getattr_one(&xdr, FATTR4_WORD0_SUPPORTED_ATTRS|
2418 FATTR4_WORD0_LINK_SUPPORT| 2365 FATTR4_WORD0_LINK_SUPPORT|
2419 FATTR4_WORD0_SYMLINK_SUPPORT| 2366 FATTR4_WORD0_SYMLINK_SUPPORT|
2420 FATTR4_WORD0_ACLSUPPORT, &hdr); 2367 FATTR4_WORD0_ACLSUPPORT, &hdr);
2421 encode_nops(&hdr); 2368 encode_nops(&hdr);
2422 return 0;
2423} 2369}
2424 2370
2425/* 2371/*
2426 * a RENEW request 2372 * a RENEW request
2427 */ 2373 */
2428static int nfs4_xdr_enc_renew(struct rpc_rqst *req, __be32 *p, struct nfs_client *clp) 2374static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr,
2375 struct nfs_client *clp)
2429{ 2376{
2430 struct xdr_stream xdr;
2431 struct compound_hdr hdr = { 2377 struct compound_hdr hdr = {
2432 .nops = 0, 2378 .nops = 0,
2433 }; 2379 };
2434 2380
2435 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2381 encode_compound_hdr(xdr, req, &hdr);
2436 encode_compound_hdr(&xdr, req, &hdr); 2382 encode_renew(xdr, clp, &hdr);
2437 encode_renew(&xdr, clp, &hdr);
2438 encode_nops(&hdr); 2383 encode_nops(&hdr);
2439 return 0;
2440} 2384}
2441 2385
2442/* 2386/*
2443 * a SETCLIENTID request 2387 * a SETCLIENTID request
2444 */ 2388 */
2445static int nfs4_xdr_enc_setclientid(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid *sc) 2389static void nfs4_xdr_enc_setclientid(struct rpc_rqst *req,
2390 struct xdr_stream *xdr,
2391 struct nfs4_setclientid *sc)
2446{ 2392{
2447 struct xdr_stream xdr;
2448 struct compound_hdr hdr = { 2393 struct compound_hdr hdr = {
2449 .nops = 0, 2394 .nops = 0,
2450 }; 2395 };
2451 2396
2452 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2397 encode_compound_hdr(xdr, req, &hdr);
2453 encode_compound_hdr(&xdr, req, &hdr); 2398 encode_setclientid(xdr, sc, &hdr);
2454 encode_setclientid(&xdr, sc, &hdr);
2455 encode_nops(&hdr); 2399 encode_nops(&hdr);
2456 return 0;
2457} 2400}
2458 2401
2459/* 2402/*
2460 * a SETCLIENTID_CONFIRM request 2403 * a SETCLIENTID_CONFIRM request
2461 */ 2404 */
2462static int nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req, __be32 *p, struct nfs4_setclientid_res *arg) 2405static void nfs4_xdr_enc_setclientid_confirm(struct rpc_rqst *req,
2406 struct xdr_stream *xdr,
2407 struct nfs4_setclientid_res *arg)
2463{ 2408{
2464 struct xdr_stream xdr;
2465 struct compound_hdr hdr = { 2409 struct compound_hdr hdr = {
2466 .nops = 0, 2410 .nops = 0,
2467 }; 2411 };
2468 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; 2412 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 };
2469 2413
2470 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2414 encode_compound_hdr(xdr, req, &hdr);
2471 encode_compound_hdr(&xdr, req, &hdr); 2415 encode_setclientid_confirm(xdr, arg, &hdr);
2472 encode_setclientid_confirm(&xdr, arg, &hdr); 2416 encode_putrootfh(xdr, &hdr);
2473 encode_putrootfh(&xdr, &hdr); 2417 encode_fsinfo(xdr, lease_bitmap, &hdr);
2474 encode_fsinfo(&xdr, lease_bitmap, &hdr);
2475 encode_nops(&hdr); 2418 encode_nops(&hdr);
2476 return 0;
2477} 2419}
2478 2420
2479/* 2421/*
2480 * DELEGRETURN request 2422 * DELEGRETURN request
2481 */ 2423 */
2482static int nfs4_xdr_enc_delegreturn(struct rpc_rqst *req, __be32 *p, const struct nfs4_delegreturnargs *args) 2424static void nfs4_xdr_enc_delegreturn(struct rpc_rqst *req,
2425 struct xdr_stream *xdr,
2426 const struct nfs4_delegreturnargs *args)
2483{ 2427{
2484 struct xdr_stream xdr;
2485 struct compound_hdr hdr = { 2428 struct compound_hdr hdr = {
2486 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2429 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2487 }; 2430 };
2488 2431
2489 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2432 encode_compound_hdr(xdr, req, &hdr);
2490 encode_compound_hdr(&xdr, req, &hdr); 2433 encode_sequence(xdr, &args->seq_args, &hdr);
2491 encode_sequence(&xdr, &args->seq_args, &hdr); 2434 encode_putfh(xdr, args->fhandle, &hdr);
2492 encode_putfh(&xdr, args->fhandle, &hdr); 2435 encode_delegreturn(xdr, args->stateid, &hdr);
2493 encode_delegreturn(&xdr, args->stateid, &hdr); 2436 encode_getfattr(xdr, args->bitmask, &hdr);
2494 encode_getfattr(&xdr, args->bitmask, &hdr);
2495 encode_nops(&hdr); 2437 encode_nops(&hdr);
2496 return 0;
2497} 2438}
2498 2439
2499/* 2440/*
2500 * Encode FS_LOCATIONS request 2441 * Encode FS_LOCATIONS request
2501 */ 2442 */
2502static int nfs4_xdr_enc_fs_locations(struct rpc_rqst *req, __be32 *p, struct nfs4_fs_locations_arg *args) 2443static void nfs4_xdr_enc_fs_locations(struct rpc_rqst *req,
2444 struct xdr_stream *xdr,
2445 struct nfs4_fs_locations_arg *args)
2503{ 2446{
2504 struct xdr_stream xdr;
2505 struct compound_hdr hdr = { 2447 struct compound_hdr hdr = {
2506 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2448 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2507 }; 2449 };
2508 uint32_t replen; 2450 uint32_t replen;
2509 2451
2510 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2452 encode_compound_hdr(xdr, req, &hdr);
2511 encode_compound_hdr(&xdr, req, &hdr); 2453 encode_sequence(xdr, &args->seq_args, &hdr);
2512 encode_sequence(&xdr, &args->seq_args, &hdr); 2454 encode_putfh(xdr, args->dir_fh, &hdr);
2513 encode_putfh(&xdr, args->dir_fh, &hdr); 2455 encode_lookup(xdr, args->name, &hdr);
2514 encode_lookup(&xdr, args->name, &hdr);
2515 replen = hdr.replen; /* get the attribute into args->page */ 2456 replen = hdr.replen; /* get the attribute into args->page */
2516 encode_fs_locations(&xdr, args->bitmask, &hdr); 2457 encode_fs_locations(xdr, args->bitmask, &hdr);
2517 2458
2518 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page, 2459 xdr_inline_pages(&req->rq_rcv_buf, replen << 2, &args->page,
2519 0, PAGE_SIZE); 2460 0, PAGE_SIZE);
2520 encode_nops(&hdr); 2461 encode_nops(&hdr);
2521 return 0;
2522} 2462}
2523 2463
2524#if defined(CONFIG_NFS_V4_1) 2464#if defined(CONFIG_NFS_V4_1)
2525/* 2465/*
2526 * EXCHANGE_ID request 2466 * EXCHANGE_ID request
2527 */ 2467 */
2528static int nfs4_xdr_enc_exchange_id(struct rpc_rqst *req, uint32_t *p, 2468static void nfs4_xdr_enc_exchange_id(struct rpc_rqst *req,
2529 struct nfs41_exchange_id_args *args) 2469 struct xdr_stream *xdr,
2470 struct nfs41_exchange_id_args *args)
2530{ 2471{
2531 struct xdr_stream xdr;
2532 struct compound_hdr hdr = { 2472 struct compound_hdr hdr = {
2533 .minorversion = args->client->cl_mvops->minor_version, 2473 .minorversion = args->client->cl_mvops->minor_version,
2534 }; 2474 };
2535 2475
2536 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2476 encode_compound_hdr(xdr, req, &hdr);
2537 encode_compound_hdr(&xdr, req, &hdr); 2477 encode_exchange_id(xdr, args, &hdr);
2538 encode_exchange_id(&xdr, args, &hdr);
2539 encode_nops(&hdr); 2478 encode_nops(&hdr);
2540 return 0;
2541} 2479}
2542 2480
2543/* 2481/*
2544 * a CREATE_SESSION request 2482 * a CREATE_SESSION request
2545 */ 2483 */
2546static int nfs4_xdr_enc_create_session(struct rpc_rqst *req, uint32_t *p, 2484static void nfs4_xdr_enc_create_session(struct rpc_rqst *req,
2547 struct nfs41_create_session_args *args) 2485 struct xdr_stream *xdr,
2486 struct nfs41_create_session_args *args)
2548{ 2487{
2549 struct xdr_stream xdr;
2550 struct compound_hdr hdr = { 2488 struct compound_hdr hdr = {
2551 .minorversion = args->client->cl_mvops->minor_version, 2489 .minorversion = args->client->cl_mvops->minor_version,
2552 }; 2490 };
2553 2491
2554 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2492 encode_compound_hdr(xdr, req, &hdr);
2555 encode_compound_hdr(&xdr, req, &hdr); 2493 encode_create_session(xdr, args, &hdr);
2556 encode_create_session(&xdr, args, &hdr);
2557 encode_nops(&hdr); 2494 encode_nops(&hdr);
2558 return 0;
2559} 2495}
2560 2496
2561/* 2497/*
2562 * a DESTROY_SESSION request 2498 * a DESTROY_SESSION request
2563 */ 2499 */
2564static int nfs4_xdr_enc_destroy_session(struct rpc_rqst *req, uint32_t *p, 2500static void nfs4_xdr_enc_destroy_session(struct rpc_rqst *req,
2565 struct nfs4_session *session) 2501 struct xdr_stream *xdr,
2502 struct nfs4_session *session)
2566{ 2503{
2567 struct xdr_stream xdr;
2568 struct compound_hdr hdr = { 2504 struct compound_hdr hdr = {
2569 .minorversion = session->clp->cl_mvops->minor_version, 2505 .minorversion = session->clp->cl_mvops->minor_version,
2570 }; 2506 };
2571 2507
2572 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2508 encode_compound_hdr(xdr, req, &hdr);
2573 encode_compound_hdr(&xdr, req, &hdr); 2509 encode_destroy_session(xdr, session, &hdr);
2574 encode_destroy_session(&xdr, session, &hdr);
2575 encode_nops(&hdr); 2510 encode_nops(&hdr);
2576 return 0;
2577} 2511}
2578 2512
2579/* 2513/*
2580 * a SEQUENCE request 2514 * a SEQUENCE request
2581 */ 2515 */
2582static int nfs4_xdr_enc_sequence(struct rpc_rqst *req, uint32_t *p, 2516static void nfs4_xdr_enc_sequence(struct rpc_rqst *req, struct xdr_stream *xdr,
2583 struct nfs4_sequence_args *args) 2517 struct nfs4_sequence_args *args)
2584{ 2518{
2585 struct xdr_stream xdr;
2586 struct compound_hdr hdr = { 2519 struct compound_hdr hdr = {
2587 .minorversion = nfs4_xdr_minorversion(args), 2520 .minorversion = nfs4_xdr_minorversion(args),
2588 }; 2521 };
2589 2522
2590 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2523 encode_compound_hdr(xdr, req, &hdr);
2591 encode_compound_hdr(&xdr, req, &hdr); 2524 encode_sequence(xdr, args, &hdr);
2592 encode_sequence(&xdr, args, &hdr);
2593 encode_nops(&hdr); 2525 encode_nops(&hdr);
2594 return 0;
2595} 2526}
2596 2527
2597/* 2528/*
2598 * a GET_LEASE_TIME request 2529 * a GET_LEASE_TIME request
2599 */ 2530 */
2600static int nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req, uint32_t *p, 2531static void nfs4_xdr_enc_get_lease_time(struct rpc_rqst *req,
2601 struct nfs4_get_lease_time_args *args) 2532 struct xdr_stream *xdr,
2533 struct nfs4_get_lease_time_args *args)
2602{ 2534{
2603 struct xdr_stream xdr;
2604 struct compound_hdr hdr = { 2535 struct compound_hdr hdr = {
2605 .minorversion = nfs4_xdr_minorversion(&args->la_seq_args), 2536 .minorversion = nfs4_xdr_minorversion(&args->la_seq_args),
2606 }; 2537 };
2607 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 }; 2538 const u32 lease_bitmap[2] = { FATTR4_WORD0_LEASE_TIME, 0 };
2608 2539
2609 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2540 encode_compound_hdr(xdr, req, &hdr);
2610 encode_compound_hdr(&xdr, req, &hdr); 2541 encode_sequence(xdr, &args->la_seq_args, &hdr);
2611 encode_sequence(&xdr, &args->la_seq_args, &hdr); 2542 encode_putrootfh(xdr, &hdr);
2612 encode_putrootfh(&xdr, &hdr); 2543 encode_fsinfo(xdr, lease_bitmap, &hdr);
2613 encode_fsinfo(&xdr, lease_bitmap, &hdr);
2614 encode_nops(&hdr); 2544 encode_nops(&hdr);
2615 return 0;
2616} 2545}
2617 2546
2618/* 2547/*
2619 * a RECLAIM_COMPLETE request 2548 * a RECLAIM_COMPLETE request
2620 */ 2549 */
2621static int nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req, uint32_t *p, 2550static void nfs4_xdr_enc_reclaim_complete(struct rpc_rqst *req,
2622 struct nfs41_reclaim_complete_args *args) 2551 struct xdr_stream *xdr,
2552 struct nfs41_reclaim_complete_args *args)
2623{ 2553{
2624 struct xdr_stream xdr;
2625 struct compound_hdr hdr = { 2554 struct compound_hdr hdr = {
2626 .minorversion = nfs4_xdr_minorversion(&args->seq_args) 2555 .minorversion = nfs4_xdr_minorversion(&args->seq_args)
2627 }; 2556 };
2628 2557
2629 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2558 encode_compound_hdr(xdr, req, &hdr);
2630 encode_compound_hdr(&xdr, req, &hdr); 2559 encode_sequence(xdr, &args->seq_args, &hdr);
2631 encode_sequence(&xdr, &args->seq_args, &hdr); 2560 encode_reclaim_complete(xdr, args, &hdr);
2632 encode_reclaim_complete(&xdr, args, &hdr);
2633 encode_nops(&hdr); 2561 encode_nops(&hdr);
2634 return 0;
2635} 2562}
2636 2563
2637/* 2564/*
2638 * Encode GETDEVICEINFO request 2565 * Encode GETDEVICEINFO request
2639 */ 2566 */
2640static int nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, uint32_t *p, 2567static void nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req,
2641 struct nfs4_getdeviceinfo_args *args) 2568 struct xdr_stream *xdr,
2569 struct nfs4_getdeviceinfo_args *args)
2642{ 2570{
2643 struct xdr_stream xdr;
2644 struct compound_hdr hdr = { 2571 struct compound_hdr hdr = {
2645 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2572 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2646 }; 2573 };
2647 2574
2648 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2575 encode_compound_hdr(xdr, req, &hdr);
2649 encode_compound_hdr(&xdr, req, &hdr); 2576 encode_sequence(xdr, &args->seq_args, &hdr);
2650 encode_sequence(&xdr, &args->seq_args, &hdr); 2577 encode_getdeviceinfo(xdr, args, &hdr);
2651 encode_getdeviceinfo(&xdr, args, &hdr);
2652 2578
2653 /* set up reply kvec. Subtract notification bitmap max size (2) 2579 /* set up reply kvec. Subtract notification bitmap max size (2)
2654 * so that notification bitmap is put in xdr_buf tail */ 2580 * so that notification bitmap is put in xdr_buf tail */
@@ -2657,27 +2583,24 @@ static int nfs4_xdr_enc_getdeviceinfo(struct rpc_rqst *req, uint32_t *p,
2657 args->pdev->pglen); 2583 args->pdev->pglen);
2658 2584
2659 encode_nops(&hdr); 2585 encode_nops(&hdr);
2660 return 0;
2661} 2586}
2662 2587
2663/* 2588/*
2664 * Encode LAYOUTGET request 2589 * Encode LAYOUTGET request
2665 */ 2590 */
2666static int nfs4_xdr_enc_layoutget(struct rpc_rqst *req, uint32_t *p, 2591static void nfs4_xdr_enc_layoutget(struct rpc_rqst *req,
2667 struct nfs4_layoutget_args *args) 2592 struct xdr_stream *xdr,
2593 struct nfs4_layoutget_args *args)
2668{ 2594{
2669 struct xdr_stream xdr;
2670 struct compound_hdr hdr = { 2595 struct compound_hdr hdr = {
2671 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 2596 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
2672 }; 2597 };
2673 2598
2674 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 2599 encode_compound_hdr(xdr, req, &hdr);
2675 encode_compound_hdr(&xdr, req, &hdr); 2600 encode_sequence(xdr, &args->seq_args, &hdr);
2676 encode_sequence(&xdr, &args->seq_args, &hdr); 2601 encode_putfh(xdr, NFS_FH(args->inode), &hdr);
2677 encode_putfh(&xdr, NFS_FH(args->inode), &hdr); 2602 encode_layoutget(xdr, args, &hdr);
2678 encode_layoutget(&xdr, args, &hdr);
2679 encode_nops(&hdr); 2603 encode_nops(&hdr);
2680 return 0;
2681} 2604}
2682#endif /* CONFIG_NFS_V4_1 */ 2605#endif /* CONFIG_NFS_V4_1 */
2683 2606
@@ -5368,22 +5291,18 @@ out:
5368/* 5291/*
5369 * Encode an SETACL request 5292 * Encode an SETACL request
5370 */ 5293 */
5371static int 5294static void nfs4_xdr_enc_setacl(struct rpc_rqst *req, struct xdr_stream *xdr,
5372nfs4_xdr_enc_setacl(struct rpc_rqst *req, __be32 *p, struct nfs_setaclargs *args) 5295 struct nfs_setaclargs *args)
5373{ 5296{
5374 struct xdr_stream xdr;
5375 struct compound_hdr hdr = { 5297 struct compound_hdr hdr = {
5376 .minorversion = nfs4_xdr_minorversion(&args->seq_args), 5298 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
5377 }; 5299 };
5378 int status;
5379 5300
5380 xdr_init_encode(&xdr, &req->rq_snd_buf, p); 5301 encode_compound_hdr(xdr, req, &hdr);
5381 encode_compound_hdr(&xdr, req, &hdr); 5302 encode_sequence(xdr, &args->seq_args, &hdr);
5382 encode_sequence(&xdr, &args->seq_args, &hdr); 5303 encode_putfh(xdr, args->fh, &hdr);
5383 encode_putfh(&xdr, args->fh, &hdr); 5304 encode_setacl(xdr, args, &hdr);
5384 status = encode_setacl(&xdr, args, &hdr);
5385 encode_nops(&hdr); 5305 encode_nops(&hdr);
5386 return status;
5387} 5306}
5388 5307
5389/* 5308/*
@@ -6316,7 +6235,7 @@ nfs4_stat_to_errno(int stat)
6316#define PROC(proc, argtype, restype) \ 6235#define PROC(proc, argtype, restype) \
6317[NFSPROC4_CLNT_##proc] = { \ 6236[NFSPROC4_CLNT_##proc] = { \
6318 .p_proc = NFSPROC4_COMPOUND, \ 6237 .p_proc = NFSPROC4_COMPOUND, \
6319 .p_encode = (kxdrproc_t)nfs4_xdr_##argtype, \ 6238 .p_encode = (kxdreproc_t)nfs4_xdr_##argtype, \
6320 .p_decode = (kxdrproc_t)nfs4_xdr_##restype, \ 6239 .p_decode = (kxdrproc_t)nfs4_xdr_##restype, \
6321 .p_arglen = NFS4_##argtype##_sz, \ 6240 .p_arglen = NFS4_##argtype##_sz, \
6322 .p_replen = NFS4_##restype##_sz, \ 6241 .p_replen = NFS4_##restype##_sz, \