diff options
Diffstat (limited to 'fs/nfs/nfs42xdr.c')
-rw-r--r-- | fs/nfs/nfs42xdr.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index c90469b604b8..4248d034479c 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c | |||
@@ -4,6 +4,12 @@ | |||
4 | #ifndef __LINUX_FS_NFS_NFS4_2XDR_H | 4 | #ifndef __LINUX_FS_NFS_NFS4_2XDR_H |
5 | #define __LINUX_FS_NFS_NFS4_2XDR_H | 5 | #define __LINUX_FS_NFS_NFS4_2XDR_H |
6 | 6 | ||
7 | #define encode_fallocate_maxsz (encode_stateid_maxsz + \ | ||
8 | 2 /* offset */ + \ | ||
9 | 2 /* length */) | ||
10 | #define encode_allocate_maxsz (op_encode_hdr_maxsz + \ | ||
11 | encode_fallocate_maxsz) | ||
12 | #define decode_allocate_maxsz (op_decode_hdr_maxsz) | ||
7 | #define encode_seek_maxsz (op_encode_hdr_maxsz + \ | 13 | #define encode_seek_maxsz (op_encode_hdr_maxsz + \ |
8 | encode_stateid_maxsz + \ | 14 | encode_stateid_maxsz + \ |
9 | 2 /* offset */ + \ | 15 | 2 /* offset */ + \ |
@@ -14,6 +20,12 @@ | |||
14 | 2 /* offset */ + \ | 20 | 2 /* offset */ + \ |
15 | 2 /* length */) | 21 | 2 /* length */) |
16 | 22 | ||
23 | #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \ | ||
24 | encode_putfh_maxsz + \ | ||
25 | encode_allocate_maxsz) | ||
26 | #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \ | ||
27 | decode_putfh_maxsz + \ | ||
28 | decode_allocate_maxsz) | ||
17 | #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \ | 29 | #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \ |
18 | encode_putfh_maxsz + \ | 30 | encode_putfh_maxsz + \ |
19 | encode_seek_maxsz) | 31 | encode_seek_maxsz) |
@@ -22,6 +34,22 @@ | |||
22 | decode_seek_maxsz) | 34 | decode_seek_maxsz) |
23 | 35 | ||
24 | 36 | ||
37 | static void encode_fallocate(struct xdr_stream *xdr, | ||
38 | struct nfs42_falloc_args *args) | ||
39 | { | ||
40 | encode_nfs4_stateid(xdr, &args->falloc_stateid); | ||
41 | encode_uint64(xdr, args->falloc_offset); | ||
42 | encode_uint64(xdr, args->falloc_length); | ||
43 | } | ||
44 | |||
45 | static void encode_allocate(struct xdr_stream *xdr, | ||
46 | struct nfs42_falloc_args *args, | ||
47 | struct compound_hdr *hdr) | ||
48 | { | ||
49 | encode_op_hdr(xdr, OP_ALLOCATE, decode_allocate_maxsz, hdr); | ||
50 | encode_fallocate(xdr, args); | ||
51 | } | ||
52 | |||
25 | static void encode_seek(struct xdr_stream *xdr, | 53 | static void encode_seek(struct xdr_stream *xdr, |
26 | struct nfs42_seek_args *args, | 54 | struct nfs42_seek_args *args, |
27 | struct compound_hdr *hdr) | 55 | struct compound_hdr *hdr) |
@@ -33,6 +61,24 @@ static void encode_seek(struct xdr_stream *xdr, | |||
33 | } | 61 | } |
34 | 62 | ||
35 | /* | 63 | /* |
64 | * Encode ALLOCATE request | ||
65 | */ | ||
66 | static void nfs4_xdr_enc_allocate(struct rpc_rqst *req, | ||
67 | struct xdr_stream *xdr, | ||
68 | struct nfs42_falloc_args *args) | ||
69 | { | ||
70 | struct compound_hdr hdr = { | ||
71 | .minorversion = nfs4_xdr_minorversion(&args->seq_args), | ||
72 | }; | ||
73 | |||
74 | encode_compound_hdr(xdr, req, &hdr); | ||
75 | encode_sequence(xdr, &args->seq_args, &hdr); | ||
76 | encode_putfh(xdr, args->falloc_fh, &hdr); | ||
77 | encode_allocate(xdr, args, &hdr); | ||
78 | encode_nops(&hdr); | ||
79 | } | ||
80 | |||
81 | /* | ||
36 | * Encode SEEK request | 82 | * Encode SEEK request |
37 | */ | 83 | */ |
38 | static void nfs4_xdr_enc_seek(struct rpc_rqst *req, | 84 | static void nfs4_xdr_enc_seek(struct rpc_rqst *req, |
@@ -50,6 +96,11 @@ static void nfs4_xdr_enc_seek(struct rpc_rqst *req, | |||
50 | encode_nops(&hdr); | 96 | encode_nops(&hdr); |
51 | } | 97 | } |
52 | 98 | ||
99 | static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) | ||
100 | { | ||
101 | return decode_op_hdr(xdr, OP_ALLOCATE); | ||
102 | } | ||
103 | |||
53 | static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) | 104 | static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) |
54 | { | 105 | { |
55 | int status; | 106 | int status; |
@@ -73,6 +124,30 @@ out_overflow: | |||
73 | } | 124 | } |
74 | 125 | ||
75 | /* | 126 | /* |
127 | * Decode ALLOCATE request | ||
128 | */ | ||
129 | static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp, | ||
130 | struct xdr_stream *xdr, | ||
131 | struct nfs42_falloc_res *res) | ||
132 | { | ||
133 | struct compound_hdr hdr; | ||
134 | int status; | ||
135 | |||
136 | status = decode_compound_hdr(xdr, &hdr); | ||
137 | if (status) | ||
138 | goto out; | ||
139 | status = decode_sequence(xdr, &res->seq_res, rqstp); | ||
140 | if (status) | ||
141 | goto out; | ||
142 | status = decode_putfh(xdr); | ||
143 | if (status) | ||
144 | goto out; | ||
145 | status = decode_allocate(xdr, res); | ||
146 | out: | ||
147 | return status; | ||
148 | } | ||
149 | |||
150 | /* | ||
76 | * Decode SEEK request | 151 | * Decode SEEK request |
77 | */ | 152 | */ |
78 | static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp, | 153 | static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp, |