xdr4.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. /*
  2. * Server-side types for NFSv4.
  3. *
  4. * Copyright (c) 2002 The Regents of the University of Michigan.
  5. * All rights reserved.
  6. *
  7. * Kendrick Smith <kmsmith@umich.edu>
  8. * Andy Adamson <andros@umich.edu>
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. *
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions and the following disclaimer.
  16. * 2. Redistributions in binary form must reproduce the above copyright
  17. * notice, this list of conditions and the following disclaimer in the
  18. * documentation and/or other materials provided with the distribution.
  19. * 3. Neither the name of the University nor the names of its
  20. * contributors may be used to endorse or promote products derived
  21. * from this software without specific prior written permission.
  22. *
  23. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  24. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  25. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  30. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  31. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. */
  36. #ifndef _LINUX_NFSD_XDR4_H
  37. #define _LINUX_NFSD_XDR4_H
  38. #include "state.h"
  39. #include "nfsd.h"
  40. #define NFSD4_MAX_TAGLEN 128
  41. #define XDR_LEN(n) (((n) + 3) & ~3)
  42. #define CURRENT_STATE_ID_FLAG (1<<0)
  43. #define SAVED_STATE_ID_FLAG (1<<1)
  44. #define SET_STATE_ID(c, f) ((c)->sid_flags |= (f))
  45. #define HAS_STATE_ID(c, f) ((c)->sid_flags & (f))
  46. #define CLEAR_STATE_ID(c, f) ((c)->sid_flags &= ~(f))
  47. struct nfsd4_compound_state {
  48. struct svc_fh current_fh;
  49. struct svc_fh save_fh;
  50. struct nfs4_stateowner *replay_owner;
  51. struct nfs4_client *clp;
  52. /* For sessions DRC */
  53. struct nfsd4_session *session;
  54. struct nfsd4_slot *slot;
  55. int data_offset;
  56. bool spo_must_allowed;
  57. size_t iovlen;
  58. u32 minorversion;
  59. __be32 status;
  60. stateid_t current_stateid;
  61. stateid_t save_stateid;
  62. /* to indicate current and saved state id presents */
  63. u32 sid_flags;
  64. };
  65. static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs)
  66. {
  67. return cs->slot != NULL;
  68. }
  69. struct nfsd4_change_info {
  70. u32 atomic;
  71. bool change_supported;
  72. u32 before_ctime_sec;
  73. u32 before_ctime_nsec;
  74. u64 before_change;
  75. u32 after_ctime_sec;
  76. u32 after_ctime_nsec;
  77. u64 after_change;
  78. };
  79. struct nfsd4_access {
  80. u32 ac_req_access; /* request */
  81. u32 ac_supported; /* response */
  82. u32 ac_resp_access; /* response */
  83. };
  84. struct nfsd4_close {
  85. u32 cl_seqid; /* request */
  86. stateid_t cl_stateid; /* request+response */
  87. };
  88. struct nfsd4_commit {
  89. u64 co_offset; /* request */
  90. u32 co_count; /* request */
  91. nfs4_verifier co_verf; /* response */
  92. };
  93. struct nfsd4_create {
  94. u32 cr_namelen; /* request */
  95. char * cr_name; /* request */
  96. u32 cr_type; /* request */
  97. union { /* request */
  98. struct {
  99. u32 datalen;
  100. char *data;
  101. struct kvec first;
  102. } link; /* NF4LNK */
  103. struct {
  104. u32 specdata1;
  105. u32 specdata2;
  106. } dev; /* NF4BLK, NF4CHR */
  107. } u;
  108. u32 cr_bmval[3]; /* request */
  109. struct iattr cr_iattr; /* request */
  110. struct nfsd4_change_info cr_cinfo; /* response */
  111. struct nfs4_acl *cr_acl;
  112. struct xdr_netobj cr_label;
  113. };
  114. #define cr_datalen u.link.datalen
  115. #define cr_data u.link.data
  116. #define cr_first u.link.first
  117. #define cr_specdata1 u.dev.specdata1
  118. #define cr_specdata2 u.dev.specdata2
  119. struct nfsd4_delegreturn {
  120. stateid_t dr_stateid;
  121. };
  122. struct nfsd4_getattr {
  123. u32 ga_bmval[3]; /* request */
  124. struct svc_fh *ga_fhp; /* response */
  125. };
  126. struct nfsd4_link {
  127. u32 li_namelen; /* request */
  128. char * li_name; /* request */
  129. struct nfsd4_change_info li_cinfo; /* response */
  130. };
  131. struct nfsd4_lock_denied {
  132. clientid_t ld_clientid;
  133. struct xdr_netobj ld_owner;
  134. u64 ld_start;
  135. u64 ld_length;
  136. u32 ld_type;
  137. };
  138. struct nfsd4_lock {
  139. /* request */
  140. u32 lk_type;
  141. u32 lk_reclaim; /* boolean */
  142. u64 lk_offset;
  143. u64 lk_length;
  144. u32 lk_is_new;
  145. union {
  146. struct {
  147. u32 open_seqid;
  148. stateid_t open_stateid;
  149. u32 lock_seqid;
  150. clientid_t clientid;
  151. struct xdr_netobj owner;
  152. } new;
  153. struct {
  154. stateid_t lock_stateid;
  155. u32 lock_seqid;
  156. } old;
  157. } v;
  158. /* response */
  159. union {
  160. struct {
  161. stateid_t stateid;
  162. } ok;
  163. struct nfsd4_lock_denied denied;
  164. } u;
  165. };
  166. #define lk_new_open_seqid v.new.open_seqid
  167. #define lk_new_open_stateid v.new.open_stateid
  168. #define lk_new_lock_seqid v.new.lock_seqid
  169. #define lk_new_clientid v.new.clientid
  170. #define lk_new_owner v.new.owner
  171. #define lk_old_lock_stateid v.old.lock_stateid
  172. #define lk_old_lock_seqid v.old.lock_seqid
  173. #define lk_resp_stateid u.ok.stateid
  174. #define lk_denied u.denied
  175. struct nfsd4_lockt {
  176. u32 lt_type;
  177. clientid_t lt_clientid;
  178. struct xdr_netobj lt_owner;
  179. u64 lt_offset;
  180. u64 lt_length;
  181. struct nfsd4_lock_denied lt_denied;
  182. };
  183. struct nfsd4_locku {
  184. u32 lu_type;
  185. u32 lu_seqid;
  186. stateid_t lu_stateid;
  187. u64 lu_offset;
  188. u64 lu_length;
  189. };
  190. struct nfsd4_lookup {
  191. u32 lo_len; /* request */
  192. char * lo_name; /* request */
  193. };
  194. struct nfsd4_putfh {
  195. u32 pf_fhlen; /* request */
  196. char *pf_fhval; /* request */
  197. };
  198. struct nfsd4_open {
  199. u32 op_claim_type; /* request */
  200. struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
  201. u32 op_delegate_type; /* request - CLAIM_PREV only */
  202. stateid_t op_delegate_stateid; /* request - response */
  203. u32 op_why_no_deleg; /* response - DELEG_NONE_EXT only */
  204. u32 op_create; /* request */
  205. u32 op_createmode; /* request */
  206. u32 op_bmval[3]; /* request */
  207. struct iattr op_iattr; /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
  208. nfs4_verifier op_verf __attribute__((aligned(32)));
  209. /* EXCLUSIVE4 */
  210. clientid_t op_clientid; /* request */
  211. struct xdr_netobj op_owner; /* request */
  212. u32 op_seqid; /* request */
  213. u32 op_share_access; /* request */
  214. u32 op_share_deny; /* request */
  215. u32 op_deleg_want; /* request */
  216. stateid_t op_stateid; /* response */
  217. __be32 op_xdr_error; /* see nfsd4_open_omfg() */
  218. u32 op_recall; /* recall */
  219. struct nfsd4_change_info op_cinfo; /* response */
  220. u32 op_rflags; /* response */
  221. bool op_truncate; /* used during processing */
  222. bool op_created; /* used during processing */
  223. struct nfs4_openowner *op_openowner; /* used during processing */
  224. struct nfs4_file *op_file; /* used during processing */
  225. struct nfs4_ol_stateid *op_stp; /* used during processing */
  226. struct nfs4_clnt_odstate *op_odstate; /* used during processing */
  227. struct nfs4_acl *op_acl;
  228. struct xdr_netobj op_label;
  229. };
  230. struct nfsd4_open_confirm {
  231. stateid_t oc_req_stateid /* request */;
  232. u32 oc_seqid /* request */;
  233. stateid_t oc_resp_stateid /* response */;
  234. };
  235. struct nfsd4_open_downgrade {
  236. stateid_t od_stateid;
  237. u32 od_seqid;
  238. u32 od_share_access; /* request */
  239. u32 od_deleg_want; /* request */
  240. u32 od_share_deny; /* request */
  241. };
  242. struct nfsd4_read {
  243. stateid_t rd_stateid; /* request */
  244. u64 rd_offset; /* request */
  245. u32 rd_length; /* request */
  246. int rd_vlen;
  247. struct file *rd_filp;
  248. bool rd_tmp_file;
  249. struct svc_rqst *rd_rqstp; /* response */
  250. struct svc_fh * rd_fhp; /* response */
  251. };
  252. struct nfsd4_readdir {
  253. u64 rd_cookie; /* request */
  254. nfs4_verifier rd_verf; /* request */
  255. u32 rd_dircount; /* request */
  256. u32 rd_maxcount; /* request */
  257. u32 rd_bmval[3]; /* request */
  258. struct svc_rqst *rd_rqstp; /* response */
  259. struct svc_fh * rd_fhp; /* response */
  260. struct readdir_cd common;
  261. struct xdr_stream *xdr;
  262. int cookie_offset;
  263. };
  264. struct nfsd4_release_lockowner {
  265. clientid_t rl_clientid;
  266. struct xdr_netobj rl_owner;
  267. };
  268. struct nfsd4_readlink {
  269. struct svc_rqst *rl_rqstp; /* request */
  270. struct svc_fh * rl_fhp; /* request */
  271. };
  272. struct nfsd4_remove {
  273. u32 rm_namelen; /* request */
  274. char * rm_name; /* request */
  275. struct nfsd4_change_info rm_cinfo; /* response */
  276. };
  277. struct nfsd4_rename {
  278. u32 rn_snamelen; /* request */
  279. char * rn_sname; /* request */
  280. u32 rn_tnamelen; /* request */
  281. char * rn_tname; /* request */
  282. struct nfsd4_change_info rn_sinfo; /* response */
  283. struct nfsd4_change_info rn_tinfo; /* response */
  284. };
  285. struct nfsd4_secinfo {
  286. u32 si_namelen; /* request */
  287. char *si_name; /* request */
  288. struct svc_export *si_exp; /* response */
  289. };
  290. struct nfsd4_secinfo_no_name {
  291. u32 sin_style; /* request */
  292. struct svc_export *sin_exp; /* response */
  293. };
  294. struct nfsd4_setattr {
  295. stateid_t sa_stateid; /* request */
  296. u32 sa_bmval[3]; /* request */
  297. struct iattr sa_iattr; /* request */
  298. struct nfs4_acl *sa_acl;
  299. struct xdr_netobj sa_label;
  300. };
  301. struct nfsd4_setclientid {
  302. nfs4_verifier se_verf; /* request */
  303. struct xdr_netobj se_name;
  304. u32 se_callback_prog; /* request */
  305. u32 se_callback_netid_len; /* request */
  306. char * se_callback_netid_val; /* request */
  307. u32 se_callback_addr_len; /* request */
  308. char * se_callback_addr_val; /* request */
  309. u32 se_callback_ident; /* request */
  310. clientid_t se_clientid; /* response */
  311. nfs4_verifier se_confirm; /* response */
  312. };
  313. struct nfsd4_setclientid_confirm {
  314. clientid_t sc_clientid;
  315. nfs4_verifier sc_confirm;
  316. };
  317. struct nfsd4_saved_compoundargs {
  318. __be32 *p;
  319. __be32 *end;
  320. int pagelen;
  321. struct page **pagelist;
  322. };
  323. struct nfsd4_test_stateid_id {
  324. __be32 ts_id_status;
  325. stateid_t ts_id_stateid;
  326. struct list_head ts_id_list;
  327. };
  328. struct nfsd4_test_stateid {
  329. u32 ts_num_ids;
  330. struct list_head ts_stateid_list;
  331. };
  332. struct nfsd4_free_stateid {
  333. stateid_t fr_stateid; /* request */
  334. };
  335. /* also used for NVERIFY */
  336. struct nfsd4_verify {
  337. u32 ve_bmval[3]; /* request */
  338. u32 ve_attrlen; /* request */
  339. char * ve_attrval; /* request */
  340. };
  341. struct nfsd4_write {
  342. stateid_t wr_stateid; /* request */
  343. u64 wr_offset; /* request */
  344. u32 wr_stable_how; /* request */
  345. u32 wr_buflen; /* request */
  346. struct kvec wr_head;
  347. struct page ** wr_pagelist; /* request */
  348. u32 wr_bytes_written; /* response */
  349. u32 wr_how_written; /* response */
  350. nfs4_verifier wr_verifier; /* response */
  351. };
  352. struct nfsd4_exchange_id {
  353. nfs4_verifier verifier;
  354. struct xdr_netobj clname;
  355. u32 flags;
  356. clientid_t clientid;
  357. u32 seqid;
  358. int spa_how;
  359. u32 spo_must_enforce[3];
  360. u32 spo_must_allow[3];
  361. };
  362. struct nfsd4_sequence {
  363. struct nfs4_sessionid sessionid; /* request/response */
  364. u32 seqid; /* request/response */
  365. u32 slotid; /* request/response */
  366. u32 maxslots; /* request/response */
  367. u32 cachethis; /* request */
  368. #if 0
  369. u32 target_maxslots; /* response */
  370. #endif /* not yet */
  371. u32 status_flags; /* response */
  372. };
  373. struct nfsd4_destroy_session {
  374. struct nfs4_sessionid sessionid;
  375. };
  376. struct nfsd4_destroy_clientid {
  377. clientid_t clientid;
  378. };
  379. struct nfsd4_reclaim_complete {
  380. u32 rca_one_fs;
  381. };
  382. struct nfsd4_deviceid {
  383. u64 fsid_idx;
  384. u32 generation;
  385. u32 pad;
  386. };
  387. struct nfsd4_layout_seg {
  388. u32 iomode;
  389. u64 offset;
  390. u64 length;
  391. };
  392. struct nfsd4_getdeviceinfo {
  393. struct nfsd4_deviceid gd_devid; /* request */
  394. u32 gd_layout_type; /* request */
  395. u32 gd_maxcount; /* request */
  396. u32 gd_notify_types;/* request - response */
  397. void *gd_device; /* response */
  398. };
  399. struct nfsd4_layoutget {
  400. u64 lg_minlength; /* request */
  401. u32 lg_signal; /* request */
  402. u32 lg_layout_type; /* request */
  403. u32 lg_maxcount; /* request */
  404. stateid_t lg_sid; /* request/response */
  405. struct nfsd4_layout_seg lg_seg; /* request/response */
  406. void *lg_content; /* response */
  407. };
  408. struct nfsd4_layoutcommit {
  409. stateid_t lc_sid; /* request */
  410. struct nfsd4_layout_seg lc_seg; /* request */
  411. u32 lc_reclaim; /* request */
  412. u32 lc_newoffset; /* request */
  413. u64 lc_last_wr; /* request */
  414. struct timespec lc_mtime; /* request */
  415. u32 lc_layout_type; /* request */
  416. u32 lc_up_len; /* layout length */
  417. void *lc_up_layout; /* decoded by callback */
  418. u32 lc_size_chg; /* boolean for response */
  419. u64 lc_newsize; /* response */
  420. };
  421. struct nfsd4_layoutreturn {
  422. u32 lr_return_type; /* request */
  423. u32 lr_layout_type; /* request */
  424. struct nfsd4_layout_seg lr_seg; /* request */
  425. u32 lr_reclaim; /* request */
  426. u32 lrf_body_len; /* request */
  427. void *lrf_body; /* request */
  428. stateid_t lr_sid; /* request/response */
  429. u32 lrs_present; /* response */
  430. };
  431. struct nfsd4_fallocate {
  432. /* request */
  433. stateid_t falloc_stateid;
  434. loff_t falloc_offset;
  435. u64 falloc_length;
  436. };
  437. struct nfsd4_clone {
  438. /* request */
  439. stateid_t cl_src_stateid;
  440. stateid_t cl_dst_stateid;
  441. u64 cl_src_pos;
  442. u64 cl_dst_pos;
  443. u64 cl_count;
  444. };
  445. struct nfsd42_write_res {
  446. u64 wr_bytes_written;
  447. u32 wr_stable_how;
  448. nfs4_verifier wr_verifier;
  449. };
  450. struct nfsd4_copy {
  451. /* request */
  452. stateid_t cp_src_stateid;
  453. stateid_t cp_dst_stateid;
  454. u64 cp_src_pos;
  455. u64 cp_dst_pos;
  456. u64 cp_count;
  457. /* both */
  458. bool cp_synchronous;
  459. /* response */
  460. struct nfsd42_write_res cp_res;
  461. };
  462. struct nfsd4_seek {
  463. /* request */
  464. stateid_t seek_stateid;
  465. loff_t seek_offset;
  466. u32 seek_whence;
  467. /* response */
  468. u32 seek_eof;
  469. loff_t seek_pos;
  470. };
  471. struct nfsd4_op {
  472. int opnum;
  473. const struct nfsd4_operation * opdesc;
  474. __be32 status;
  475. union nfsd4_op_u {
  476. struct nfsd4_access access;
  477. struct nfsd4_close close;
  478. struct nfsd4_commit commit;
  479. struct nfsd4_create create;
  480. struct nfsd4_delegreturn delegreturn;
  481. struct nfsd4_getattr getattr;
  482. struct svc_fh * getfh;
  483. struct nfsd4_link link;
  484. struct nfsd4_lock lock;
  485. struct nfsd4_lockt lockt;
  486. struct nfsd4_locku locku;
  487. struct nfsd4_lookup lookup;
  488. struct nfsd4_verify nverify;
  489. struct nfsd4_open open;
  490. struct nfsd4_open_confirm open_confirm;
  491. struct nfsd4_open_downgrade open_downgrade;
  492. struct nfsd4_putfh putfh;
  493. struct nfsd4_read read;
  494. struct nfsd4_readdir readdir;
  495. struct nfsd4_readlink readlink;
  496. struct nfsd4_remove remove;
  497. struct nfsd4_rename rename;
  498. clientid_t renew;
  499. struct nfsd4_secinfo secinfo;
  500. struct nfsd4_setattr setattr;
  501. struct nfsd4_setclientid setclientid;
  502. struct nfsd4_setclientid_confirm setclientid_confirm;
  503. struct nfsd4_verify verify;
  504. struct nfsd4_write write;
  505. struct nfsd4_release_lockowner release_lockowner;
  506. /* NFSv4.1 */
  507. struct nfsd4_exchange_id exchange_id;
  508. struct nfsd4_backchannel_ctl backchannel_ctl;
  509. struct nfsd4_bind_conn_to_session bind_conn_to_session;
  510. struct nfsd4_create_session create_session;
  511. struct nfsd4_destroy_session destroy_session;
  512. struct nfsd4_destroy_clientid destroy_clientid;
  513. struct nfsd4_sequence sequence;
  514. struct nfsd4_reclaim_complete reclaim_complete;
  515. struct nfsd4_test_stateid test_stateid;
  516. struct nfsd4_free_stateid free_stateid;
  517. struct nfsd4_getdeviceinfo getdeviceinfo;
  518. struct nfsd4_layoutget layoutget;
  519. struct nfsd4_layoutcommit layoutcommit;
  520. struct nfsd4_layoutreturn layoutreturn;
  521. struct nfsd4_secinfo_no_name secinfo_no_name;
  522. /* NFSv4.2 */
  523. struct nfsd4_fallocate allocate;
  524. struct nfsd4_fallocate deallocate;
  525. struct nfsd4_clone clone;
  526. struct nfsd4_copy copy;
  527. struct nfsd4_seek seek;
  528. } u;
  529. struct nfs4_replay * replay;
  530. };
  531. bool nfsd4_cache_this_op(struct nfsd4_op *);
  532. /*
  533. * Memory needed just for the duration of processing one compound:
  534. */
  535. struct svcxdr_tmpbuf {
  536. struct svcxdr_tmpbuf *next;
  537. char buf[];
  538. };
  539. struct nfsd4_compoundargs {
  540. /* scratch variables for XDR decode */
  541. __be32 * p;
  542. __be32 * end;
  543. struct page ** pagelist;
  544. int pagelen;
  545. bool tail;
  546. __be32 tmp[8];
  547. __be32 * tmpp;
  548. struct svcxdr_tmpbuf *to_free;
  549. struct svc_rqst *rqstp;
  550. u32 taglen;
  551. char * tag;
  552. u32 minorversion;
  553. u32 opcnt;
  554. struct nfsd4_op *ops;
  555. struct nfsd4_op iops[8];
  556. int cachetype;
  557. };
  558. struct nfsd4_compoundres {
  559. /* scratch variables for XDR encode */
  560. struct xdr_stream xdr;
  561. struct svc_rqst * rqstp;
  562. u32 taglen;
  563. char * tag;
  564. u32 opcnt;
  565. __be32 * tagp; /* tag, opcount encode location */
  566. struct nfsd4_compound_state cstate;
  567. };
  568. static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
  569. {
  570. struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
  571. return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
  572. }
  573. /*
  574. * The session reply cache only needs to cache replies that the client
  575. * actually asked us to. But it's almost free for us to cache compounds
  576. * consisting of only a SEQUENCE op, so we may as well cache those too.
  577. * Also, the protocol doesn't give us a convenient response in the case
  578. * of a replay of a solo SEQUENCE op that wasn't cached
  579. * (RETRY_UNCACHED_REP can only be returned in the second op of a
  580. * compound).
  581. */
  582. static inline bool nfsd4_cache_this(struct nfsd4_compoundres *resp)
  583. {
  584. return (resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS)
  585. || nfsd4_is_solo_sequence(resp);
  586. }
  587. static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp)
  588. {
  589. struct nfsd4_compoundres *resp = rqstp->rq_resp;
  590. struct nfsd4_compoundargs *argp = rqstp->rq_argp;
  591. return argp->opcnt == resp->opcnt;
  592. }
  593. const struct nfsd4_operation *OPDESC(struct nfsd4_op *op);
  594. int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op);
  595. void warn_on_nonidempotent_op(struct nfsd4_op *op);
  596. #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
  597. static inline void
  598. set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
  599. {
  600. BUG_ON(!fhp->fh_pre_saved);
  601. cinfo->atomic = (u32)fhp->fh_post_saved;
  602. cinfo->change_supported = IS_I_VERSION(d_inode(fhp->fh_dentry));
  603. cinfo->before_change = fhp->fh_pre_change;
  604. cinfo->after_change = fhp->fh_post_change;
  605. cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
  606. cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
  607. cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
  608. cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
  609. }
  610. bool nfsd4_mach_creds_match(struct nfs4_client *cl, struct svc_rqst *rqstp);
  611. int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *);
  612. int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *);
  613. int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *);
  614. __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);
  615. void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
  616. void nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op);
  617. __be32 nfsd4_encode_fattr_to_buf(__be32 **p, int words,
  618. struct svc_fh *fhp, struct svc_export *exp,
  619. struct dentry *dentry,
  620. u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
  621. extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
  622. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  623. extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
  624. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  625. extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
  626. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  627. extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *,
  628. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  629. extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *,
  630. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  631. extern __be32 nfsd4_create_session(struct svc_rqst *,
  632. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  633. extern __be32 nfsd4_sequence(struct svc_rqst *,
  634. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  635. extern void nfsd4_sequence_done(struct nfsd4_compoundres *resp);
  636. extern __be32 nfsd4_destroy_session(struct svc_rqst *,
  637. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  638. extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *,
  639. union nfsd4_op_u *u);
  640. __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *,
  641. union nfsd4_op_u *u);
  642. extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
  643. struct nfsd4_open *open, struct nfsd_net *nn);
  644. extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
  645. struct svc_fh *current_fh, struct nfsd4_open *open);
  646. extern void nfsd4_cstate_clear_replay(struct nfsd4_compound_state *cstate);
  647. extern void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate,
  648. struct nfsd4_open *open);
  649. extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
  650. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  651. extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  652. union nfsd4_op_u *u);
  653. extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
  654. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  655. extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  656. union nfsd4_op_u *u);
  657. extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  658. union nfsd4_op_u *u);
  659. extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  660. union nfsd4_op_u *u);
  661. extern __be32
  662. nfsd4_release_lockowner(struct svc_rqst *rqstp,
  663. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  664. extern void nfsd4_release_compoundargs(struct svc_rqst *rqstp);
  665. extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
  666. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  667. extern __be32 nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  668. union nfsd4_op_u *u);
  669. extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp,
  670. struct nfsd4_compound_state *, union nfsd4_op_u *);
  671. extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp,
  672. struct nfsd4_compound_state *, union nfsd4_op_u *);
  673. extern void nfsd4_bump_seqid(struct nfsd4_compound_state *, __be32 nfserr);
  674. enum nfsd4_op_flags {
  675. ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */
  676. ALLOWED_ON_ABSENT_FS = 1 << 1, /* ops processed on absent fs */
  677. ALLOWED_AS_FIRST_OP = 1 << 2, /* ops reqired first in compound */
  678. /* For rfc 5661 section 2.6.3.1.1: */
  679. OP_HANDLES_WRONGSEC = 1 << 3,
  680. OP_IS_PUTFH_LIKE = 1 << 4,
  681. /*
  682. * These are the ops whose result size we estimate before
  683. * encoding, to avoid performing an op then not being able to
  684. * respond or cache a response. This includes writes and setattrs
  685. * as well as the operations usually called "nonidempotent":
  686. */
  687. OP_MODIFIES_SOMETHING = 1 << 5,
  688. /*
  689. * Cache compounds containing these ops in the xid-based drc:
  690. * We use the DRC for compounds containing non-idempotent
  691. * operations, *except* those that are 4.1-specific (since
  692. * sessions provide their own EOS), and except for stateful
  693. * operations other than setclientid and setclientid_confirm
  694. * (since sequence numbers provide EOS for open, lock, etc in
  695. * the v4.0 case).
  696. */
  697. OP_CACHEME = 1 << 6,
  698. /*
  699. * These are ops which clear current state id.
  700. */
  701. OP_CLEAR_STATEID = 1 << 7,
  702. /* Most ops return only an error on failure; some may do more: */
  703. OP_NONTRIVIAL_ERROR_ENCODE = 1 << 8,
  704. };
  705. struct nfsd4_operation {
  706. __be32 (*op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
  707. union nfsd4_op_u *);
  708. void (*op_release)(union nfsd4_op_u *);
  709. u32 op_flags;
  710. char *op_name;
  711. /* Try to get response size before operation */
  712. u32 (*op_rsize_bop)(struct svc_rqst *, struct nfsd4_op *);
  713. void (*op_get_currentstateid)(struct nfsd4_compound_state *,
  714. union nfsd4_op_u *);
  715. void (*op_set_currentstateid)(struct nfsd4_compound_state *,
  716. union nfsd4_op_u *);
  717. };
  718. #endif
  719. /*
  720. * Local variables:
  721. * c-basic-offset: 8
  722. * End:
  723. */