aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs42xdr.c
diff options
context:
space:
mode:
authorAnna Schumaker <Anna.Schumaker@netapp.com>2014-11-25 13:18:16 -0500
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-11-25 16:38:32 -0500
commit624bd5b7b683c978c6d5f4e9f6142cfb3470983d (patch)
treedcbe9728ea9a6ef12b57c63aec6b34b872a42542 /fs/nfs/nfs42xdr.c
parentf4ac1674f5da420ef17896f0f222c5215ebcde80 (diff)
nfs: Add DEALLOCATE support
This patch adds support for using the NFS v4.2 operation DEALLOCATE to punch holes in a file. Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/nfs42xdr.c')
-rw-r--r--fs/nfs/nfs42xdr.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c
index 4248d034479c..038a7e1521fa 100644
--- a/fs/nfs/nfs42xdr.c
+++ b/fs/nfs/nfs42xdr.c
@@ -10,6 +10,9 @@
10#define encode_allocate_maxsz (op_encode_hdr_maxsz + \ 10#define encode_allocate_maxsz (op_encode_hdr_maxsz + \
11 encode_fallocate_maxsz) 11 encode_fallocate_maxsz)
12#define decode_allocate_maxsz (op_decode_hdr_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)
13#define encode_seek_maxsz (op_encode_hdr_maxsz + \ 16#define encode_seek_maxsz (op_encode_hdr_maxsz + \
14 encode_stateid_maxsz + \ 17 encode_stateid_maxsz + \
15 2 /* offset */ + \ 18 2 /* offset */ + \
@@ -26,6 +29,12 @@
26#define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \ 29#define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
27 decode_putfh_maxsz + \ 30 decode_putfh_maxsz + \
28 decode_allocate_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)
29#define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \ 38#define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
30 encode_putfh_maxsz + \ 39 encode_putfh_maxsz + \
31 encode_seek_maxsz) 40 encode_seek_maxsz)
@@ -50,6 +59,14 @@ static void encode_allocate(struct xdr_stream *xdr,
50 encode_fallocate(xdr, args); 59 encode_fallocate(xdr, args);
51} 60}
52 61
62static void encode_deallocate(struct xdr_stream *xdr,
63 struct nfs42_falloc_args *args,
64 struct compound_hdr *hdr)
65{
66 encode_op_hdr(xdr, OP_DEALLOCATE, decode_deallocate_maxsz, hdr);
67 encode_fallocate(xdr, args);
68}
69
53static void encode_seek(struct xdr_stream *xdr, 70static void encode_seek(struct xdr_stream *xdr,
54 struct nfs42_seek_args *args, 71 struct nfs42_seek_args *args,
55 struct compound_hdr *hdr) 72 struct compound_hdr *hdr)
@@ -79,6 +96,24 @@ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
79} 96}
80 97
81/* 98/*
99 * Encode DEALLOCATE request
100 */
101static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req,
102 struct xdr_stream *xdr,
103 struct nfs42_falloc_args *args)
104{
105 struct compound_hdr hdr = {
106 .minorversion = nfs4_xdr_minorversion(&args->seq_args),
107 };
108
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);
113 encode_nops(&hdr);
114}
115
116/*
82 * Encode SEEK request 117 * Encode SEEK request
83 */ 118 */
84static void nfs4_xdr_enc_seek(struct rpc_rqst *req, 119static void nfs4_xdr_enc_seek(struct rpc_rqst *req,
@@ -101,6 +136,11 @@ static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
101 return decode_op_hdr(xdr, OP_ALLOCATE); 136 return decode_op_hdr(xdr, OP_ALLOCATE);
102} 137}
103 138
139static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
140{
141 return decode_op_hdr(xdr, OP_DEALLOCATE);
142}
143
104static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) 144static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res)
105{ 145{
106 int status; 146 int status;
@@ -148,6 +188,30 @@ out:
148} 188}
149 189
150/* 190/*
191 * Decode DEALLOCATE request
192 */
193static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp,
194 struct xdr_stream *xdr,
195 struct nfs42_falloc_res *res)
196{
197 struct compound_hdr hdr;
198 int status;
199
200 status = decode_compound_hdr(xdr, &hdr);
201 if (status)
202 goto out;
203 status = decode_sequence(xdr, &res->seq_res, rqstp);
204 if (status)
205 goto out;
206 status = decode_putfh(xdr);
207 if (status)
208 goto out;
209 status = decode_deallocate(xdr, res);
210out:
211 return status;
212}
213
214/*
151 * Decode SEEK request 215 * Decode SEEK request
152 */ 216 */
153static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp, 217static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp,