xdr4.h 24 KB

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