2 * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
4 #ifndef __LINUX_FS_NFS_NFS4_2XDR_H
5 #define __LINUX_FS_NFS_NFS4_2XDR_H
7 #define encode_fallocate_maxsz (encode_stateid_maxsz + \
10 #define encode_allocate_maxsz (op_encode_hdr_maxsz + \
11 encode_fallocate_maxsz)
12 #define decode_allocate_maxsz (op_decode_hdr_maxsz)
13 #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \
14 encode_fallocate_maxsz)
15 #define decode_deallocate_maxsz (op_decode_hdr_maxsz)
16 #define encode_seek_maxsz (op_encode_hdr_maxsz + \
17 encode_stateid_maxsz + \
20 #define decode_seek_maxsz (op_decode_hdr_maxsz + \
26 #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \
27 encode_putfh_maxsz + \
28 encode_allocate_maxsz)
29 #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
30 decode_putfh_maxsz + \
31 decode_allocate_maxsz)
32 #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
33 encode_putfh_maxsz + \
34 encode_deallocate_maxsz)
35 #define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \
36 decode_putfh_maxsz + \
37 decode_deallocate_maxsz)
38 #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
39 encode_putfh_maxsz + \
41 #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \
42 decode_putfh_maxsz + \
46 static void encode_fallocate(struct xdr_stream
*xdr
,
47 struct nfs42_falloc_args
*args
)
49 encode_nfs4_stateid(xdr
, &args
->falloc_stateid
);
50 encode_uint64(xdr
, args
->falloc_offset
);
51 encode_uint64(xdr
, args
->falloc_length
);
54 static void encode_allocate(struct xdr_stream
*xdr
,
55 struct nfs42_falloc_args
*args
,
56 struct compound_hdr
*hdr
)
58 encode_op_hdr(xdr
, OP_ALLOCATE
, decode_allocate_maxsz
, hdr
);
59 encode_fallocate(xdr
, args
);
62 static void encode_deallocate(struct xdr_stream
*xdr
,
63 struct nfs42_falloc_args
*args
,
64 struct compound_hdr
*hdr
)
66 encode_op_hdr(xdr
, OP_DEALLOCATE
, decode_deallocate_maxsz
, hdr
);
67 encode_fallocate(xdr
, args
);
70 static void encode_seek(struct xdr_stream
*xdr
,
71 struct nfs42_seek_args
*args
,
72 struct compound_hdr
*hdr
)
74 encode_op_hdr(xdr
, OP_SEEK
, decode_seek_maxsz
, hdr
);
75 encode_nfs4_stateid(xdr
, &args
->sa_stateid
);
76 encode_uint64(xdr
, args
->sa_offset
);
77 encode_uint32(xdr
, args
->sa_what
);
81 * Encode ALLOCATE request
83 static void nfs4_xdr_enc_allocate(struct rpc_rqst
*req
,
84 struct xdr_stream
*xdr
,
85 struct nfs42_falloc_args
*args
)
87 struct compound_hdr hdr
= {
88 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
91 encode_compound_hdr(xdr
, req
, &hdr
);
92 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
93 encode_putfh(xdr
, args
->falloc_fh
, &hdr
);
94 encode_allocate(xdr
, args
, &hdr
);
99 * Encode DEALLOCATE request
101 static void nfs4_xdr_enc_deallocate(struct rpc_rqst
*req
,
102 struct xdr_stream
*xdr
,
103 struct nfs42_falloc_args
*args
)
105 struct compound_hdr hdr
= {
106 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
109 encode_compound_hdr(xdr
, req
, &hdr
);
110 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
111 encode_putfh(xdr
, args
->falloc_fh
, &hdr
);
112 encode_deallocate(xdr
, args
, &hdr
);
117 * Encode SEEK request
119 static void nfs4_xdr_enc_seek(struct rpc_rqst
*req
,
120 struct xdr_stream
*xdr
,
121 struct nfs42_seek_args
*args
)
123 struct compound_hdr hdr
= {
124 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
127 encode_compound_hdr(xdr
, req
, &hdr
);
128 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
129 encode_putfh(xdr
, args
->sa_fh
, &hdr
);
130 encode_seek(xdr
, args
, &hdr
);
134 static int decode_allocate(struct xdr_stream
*xdr
, struct nfs42_falloc_res
*res
)
136 return decode_op_hdr(xdr
, OP_ALLOCATE
);
139 static int decode_deallocate(struct xdr_stream
*xdr
, struct nfs42_falloc_res
*res
)
141 return decode_op_hdr(xdr
, OP_DEALLOCATE
);
144 static int decode_seek(struct xdr_stream
*xdr
, struct nfs42_seek_res
*res
)
149 status
= decode_op_hdr(xdr
, OP_SEEK
);
153 p
= xdr_inline_decode(xdr
, 4 + 8);
157 res
->sr_eof
= be32_to_cpup(p
++);
158 p
= xdr_decode_hyper(p
, &res
->sr_offset
);
162 print_overflow_msg(__func__
, xdr
);
167 * Decode ALLOCATE request
169 static int nfs4_xdr_dec_allocate(struct rpc_rqst
*rqstp
,
170 struct xdr_stream
*xdr
,
171 struct nfs42_falloc_res
*res
)
173 struct compound_hdr hdr
;
176 status
= decode_compound_hdr(xdr
, &hdr
);
179 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
182 status
= decode_putfh(xdr
);
185 status
= decode_allocate(xdr
, res
);
191 * Decode DEALLOCATE request
193 static int nfs4_xdr_dec_deallocate(struct rpc_rqst
*rqstp
,
194 struct xdr_stream
*xdr
,
195 struct nfs42_falloc_res
*res
)
197 struct compound_hdr hdr
;
200 status
= decode_compound_hdr(xdr
, &hdr
);
203 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
206 status
= decode_putfh(xdr
);
209 status
= decode_deallocate(xdr
, res
);
215 * Decode SEEK request
217 static int nfs4_xdr_dec_seek(struct rpc_rqst
*rqstp
,
218 struct xdr_stream
*xdr
,
219 struct nfs42_seek_res
*res
)
221 struct compound_hdr hdr
;
224 status
= decode_compound_hdr(xdr
, &hdr
);
227 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
230 status
= decode_putfh(xdr
);
233 status
= decode_seek(xdr
, res
);
237 #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */