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 + \
30 #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
31 decode_putfh_maxsz + \
32 decode_allocate_maxsz + \
34 #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
35 encode_putfh_maxsz + \
36 encode_deallocate_maxsz + \
38 #define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \
39 decode_putfh_maxsz + \
40 decode_deallocate_maxsz + \
42 #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
43 encode_putfh_maxsz + \
45 #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \
46 decode_putfh_maxsz + \
50 static void encode_fallocate(struct xdr_stream
*xdr
,
51 struct nfs42_falloc_args
*args
)
53 encode_nfs4_stateid(xdr
, &args
->falloc_stateid
);
54 encode_uint64(xdr
, args
->falloc_offset
);
55 encode_uint64(xdr
, args
->falloc_length
);
58 static void encode_allocate(struct xdr_stream
*xdr
,
59 struct nfs42_falloc_args
*args
,
60 struct compound_hdr
*hdr
)
62 encode_op_hdr(xdr
, OP_ALLOCATE
, decode_allocate_maxsz
, hdr
);
63 encode_fallocate(xdr
, args
);
66 static void encode_deallocate(struct xdr_stream
*xdr
,
67 struct nfs42_falloc_args
*args
,
68 struct compound_hdr
*hdr
)
70 encode_op_hdr(xdr
, OP_DEALLOCATE
, decode_deallocate_maxsz
, hdr
);
71 encode_fallocate(xdr
, args
);
74 static void encode_seek(struct xdr_stream
*xdr
,
75 struct nfs42_seek_args
*args
,
76 struct compound_hdr
*hdr
)
78 encode_op_hdr(xdr
, OP_SEEK
, decode_seek_maxsz
, hdr
);
79 encode_nfs4_stateid(xdr
, &args
->sa_stateid
);
80 encode_uint64(xdr
, args
->sa_offset
);
81 encode_uint32(xdr
, args
->sa_what
);
85 * Encode ALLOCATE request
87 static void nfs4_xdr_enc_allocate(struct rpc_rqst
*req
,
88 struct xdr_stream
*xdr
,
89 struct nfs42_falloc_args
*args
)
91 struct compound_hdr hdr
= {
92 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
95 encode_compound_hdr(xdr
, req
, &hdr
);
96 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
97 encode_putfh(xdr
, args
->falloc_fh
, &hdr
);
98 encode_allocate(xdr
, args
, &hdr
);
99 encode_getfattr(xdr
, args
->falloc_bitmask
, &hdr
);
104 * Encode DEALLOCATE request
106 static void nfs4_xdr_enc_deallocate(struct rpc_rqst
*req
,
107 struct xdr_stream
*xdr
,
108 struct nfs42_falloc_args
*args
)
110 struct compound_hdr hdr
= {
111 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
114 encode_compound_hdr(xdr
, req
, &hdr
);
115 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
116 encode_putfh(xdr
, args
->falloc_fh
, &hdr
);
117 encode_deallocate(xdr
, args
, &hdr
);
118 encode_getfattr(xdr
, args
->falloc_bitmask
, &hdr
);
123 * Encode SEEK request
125 static void nfs4_xdr_enc_seek(struct rpc_rqst
*req
,
126 struct xdr_stream
*xdr
,
127 struct nfs42_seek_args
*args
)
129 struct compound_hdr hdr
= {
130 .minorversion
= nfs4_xdr_minorversion(&args
->seq_args
),
133 encode_compound_hdr(xdr
, req
, &hdr
);
134 encode_sequence(xdr
, &args
->seq_args
, &hdr
);
135 encode_putfh(xdr
, args
->sa_fh
, &hdr
);
136 encode_seek(xdr
, args
, &hdr
);
140 static int decode_allocate(struct xdr_stream
*xdr
, struct nfs42_falloc_res
*res
)
142 return decode_op_hdr(xdr
, OP_ALLOCATE
);
145 static int decode_deallocate(struct xdr_stream
*xdr
, struct nfs42_falloc_res
*res
)
147 return decode_op_hdr(xdr
, OP_DEALLOCATE
);
150 static int decode_seek(struct xdr_stream
*xdr
, struct nfs42_seek_res
*res
)
155 status
= decode_op_hdr(xdr
, OP_SEEK
);
159 p
= xdr_inline_decode(xdr
, 4 + 8);
163 res
->sr_eof
= be32_to_cpup(p
++);
164 p
= xdr_decode_hyper(p
, &res
->sr_offset
);
168 print_overflow_msg(__func__
, xdr
);
173 * Decode ALLOCATE request
175 static int nfs4_xdr_dec_allocate(struct rpc_rqst
*rqstp
,
176 struct xdr_stream
*xdr
,
177 struct nfs42_falloc_res
*res
)
179 struct compound_hdr hdr
;
182 status
= decode_compound_hdr(xdr
, &hdr
);
185 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
188 status
= decode_putfh(xdr
);
191 status
= decode_allocate(xdr
, res
);
194 decode_getfattr(xdr
, res
->falloc_fattr
, res
->falloc_server
);
200 * Decode DEALLOCATE request
202 static int nfs4_xdr_dec_deallocate(struct rpc_rqst
*rqstp
,
203 struct xdr_stream
*xdr
,
204 struct nfs42_falloc_res
*res
)
206 struct compound_hdr hdr
;
209 status
= decode_compound_hdr(xdr
, &hdr
);
212 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
215 status
= decode_putfh(xdr
);
218 status
= decode_deallocate(xdr
, res
);
221 decode_getfattr(xdr
, res
->falloc_fattr
, res
->falloc_server
);
227 * Decode SEEK request
229 static int nfs4_xdr_dec_seek(struct rpc_rqst
*rqstp
,
230 struct xdr_stream
*xdr
,
231 struct nfs42_seek_res
*res
)
233 struct compound_hdr hdr
;
236 status
= decode_compound_hdr(xdr
, &hdr
);
239 status
= decode_sequence(xdr
, &res
->seq_res
, rqstp
);
242 status
= decode_putfh(xdr
);
245 status
= decode_seek(xdr
, res
);
249 #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */