Blame view
fs/nfs/nfs42xdr.c
11.4 KB
1c6dcbe5c
|
1 2 3 4 5 |
/* * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> */ #ifndef __LINUX_FS_NFS_NFS4_2XDR_H #define __LINUX_FS_NFS_NFS4_2XDR_H |
be3a5d233
|
6 |
#include "nfs42.h" |
f4ac1674f
|
7 8 9 10 11 12 |
#define encode_fallocate_maxsz (encode_stateid_maxsz + \ 2 /* offset */ + \ 2 /* length */) #define encode_allocate_maxsz (op_encode_hdr_maxsz + \ encode_fallocate_maxsz) #define decode_allocate_maxsz (op_decode_hdr_maxsz) |
624bd5b7b
|
13 14 15 |
#define encode_deallocate_maxsz (op_encode_hdr_maxsz + \ encode_fallocate_maxsz) #define decode_deallocate_maxsz (op_decode_hdr_maxsz) |
1c6dcbe5c
|
16 17 18 19 20 21 22 23 24 |
#define encode_seek_maxsz (op_encode_hdr_maxsz + \ encode_stateid_maxsz + \ 2 /* offset */ + \ 1 /* whence */) #define decode_seek_maxsz (op_decode_hdr_maxsz + \ 1 /* eof */ + \ 1 /* whence */ + \ 2 /* offset */ + \ 2 /* length */) |
be3a5d233
|
25 26 27 28 29 30 31 32 33 34 |
#define encode_io_info_maxsz 4 #define encode_layoutstats_maxsz (op_decode_hdr_maxsz + \ 2 /* offset */ + \ 2 /* length */ + \ encode_stateid_maxsz + \ encode_io_info_maxsz + \ encode_io_info_maxsz + \ 1 /* opaque devaddr4 length */ + \ XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE)) #define decode_layoutstats_maxsz (op_decode_hdr_maxsz) |
36022770d
|
35 36 37 38 39 40 |
#define encode_clone_maxsz (encode_stateid_maxsz + \ encode_stateid_maxsz + \ 2 /* src offset */ + \ 2 /* dst offset */ + \ 2 /* count */) #define decode_clone_maxsz (op_decode_hdr_maxsz) |
1c6dcbe5c
|
41 |
|
f4ac1674f
|
42 43 |
#define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ |
9a51940bf
|
44 45 |
encode_allocate_maxsz + \ encode_getattr_maxsz) |
f4ac1674f
|
46 47 |
#define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ |
9a51940bf
|
48 49 |
decode_allocate_maxsz + \ decode_getattr_maxsz) |
624bd5b7b
|
50 51 |
#define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ |
9a51940bf
|
52 53 |
encode_deallocate_maxsz + \ encode_getattr_maxsz) |
624bd5b7b
|
54 55 |
#define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ |
9a51940bf
|
56 57 |
decode_deallocate_maxsz + \ decode_getattr_maxsz) |
1c6dcbe5c
|
58 59 60 61 62 63 |
#define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \ encode_putfh_maxsz + \ encode_seek_maxsz) #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \ decode_putfh_maxsz + \ decode_seek_maxsz) |
be3a5d233
|
64 65 66 67 68 69 70 71 |
#define NFS4_enc_layoutstats_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putfh_maxsz + \ PNFS_LAYOUTSTATS_MAXDEV * encode_layoutstats_maxsz) #define NFS4_dec_layoutstats_sz (compound_decode_hdr_maxsz + \ decode_sequence_maxsz + \ decode_putfh_maxsz + \ PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz) |
36022770d
|
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
#define NFS4_enc_clone_sz (compound_encode_hdr_maxsz + \ encode_sequence_maxsz + \ encode_putfh_maxsz + \ encode_savefh_maxsz + \ encode_putfh_maxsz + \ encode_clone_maxsz + \ encode_getattr_maxsz) #define NFS4_dec_clone_sz (compound_decode_hdr_maxsz + \ decode_sequence_maxsz + \ decode_putfh_maxsz + \ decode_savefh_maxsz + \ decode_putfh_maxsz + \ decode_clone_maxsz + \ decode_getattr_maxsz) |
1c6dcbe5c
|
86 |
|
f4ac1674f
|
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
static void encode_fallocate(struct xdr_stream *xdr, struct nfs42_falloc_args *args) { encode_nfs4_stateid(xdr, &args->falloc_stateid); encode_uint64(xdr, args->falloc_offset); encode_uint64(xdr, args->falloc_length); } static void encode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_args *args, struct compound_hdr *hdr) { encode_op_hdr(xdr, OP_ALLOCATE, decode_allocate_maxsz, hdr); encode_fallocate(xdr, args); } |
624bd5b7b
|
102 103 104 105 106 107 108 |
static void encode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_args *args, struct compound_hdr *hdr) { encode_op_hdr(xdr, OP_DEALLOCATE, decode_deallocate_maxsz, hdr); encode_fallocate(xdr, args); } |
1c6dcbe5c
|
109 110 111 112 113 114 115 116 117 |
static void encode_seek(struct xdr_stream *xdr, struct nfs42_seek_args *args, struct compound_hdr *hdr) { encode_op_hdr(xdr, OP_SEEK, decode_seek_maxsz, hdr); encode_nfs4_stateid(xdr, &args->sa_stateid); encode_uint64(xdr, args->sa_offset); encode_uint32(xdr, args->sa_what); } |
be3a5d233
|
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
static void encode_layoutstats(struct xdr_stream *xdr, struct nfs42_layoutstat_args *args, struct nfs42_layoutstat_devinfo *devinfo, struct compound_hdr *hdr) { __be32 *p; encode_op_hdr(xdr, OP_LAYOUTSTATS, decode_layoutstats_maxsz, hdr); p = reserve_space(xdr, 8 + 8); p = xdr_encode_hyper(p, devinfo->offset); p = xdr_encode_hyper(p, devinfo->length); encode_nfs4_stateid(xdr, &args->stateid); p = reserve_space(xdr, 4*8 + NFS4_DEVICEID4_SIZE + 4); p = xdr_encode_hyper(p, devinfo->read_count); p = xdr_encode_hyper(p, devinfo->read_bytes); p = xdr_encode_hyper(p, devinfo->write_count); p = xdr_encode_hyper(p, devinfo->write_bytes); p = xdr_encode_opaque_fixed(p, devinfo->dev_id.data, NFS4_DEVICEID4_SIZE); /* Encode layoutupdate4 */ *p++ = cpu_to_be32(devinfo->layout_type); if (devinfo->layoutstats_encode != NULL) devinfo->layoutstats_encode(xdr, args, devinfo); else encode_uint32(xdr, 0); } |
36022770d
|
144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
static void encode_clone(struct xdr_stream *xdr, struct nfs42_clone_args *args, struct compound_hdr *hdr) { __be32 *p; encode_op_hdr(xdr, OP_CLONE, decode_clone_maxsz, hdr); encode_nfs4_stateid(xdr, &args->src_stateid); encode_nfs4_stateid(xdr, &args->dst_stateid); p = reserve_space(xdr, 3*8); p = xdr_encode_hyper(p, args->src_offset); p = xdr_encode_hyper(p, args->dst_offset); xdr_encode_hyper(p, args->count); } |
1c6dcbe5c
|
158 |
/* |
f4ac1674f
|
159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
* Encode ALLOCATE request */ static void nfs4_xdr_enc_allocate(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs42_falloc_args *args) { struct compound_hdr hdr = { .minorversion = nfs4_xdr_minorversion(&args->seq_args), }; encode_compound_hdr(xdr, req, &hdr); encode_sequence(xdr, &args->seq_args, &hdr); encode_putfh(xdr, args->falloc_fh, &hdr); encode_allocate(xdr, args, &hdr); |
9a51940bf
|
173 |
encode_getfattr(xdr, args->falloc_bitmask, &hdr); |
f4ac1674f
|
174 175 176 177 |
encode_nops(&hdr); } /* |
624bd5b7b
|
178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
* Encode DEALLOCATE request */ static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs42_falloc_args *args) { struct compound_hdr hdr = { .minorversion = nfs4_xdr_minorversion(&args->seq_args), }; encode_compound_hdr(xdr, req, &hdr); encode_sequence(xdr, &args->seq_args, &hdr); encode_putfh(xdr, args->falloc_fh, &hdr); encode_deallocate(xdr, args, &hdr); |
9a51940bf
|
192 |
encode_getfattr(xdr, args->falloc_bitmask, &hdr); |
624bd5b7b
|
193 194 195 196 |
encode_nops(&hdr); } /* |
1c6dcbe5c
|
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
* Encode SEEK request */ static void nfs4_xdr_enc_seek(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs42_seek_args *args) { struct compound_hdr hdr = { .minorversion = nfs4_xdr_minorversion(&args->seq_args), }; encode_compound_hdr(xdr, req, &hdr); encode_sequence(xdr, &args->seq_args, &hdr); encode_putfh(xdr, args->sa_fh, &hdr); encode_seek(xdr, args, &hdr); encode_nops(&hdr); } |
be3a5d233
|
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
/* * Encode LAYOUTSTATS request */ static void nfs4_xdr_enc_layoutstats(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs42_layoutstat_args *args) { int i; struct compound_hdr hdr = { .minorversion = nfs4_xdr_minorversion(&args->seq_args), }; encode_compound_hdr(xdr, req, &hdr); encode_sequence(xdr, &args->seq_args, &hdr); encode_putfh(xdr, args->fh, &hdr); WARN_ON(args->num_dev > PNFS_LAYOUTSTATS_MAXDEV); for (i = 0; i < args->num_dev; i++) encode_layoutstats(xdr, args, &args->devinfo[i], &hdr); encode_nops(&hdr); } |
36022770d
|
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
/* * Encode CLONE request */ static void nfs4_xdr_enc_clone(struct rpc_rqst *req, struct xdr_stream *xdr, struct nfs42_clone_args *args) { struct compound_hdr hdr = { .minorversion = nfs4_xdr_minorversion(&args->seq_args), }; encode_compound_hdr(xdr, req, &hdr); encode_sequence(xdr, &args->seq_args, &hdr); encode_putfh(xdr, args->src_fh, &hdr); encode_savefh(xdr, &hdr); encode_putfh(xdr, args->dst_fh, &hdr); encode_clone(xdr, args, &hdr); encode_getfattr(xdr, args->dst_bitmask, &hdr); encode_nops(&hdr); } |
f4ac1674f
|
254 255 256 257 |
static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) { return decode_op_hdr(xdr, OP_ALLOCATE); } |
624bd5b7b
|
258 259 260 261 |
static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res) { return decode_op_hdr(xdr, OP_DEALLOCATE); } |
1c6dcbe5c
|
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res) { int status; __be32 *p; status = decode_op_hdr(xdr, OP_SEEK); if (status) return status; p = xdr_inline_decode(xdr, 4 + 8); if (unlikely(!p)) goto out_overflow; res->sr_eof = be32_to_cpup(p++); p = xdr_decode_hyper(p, &res->sr_offset); return 0; out_overflow: print_overflow_msg(__func__, xdr); return -EIO; } |
19cf63351
|
283 |
static int decode_layoutstats(struct xdr_stream *xdr) |
be3a5d233
|
284 |
{ |
da2e81275
|
285 |
return decode_op_hdr(xdr, OP_LAYOUTSTATS); |
be3a5d233
|
286 |
} |
36022770d
|
287 288 289 290 |
static int decode_clone(struct xdr_stream *xdr) { return decode_op_hdr(xdr, OP_CLONE); } |
1c6dcbe5c
|
291 |
/* |
f4ac1674f
|
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
* Decode ALLOCATE request */ static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp, struct xdr_stream *xdr, struct nfs42_falloc_res *res) { struct compound_hdr hdr; int status; status = decode_compound_hdr(xdr, &hdr); if (status) goto out; status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; status = decode_allocate(xdr, res); |
9a51940bf
|
311 312 313 |
if (status) goto out; decode_getfattr(xdr, res->falloc_fattr, res->falloc_server); |
f4ac1674f
|
314 315 316 317 318 |
out: return status; } /* |
624bd5b7b
|
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
* Decode DEALLOCATE request */ static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp, struct xdr_stream *xdr, struct nfs42_falloc_res *res) { struct compound_hdr hdr; int status; status = decode_compound_hdr(xdr, &hdr); if (status) goto out; status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; status = decode_deallocate(xdr, res); |
9a51940bf
|
338 339 340 |
if (status) goto out; decode_getfattr(xdr, res->falloc_fattr, res->falloc_server); |
624bd5b7b
|
341 342 343 344 345 |
out: return status; } /* |
1c6dcbe5c
|
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
* Decode SEEK request */ static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp, struct xdr_stream *xdr, struct nfs42_seek_res *res) { struct compound_hdr hdr; int status; status = decode_compound_hdr(xdr, &hdr); if (status) goto out; status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; status = decode_seek(xdr, res); out: return status; } |
be3a5d233
|
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
/* * Decode LAYOUTSTATS request */ static int nfs4_xdr_dec_layoutstats(struct rpc_rqst *rqstp, struct xdr_stream *xdr, struct nfs42_layoutstat_res *res) { struct compound_hdr hdr; int status, i; status = decode_compound_hdr(xdr, &hdr); if (status) goto out; status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; WARN_ON(res->num_dev > PNFS_LAYOUTSTATS_MAXDEV); for (i = 0; i < res->num_dev; i++) { |
19cf63351
|
390 |
status = decode_layoutstats(xdr); |
be3a5d233
|
391 392 393 394 395 396 397 |
if (status) goto out; } out: res->rpc_status = status; return status; } |
36022770d
|
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
/* * Decode CLONE request */ static int nfs4_xdr_dec_clone(struct rpc_rqst *rqstp, struct xdr_stream *xdr, struct nfs42_clone_res *res) { struct compound_hdr hdr; int status; status = decode_compound_hdr(xdr, &hdr); if (status) goto out; status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; status = decode_savefh(xdr); if (status) goto out; status = decode_putfh(xdr); if (status) goto out; status = decode_clone(xdr); if (status) goto out; status = decode_getfattr(xdr, res->dst_fattr, res->server); out: res->rpc_status = status; return status; } |
1c6dcbe5c
|
432 |
#endif /* __LINUX_FS_NFS_NFS4_2XDR_H */ |