nfs42xdr.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com>
  4. */
  5. #ifndef __LINUX_FS_NFS_NFS4_2XDR_H
  6. #define __LINUX_FS_NFS_NFS4_2XDR_H
  7. #include "nfs42.h"
  8. #define encode_fallocate_maxsz (encode_stateid_maxsz + \
  9. 2 /* offset */ + \
  10. 2 /* length */)
  11. #define NFS42_WRITE_RES_SIZE (1 /* wr_callback_id size */ +\
  12. XDR_QUADLEN(NFS4_STATEID_SIZE) + \
  13. 2 /* wr_count */ + \
  14. 1 /* wr_committed */ + \
  15. XDR_QUADLEN(NFS4_VERIFIER_SIZE))
  16. #define encode_allocate_maxsz (op_encode_hdr_maxsz + \
  17. encode_fallocate_maxsz)
  18. #define decode_allocate_maxsz (op_decode_hdr_maxsz)
  19. #define encode_copy_maxsz (op_encode_hdr_maxsz + \
  20. XDR_QUADLEN(NFS4_STATEID_SIZE) + \
  21. XDR_QUADLEN(NFS4_STATEID_SIZE) + \
  22. 2 + 2 + 2 + 1 + 1 + 1)
  23. #define decode_copy_maxsz (op_decode_hdr_maxsz + \
  24. NFS42_WRITE_RES_SIZE + \
  25. 1 /* cr_consecutive */ + \
  26. 1 /* cr_synchronous */)
  27. #define encode_offload_cancel_maxsz (op_encode_hdr_maxsz + \
  28. XDR_QUADLEN(NFS4_STATEID_SIZE))
  29. #define decode_offload_cancel_maxsz (op_decode_hdr_maxsz)
  30. #define encode_deallocate_maxsz (op_encode_hdr_maxsz + \
  31. encode_fallocate_maxsz)
  32. #define decode_deallocate_maxsz (op_decode_hdr_maxsz)
  33. #define encode_seek_maxsz (op_encode_hdr_maxsz + \
  34. encode_stateid_maxsz + \
  35. 2 /* offset */ + \
  36. 1 /* whence */)
  37. #define decode_seek_maxsz (op_decode_hdr_maxsz + \
  38. 1 /* eof */ + \
  39. 1 /* whence */ + \
  40. 2 /* offset */ + \
  41. 2 /* length */)
  42. #define encode_io_info_maxsz 4
  43. #define encode_layoutstats_maxsz (op_decode_hdr_maxsz + \
  44. 2 /* offset */ + \
  45. 2 /* length */ + \
  46. encode_stateid_maxsz + \
  47. encode_io_info_maxsz + \
  48. encode_io_info_maxsz + \
  49. 1 /* opaque devaddr4 length */ + \
  50. XDR_QUADLEN(PNFS_LAYOUTSTATS_MAXSIZE))
  51. #define decode_layoutstats_maxsz (op_decode_hdr_maxsz)
  52. #define encode_clone_maxsz (encode_stateid_maxsz + \
  53. encode_stateid_maxsz + \
  54. 2 /* src offset */ + \
  55. 2 /* dst offset */ + \
  56. 2 /* count */)
  57. #define decode_clone_maxsz (op_decode_hdr_maxsz)
  58. #define NFS4_enc_allocate_sz (compound_encode_hdr_maxsz + \
  59. encode_putfh_maxsz + \
  60. encode_allocate_maxsz + \
  61. encode_getattr_maxsz)
  62. #define NFS4_dec_allocate_sz (compound_decode_hdr_maxsz + \
  63. decode_putfh_maxsz + \
  64. decode_allocate_maxsz + \
  65. decode_getattr_maxsz)
  66. #define NFS4_enc_copy_sz (compound_encode_hdr_maxsz + \
  67. encode_putfh_maxsz + \
  68. encode_savefh_maxsz + \
  69. encode_putfh_maxsz + \
  70. encode_copy_maxsz + \
  71. encode_commit_maxsz)
  72. #define NFS4_dec_copy_sz (compound_decode_hdr_maxsz + \
  73. decode_putfh_maxsz + \
  74. decode_savefh_maxsz + \
  75. decode_putfh_maxsz + \
  76. decode_copy_maxsz + \
  77. decode_commit_maxsz)
  78. #define NFS4_enc_offload_cancel_sz (compound_encode_hdr_maxsz + \
  79. encode_putfh_maxsz + \
  80. encode_offload_cancel_maxsz)
  81. #define NFS4_dec_offload_cancel_sz (compound_decode_hdr_maxsz + \
  82. decode_putfh_maxsz + \
  83. decode_offload_cancel_maxsz)
  84. #define NFS4_enc_deallocate_sz (compound_encode_hdr_maxsz + \
  85. encode_putfh_maxsz + \
  86. encode_deallocate_maxsz + \
  87. encode_getattr_maxsz)
  88. #define NFS4_dec_deallocate_sz (compound_decode_hdr_maxsz + \
  89. decode_putfh_maxsz + \
  90. decode_deallocate_maxsz + \
  91. decode_getattr_maxsz)
  92. #define NFS4_enc_seek_sz (compound_encode_hdr_maxsz + \
  93. encode_putfh_maxsz + \
  94. encode_seek_maxsz)
  95. #define NFS4_dec_seek_sz (compound_decode_hdr_maxsz + \
  96. decode_putfh_maxsz + \
  97. decode_seek_maxsz)
  98. #define NFS4_enc_layoutstats_sz (compound_encode_hdr_maxsz + \
  99. encode_sequence_maxsz + \
  100. encode_putfh_maxsz + \
  101. PNFS_LAYOUTSTATS_MAXDEV * encode_layoutstats_maxsz)
  102. #define NFS4_dec_layoutstats_sz (compound_decode_hdr_maxsz + \
  103. decode_sequence_maxsz + \
  104. decode_putfh_maxsz + \
  105. PNFS_LAYOUTSTATS_MAXDEV * decode_layoutstats_maxsz)
  106. #define NFS4_enc_clone_sz (compound_encode_hdr_maxsz + \
  107. encode_sequence_maxsz + \
  108. encode_putfh_maxsz + \
  109. encode_savefh_maxsz + \
  110. encode_putfh_maxsz + \
  111. encode_clone_maxsz + \
  112. encode_getattr_maxsz)
  113. #define NFS4_dec_clone_sz (compound_decode_hdr_maxsz + \
  114. decode_sequence_maxsz + \
  115. decode_putfh_maxsz + \
  116. decode_savefh_maxsz + \
  117. decode_putfh_maxsz + \
  118. decode_clone_maxsz + \
  119. decode_getattr_maxsz)
  120. static void encode_fallocate(struct xdr_stream *xdr,
  121. const struct nfs42_falloc_args *args)
  122. {
  123. encode_nfs4_stateid(xdr, &args->falloc_stateid);
  124. encode_uint64(xdr, args->falloc_offset);
  125. encode_uint64(xdr, args->falloc_length);
  126. }
  127. static void encode_allocate(struct xdr_stream *xdr,
  128. const struct nfs42_falloc_args *args,
  129. struct compound_hdr *hdr)
  130. {
  131. encode_op_hdr(xdr, OP_ALLOCATE, decode_allocate_maxsz, hdr);
  132. encode_fallocate(xdr, args);
  133. }
  134. static void encode_copy(struct xdr_stream *xdr,
  135. const struct nfs42_copy_args *args,
  136. struct compound_hdr *hdr)
  137. {
  138. encode_op_hdr(xdr, OP_COPY, decode_copy_maxsz, hdr);
  139. encode_nfs4_stateid(xdr, &args->src_stateid);
  140. encode_nfs4_stateid(xdr, &args->dst_stateid);
  141. encode_uint64(xdr, args->src_pos);
  142. encode_uint64(xdr, args->dst_pos);
  143. encode_uint64(xdr, args->count);
  144. encode_uint32(xdr, 1); /* consecutive = true */
  145. encode_uint32(xdr, args->sync);
  146. encode_uint32(xdr, 0); /* src server list */
  147. }
  148. static void encode_offload_cancel(struct xdr_stream *xdr,
  149. const struct nfs42_offload_status_args *args,
  150. struct compound_hdr *hdr)
  151. {
  152. encode_op_hdr(xdr, OP_OFFLOAD_CANCEL, decode_offload_cancel_maxsz, hdr);
  153. encode_nfs4_stateid(xdr, &args->osa_stateid);
  154. }
  155. static void encode_deallocate(struct xdr_stream *xdr,
  156. const struct nfs42_falloc_args *args,
  157. struct compound_hdr *hdr)
  158. {
  159. encode_op_hdr(xdr, OP_DEALLOCATE, decode_deallocate_maxsz, hdr);
  160. encode_fallocate(xdr, args);
  161. }
  162. static void encode_seek(struct xdr_stream *xdr,
  163. const struct nfs42_seek_args *args,
  164. struct compound_hdr *hdr)
  165. {
  166. encode_op_hdr(xdr, OP_SEEK, decode_seek_maxsz, hdr);
  167. encode_nfs4_stateid(xdr, &args->sa_stateid);
  168. encode_uint64(xdr, args->sa_offset);
  169. encode_uint32(xdr, args->sa_what);
  170. }
  171. static void encode_layoutstats(struct xdr_stream *xdr,
  172. const struct nfs42_layoutstat_args *args,
  173. struct nfs42_layoutstat_devinfo *devinfo,
  174. struct compound_hdr *hdr)
  175. {
  176. __be32 *p;
  177. encode_op_hdr(xdr, OP_LAYOUTSTATS, decode_layoutstats_maxsz, hdr);
  178. p = reserve_space(xdr, 8 + 8);
  179. p = xdr_encode_hyper(p, devinfo->offset);
  180. p = xdr_encode_hyper(p, devinfo->length);
  181. encode_nfs4_stateid(xdr, &args->stateid);
  182. p = reserve_space(xdr, 4*8 + NFS4_DEVICEID4_SIZE + 4);
  183. p = xdr_encode_hyper(p, devinfo->read_count);
  184. p = xdr_encode_hyper(p, devinfo->read_bytes);
  185. p = xdr_encode_hyper(p, devinfo->write_count);
  186. p = xdr_encode_hyper(p, devinfo->write_bytes);
  187. p = xdr_encode_opaque_fixed(p, devinfo->dev_id.data,
  188. NFS4_DEVICEID4_SIZE);
  189. /* Encode layoutupdate4 */
  190. *p++ = cpu_to_be32(devinfo->layout_type);
  191. if (devinfo->ld_private.ops)
  192. devinfo->ld_private.ops->encode(xdr, args,
  193. &devinfo->ld_private);
  194. else
  195. encode_uint32(xdr, 0);
  196. }
  197. static void encode_clone(struct xdr_stream *xdr,
  198. const struct nfs42_clone_args *args,
  199. struct compound_hdr *hdr)
  200. {
  201. __be32 *p;
  202. encode_op_hdr(xdr, OP_CLONE, decode_clone_maxsz, hdr);
  203. encode_nfs4_stateid(xdr, &args->src_stateid);
  204. encode_nfs4_stateid(xdr, &args->dst_stateid);
  205. p = reserve_space(xdr, 3*8);
  206. p = xdr_encode_hyper(p, args->src_offset);
  207. p = xdr_encode_hyper(p, args->dst_offset);
  208. xdr_encode_hyper(p, args->count);
  209. }
  210. /*
  211. * Encode ALLOCATE request
  212. */
  213. static void nfs4_xdr_enc_allocate(struct rpc_rqst *req,
  214. struct xdr_stream *xdr,
  215. const void *data)
  216. {
  217. const struct nfs42_falloc_args *args = data;
  218. struct compound_hdr hdr = {
  219. .minorversion = nfs4_xdr_minorversion(&args->seq_args),
  220. };
  221. encode_compound_hdr(xdr, req, &hdr);
  222. encode_sequence(xdr, &args->seq_args, &hdr);
  223. encode_putfh(xdr, args->falloc_fh, &hdr);
  224. encode_allocate(xdr, args, &hdr);
  225. encode_getfattr(xdr, args->falloc_bitmask, &hdr);
  226. encode_nops(&hdr);
  227. }
  228. static void encode_copy_commit(struct xdr_stream *xdr,
  229. const struct nfs42_copy_args *args,
  230. struct compound_hdr *hdr)
  231. {
  232. __be32 *p;
  233. encode_op_hdr(xdr, OP_COMMIT, decode_commit_maxsz, hdr);
  234. p = reserve_space(xdr, 12);
  235. p = xdr_encode_hyper(p, args->dst_pos);
  236. *p = cpu_to_be32(args->count);
  237. }
  238. /*
  239. * Encode COPY request
  240. */
  241. static void nfs4_xdr_enc_copy(struct rpc_rqst *req,
  242. struct xdr_stream *xdr,
  243. const void *data)
  244. {
  245. const struct nfs42_copy_args *args = data;
  246. struct compound_hdr hdr = {
  247. .minorversion = nfs4_xdr_minorversion(&args->seq_args),
  248. };
  249. encode_compound_hdr(xdr, req, &hdr);
  250. encode_sequence(xdr, &args->seq_args, &hdr);
  251. encode_putfh(xdr, args->src_fh, &hdr);
  252. encode_savefh(xdr, &hdr);
  253. encode_putfh(xdr, args->dst_fh, &hdr);
  254. encode_copy(xdr, args, &hdr);
  255. if (args->sync)
  256. encode_copy_commit(xdr, args, &hdr);
  257. encode_nops(&hdr);
  258. }
  259. /*
  260. * Encode OFFLOAD_CANEL request
  261. */
  262. static void nfs4_xdr_enc_offload_cancel(struct rpc_rqst *req,
  263. struct xdr_stream *xdr,
  264. const void *data)
  265. {
  266. const struct nfs42_offload_status_args *args = data;
  267. struct compound_hdr hdr = {
  268. .minorversion = nfs4_xdr_minorversion(&args->osa_seq_args),
  269. };
  270. encode_compound_hdr(xdr, req, &hdr);
  271. encode_sequence(xdr, &args->osa_seq_args, &hdr);
  272. encode_putfh(xdr, args->osa_src_fh, &hdr);
  273. encode_offload_cancel(xdr, args, &hdr);
  274. encode_nops(&hdr);
  275. }
  276. /*
  277. * Encode DEALLOCATE request
  278. */
  279. static void nfs4_xdr_enc_deallocate(struct rpc_rqst *req,
  280. struct xdr_stream *xdr,
  281. const void *data)
  282. {
  283. const struct nfs42_falloc_args *args = data;
  284. struct compound_hdr hdr = {
  285. .minorversion = nfs4_xdr_minorversion(&args->seq_args),
  286. };
  287. encode_compound_hdr(xdr, req, &hdr);
  288. encode_sequence(xdr, &args->seq_args, &hdr);
  289. encode_putfh(xdr, args->falloc_fh, &hdr);
  290. encode_deallocate(xdr, args, &hdr);
  291. encode_getfattr(xdr, args->falloc_bitmask, &hdr);
  292. encode_nops(&hdr);
  293. }
  294. /*
  295. * Encode SEEK request
  296. */
  297. static void nfs4_xdr_enc_seek(struct rpc_rqst *req,
  298. struct xdr_stream *xdr,
  299. const void *data)
  300. {
  301. const struct nfs42_seek_args *args = data;
  302. struct compound_hdr hdr = {
  303. .minorversion = nfs4_xdr_minorversion(&args->seq_args),
  304. };
  305. encode_compound_hdr(xdr, req, &hdr);
  306. encode_sequence(xdr, &args->seq_args, &hdr);
  307. encode_putfh(xdr, args->sa_fh, &hdr);
  308. encode_seek(xdr, args, &hdr);
  309. encode_nops(&hdr);
  310. }
  311. /*
  312. * Encode LAYOUTSTATS request
  313. */
  314. static void nfs4_xdr_enc_layoutstats(struct rpc_rqst *req,
  315. struct xdr_stream *xdr,
  316. const void *data)
  317. {
  318. const struct nfs42_layoutstat_args *args = data;
  319. int i;
  320. struct compound_hdr hdr = {
  321. .minorversion = nfs4_xdr_minorversion(&args->seq_args),
  322. };
  323. encode_compound_hdr(xdr, req, &hdr);
  324. encode_sequence(xdr, &args->seq_args, &hdr);
  325. encode_putfh(xdr, args->fh, &hdr);
  326. WARN_ON(args->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
  327. for (i = 0; i < args->num_dev; i++)
  328. encode_layoutstats(xdr, args, &args->devinfo[i], &hdr);
  329. encode_nops(&hdr);
  330. }
  331. /*
  332. * Encode CLONE request
  333. */
  334. static void nfs4_xdr_enc_clone(struct rpc_rqst *req,
  335. struct xdr_stream *xdr,
  336. const void *data)
  337. {
  338. const struct nfs42_clone_args *args = data;
  339. struct compound_hdr hdr = {
  340. .minorversion = nfs4_xdr_minorversion(&args->seq_args),
  341. };
  342. encode_compound_hdr(xdr, req, &hdr);
  343. encode_sequence(xdr, &args->seq_args, &hdr);
  344. encode_putfh(xdr, args->src_fh, &hdr);
  345. encode_savefh(xdr, &hdr);
  346. encode_putfh(xdr, args->dst_fh, &hdr);
  347. encode_clone(xdr, args, &hdr);
  348. encode_getfattr(xdr, args->dst_bitmask, &hdr);
  349. encode_nops(&hdr);
  350. }
  351. static int decode_allocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
  352. {
  353. return decode_op_hdr(xdr, OP_ALLOCATE);
  354. }
  355. static int decode_write_response(struct xdr_stream *xdr,
  356. struct nfs42_write_res *res)
  357. {
  358. __be32 *p;
  359. int status, count;
  360. p = xdr_inline_decode(xdr, 4);
  361. if (unlikely(!p))
  362. goto out_overflow;
  363. count = be32_to_cpup(p);
  364. if (count > 1)
  365. return -EREMOTEIO;
  366. else if (count == 1) {
  367. status = decode_opaque_fixed(xdr, &res->stateid,
  368. NFS4_STATEID_SIZE);
  369. if (unlikely(status))
  370. goto out_overflow;
  371. }
  372. p = xdr_inline_decode(xdr, 8 + 4);
  373. if (unlikely(!p))
  374. goto out_overflow;
  375. p = xdr_decode_hyper(p, &res->count);
  376. res->verifier.committed = be32_to_cpup(p);
  377. return decode_verifier(xdr, &res->verifier.verifier);
  378. out_overflow:
  379. print_overflow_msg(__func__, xdr);
  380. return -EIO;
  381. }
  382. static int decode_copy_requirements(struct xdr_stream *xdr,
  383. struct nfs42_copy_res *res) {
  384. __be32 *p;
  385. p = xdr_inline_decode(xdr, 4 + 4);
  386. if (unlikely(!p))
  387. goto out_overflow;
  388. res->consecutive = be32_to_cpup(p++);
  389. res->synchronous = be32_to_cpup(p++);
  390. return 0;
  391. out_overflow:
  392. print_overflow_msg(__func__, xdr);
  393. return -EIO;
  394. }
  395. static int decode_copy(struct xdr_stream *xdr, struct nfs42_copy_res *res)
  396. {
  397. int status;
  398. status = decode_op_hdr(xdr, OP_COPY);
  399. if (status == NFS4ERR_OFFLOAD_NO_REQS) {
  400. status = decode_copy_requirements(xdr, res);
  401. if (status)
  402. return status;
  403. return NFS4ERR_OFFLOAD_NO_REQS;
  404. } else if (status)
  405. return status;
  406. status = decode_write_response(xdr, &res->write_res);
  407. if (status)
  408. return status;
  409. return decode_copy_requirements(xdr, res);
  410. }
  411. static int decode_offload_cancel(struct xdr_stream *xdr,
  412. struct nfs42_offload_status_res *res)
  413. {
  414. return decode_op_hdr(xdr, OP_OFFLOAD_CANCEL);
  415. }
  416. static int decode_deallocate(struct xdr_stream *xdr, struct nfs42_falloc_res *res)
  417. {
  418. return decode_op_hdr(xdr, OP_DEALLOCATE);
  419. }
  420. static int decode_seek(struct xdr_stream *xdr, struct nfs42_seek_res *res)
  421. {
  422. int status;
  423. __be32 *p;
  424. status = decode_op_hdr(xdr, OP_SEEK);
  425. if (status)
  426. return status;
  427. p = xdr_inline_decode(xdr, 4 + 8);
  428. if (unlikely(!p))
  429. goto out_overflow;
  430. res->sr_eof = be32_to_cpup(p++);
  431. p = xdr_decode_hyper(p, &res->sr_offset);
  432. return 0;
  433. out_overflow:
  434. print_overflow_msg(__func__, xdr);
  435. return -EIO;
  436. }
  437. static int decode_layoutstats(struct xdr_stream *xdr)
  438. {
  439. return decode_op_hdr(xdr, OP_LAYOUTSTATS);
  440. }
  441. static int decode_clone(struct xdr_stream *xdr)
  442. {
  443. return decode_op_hdr(xdr, OP_CLONE);
  444. }
  445. /*
  446. * Decode ALLOCATE request
  447. */
  448. static int nfs4_xdr_dec_allocate(struct rpc_rqst *rqstp,
  449. struct xdr_stream *xdr,
  450. void *data)
  451. {
  452. struct nfs42_falloc_res *res = data;
  453. struct compound_hdr hdr;
  454. int status;
  455. status = decode_compound_hdr(xdr, &hdr);
  456. if (status)
  457. goto out;
  458. status = decode_sequence(xdr, &res->seq_res, rqstp);
  459. if (status)
  460. goto out;
  461. status = decode_putfh(xdr);
  462. if (status)
  463. goto out;
  464. status = decode_allocate(xdr, res);
  465. if (status)
  466. goto out;
  467. decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
  468. out:
  469. return status;
  470. }
  471. /*
  472. * Decode COPY response
  473. */
  474. static int nfs4_xdr_dec_copy(struct rpc_rqst *rqstp,
  475. struct xdr_stream *xdr,
  476. void *data)
  477. {
  478. struct nfs42_copy_res *res = data;
  479. struct compound_hdr hdr;
  480. int status;
  481. status = decode_compound_hdr(xdr, &hdr);
  482. if (status)
  483. goto out;
  484. status = decode_sequence(xdr, &res->seq_res, rqstp);
  485. if (status)
  486. goto out;
  487. status = decode_putfh(xdr);
  488. if (status)
  489. goto out;
  490. status = decode_savefh(xdr);
  491. if (status)
  492. goto out;
  493. status = decode_putfh(xdr);
  494. if (status)
  495. goto out;
  496. status = decode_copy(xdr, res);
  497. if (status)
  498. goto out;
  499. if (res->commit_res.verf)
  500. status = decode_commit(xdr, &res->commit_res);
  501. out:
  502. return status;
  503. }
  504. /*
  505. * Decode OFFLOAD_CANCEL response
  506. */
  507. static int nfs4_xdr_dec_offload_cancel(struct rpc_rqst *rqstp,
  508. struct xdr_stream *xdr,
  509. void *data)
  510. {
  511. struct nfs42_offload_status_res *res = data;
  512. struct compound_hdr hdr;
  513. int status;
  514. status = decode_compound_hdr(xdr, &hdr);
  515. if (status)
  516. goto out;
  517. status = decode_sequence(xdr, &res->osr_seq_res, rqstp);
  518. if (status)
  519. goto out;
  520. status = decode_putfh(xdr);
  521. if (status)
  522. goto out;
  523. status = decode_offload_cancel(xdr, res);
  524. out:
  525. return status;
  526. }
  527. /*
  528. * Decode DEALLOCATE request
  529. */
  530. static int nfs4_xdr_dec_deallocate(struct rpc_rqst *rqstp,
  531. struct xdr_stream *xdr,
  532. void *data)
  533. {
  534. struct nfs42_falloc_res *res = data;
  535. struct compound_hdr hdr;
  536. int status;
  537. status = decode_compound_hdr(xdr, &hdr);
  538. if (status)
  539. goto out;
  540. status = decode_sequence(xdr, &res->seq_res, rqstp);
  541. if (status)
  542. goto out;
  543. status = decode_putfh(xdr);
  544. if (status)
  545. goto out;
  546. status = decode_deallocate(xdr, res);
  547. if (status)
  548. goto out;
  549. decode_getfattr(xdr, res->falloc_fattr, res->falloc_server);
  550. out:
  551. return status;
  552. }
  553. /*
  554. * Decode SEEK request
  555. */
  556. static int nfs4_xdr_dec_seek(struct rpc_rqst *rqstp,
  557. struct xdr_stream *xdr,
  558. void *data)
  559. {
  560. struct nfs42_seek_res *res = data;
  561. struct compound_hdr hdr;
  562. int status;
  563. status = decode_compound_hdr(xdr, &hdr);
  564. if (status)
  565. goto out;
  566. status = decode_sequence(xdr, &res->seq_res, rqstp);
  567. if (status)
  568. goto out;
  569. status = decode_putfh(xdr);
  570. if (status)
  571. goto out;
  572. status = decode_seek(xdr, res);
  573. out:
  574. return status;
  575. }
  576. /*
  577. * Decode LAYOUTSTATS request
  578. */
  579. static int nfs4_xdr_dec_layoutstats(struct rpc_rqst *rqstp,
  580. struct xdr_stream *xdr,
  581. void *data)
  582. {
  583. struct nfs42_layoutstat_res *res = data;
  584. struct compound_hdr hdr;
  585. int status, i;
  586. status = decode_compound_hdr(xdr, &hdr);
  587. if (status)
  588. goto out;
  589. status = decode_sequence(xdr, &res->seq_res, rqstp);
  590. if (status)
  591. goto out;
  592. status = decode_putfh(xdr);
  593. if (status)
  594. goto out;
  595. WARN_ON(res->num_dev > PNFS_LAYOUTSTATS_MAXDEV);
  596. for (i = 0; i < res->num_dev; i++) {
  597. status = decode_layoutstats(xdr);
  598. if (status)
  599. goto out;
  600. }
  601. out:
  602. res->rpc_status = status;
  603. return status;
  604. }
  605. /*
  606. * Decode CLONE request
  607. */
  608. static int nfs4_xdr_dec_clone(struct rpc_rqst *rqstp,
  609. struct xdr_stream *xdr,
  610. void *data)
  611. {
  612. struct nfs42_clone_res *res = data;
  613. struct compound_hdr hdr;
  614. int status;
  615. status = decode_compound_hdr(xdr, &hdr);
  616. if (status)
  617. goto out;
  618. status = decode_sequence(xdr, &res->seq_res, rqstp);
  619. if (status)
  620. goto out;
  621. status = decode_putfh(xdr);
  622. if (status)
  623. goto out;
  624. status = decode_savefh(xdr);
  625. if (status)
  626. goto out;
  627. status = decode_putfh(xdr);
  628. if (status)
  629. goto out;
  630. status = decode_clone(xdr);
  631. if (status)
  632. goto out;
  633. status = decode_getfattr(xdr, res->dst_fattr, res->server);
  634. out:
  635. res->rpc_status = status;
  636. return status;
  637. }
  638. #endif /* __LINUX_FS_NFS_NFS4_2XDR_H */