summaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs42xdr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/nfs42xdr.c')
-rw-r--r--fs/nfs/nfs42xdr.c97
1 files changed, 96 insertions, 1 deletions
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index 0eb29e14070d..0ca482a51e53 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -34,6 +34,12 @@
34 1 /* opaque devaddr4 length */ + \ 34 1 /* opaque devaddr4 length */ + \
35 XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE)) 35 XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE))
36#define decode_layoutstats_maxsz (op_decode_hdr_maxsz) 36#define decode_layoutstats_maxsz (op_decode_hdr_maxsz)
37#define encode_clone_maxsz (encode_stateid_maxsz + \
38 encode_stateid_maxsz + \
39 2 /* src offset */ + \
40 2 /* dst offset */ + \
41 2 /* count */)
42#define decode_clone_maxsz (op_decode_hdr_maxsz)
37 43
38#define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \ 44#define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \
39 encode_putfh_maxsz + \ 45 encode_putfh_maxsz + \
@@ -65,7 +71,20 @@
65 decode_sequence_maxsz + \ 71 decode_sequence_maxsz + \
66 decode_putfh_maxsz + \ 72 decode_putfh_maxsz + \
67 PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz) 73 PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz)
68 74#define NFS4_enc_clone_sz (compound_encode_hdr_maxsz + \
75 encode_sequence_maxsz + \
76 encode_putfh_maxsz + \
77 encode_savefh_maxsz + \
78 encode_putfh_maxsz + \
79 encode_clone_maxsz + \
80 encode_getattr_maxsz)
81#define NFS4_dec_clone_sz (compound_decode_hdr_maxsz + \
82 decode_sequence_maxsz + \
83 decode_putfh_maxsz + \
84 decode_savefh_maxsz + \
85 decode_putfh_maxsz + \
86 decode_clone_maxsz + \
87 decode_getattr_maxsz)
69 88
70static void encode_fallocate(struct xdr_stream *xdr, 89static void encode_fallocate(struct xdr_stream *xdr,
71 struct nfs42_falloc_args *args) 90 struct nfs42_falloc_args *args)
@@ -128,6 +147,21 @@ static void encode_layoutstats(struct xdr_stream *xdr,
128 encode_uint32(xdr, 0); 147 encode_uint32(xdr, 0);
129} 148}
130 149
150static void encode_clone(struct xdr_stream *xdr,
151 struct nfs42_clone_args *args,
152 struct compound_hdr *hdr)
153{
154 __be32 *p;
155
156 encode_op_hdr(xdr, OP_CLONE, decode_clone_maxsz, hdr);
157 encode_nfs4_stateid(xdr, &args->src_stateid);
158 encode_nfs4_stateid(xdr, &args->dst_stateid);
159 p = reserve_space(xdr, 3*8);
160 p = xdr_encode_hyper(p, args->src_offset);
161 p = xdr_encode_hyper(p, args->dst_offset);
162 xdr_encode_hyper(p, args->count);
163}
164
131/* 165/*
132 * Encode ALLOCATE request 166 * Encode ALLOCATE request
133 */ 167 */
@@ -206,6 +240,27 @@ static void nfs4_xdr_enc_layoutstats(struct rpc_rqst *req,
206 encode_nops(&hdr); 240 encode_nops(&hdr);
207} 241}
208 242
243/*
244 * Encode CLONE request
245 */
246static void nfs4_xdr_enc_clone(struct rpc_rqst *req,
247 struct xdr_stream *xdr,
248 struct nfs42_clone_args *args)
249{
250 struct compound_hdr hdr = {
251 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
252 };
253
254 encode_compound_hdr(xdr, req, &hdr);
255 encode_sequence(xdr, &args->seq_args, &hdr);
256 encode_putfh(xdr, args->src_fh, &hdr);
257 encode_savefh(xdr, &hdr);
258 encode_putfh(xdr, args->dst_fh, &hdr);
259 encode_clone(xdr, args, &hdr);
260 encode_getfattr(xdr, args->dst_bitmask, &hdr);
261 encode_nops(&hdr);
262}
263
209static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) 264static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
210{ 265{
211 return decode_op_hdr(xdr, OP_ALLOCATE); 266 return decode_op_hdr(xdr, OP_ALLOCATE);
@@ -243,6 +298,11 @@ static int decode_layoutstats(struct xdr_stream *xdr)
243 return decode_op_hdr(xdr, OP_LAYOUTSTATS); 298 return decode_op_hdr(xdr, OP_LAYOUTSTATS);
244} 299}
245 300
301static int decode_clone(struct xdr_stream *xdr)
302{
303 return decode_op_hdr(xdr, OP_CLONE);
304}
305
246/* 306/*
247 * Decode ALLOCATE request 307 * Decode ALLOCATE request
248 */ 308 */
@@ -351,4 +411,39 @@ out:
351 return status; 411 return status;
352} 412}
353 413
414/*
415 * Decode CLONE request
416 */
417static int nfs4_xdr_dec_clone(struct rpc_rqst *rqstp,
418 struct xdr_stream *xdr,
419 struct nfs42_clone_res *res)
420{
421 struct compound_hdr hdr;
422 int status;
423
424 status = decode_compound_hdr(xdr, &hdr);
425 if (status)
426 goto out;
427 status = decode_sequence(xdr, &res->seq_res, rqstp);
428 if (status)
429 goto out;
430 status = decode_putfh(xdr);
431 if (status)
432 goto out;
433 status = decode_savefh(xdr);
434 if (status)
435 goto out;
436 status = decode_putfh(xdr);
437 if (status)
438 goto out;
439 status = decode_clone(xdr);
440 if (status)
441 goto out;
442 status = decode_getfattr(xdr, res->dst_fattr, res->server);
443
444out:
445 res->rpc_status = status;
446 return status;
447}
448
354#endif /* __LINUX_FS_NFS_NFS4_2XDR_H */ 449#endif /* __LINUX_FS_NFS_NFS4_2XDR_H */