xdr4.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  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_CSTATE_FLAG(c, f) ((c)->sid_flags |= (f))
  45. #define HAS_CSTATE_FLAG(c, f) ((c)->sid_flags & (f))
  46. #define CLEAR_CSTATE_FLAG(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. bool no_verify; /* represents foreigh fh */
  199. };
  200. struct nfsd4_getxattr {
  201. char *getxa_name; /* request */
  202. u32 getxa_len; /* request */
  203. void *getxa_buf;
  204. };
  205. struct nfsd4_setxattr {
  206. u32 setxa_flags; /* request */
  207. char *setxa_name; /* request */
  208. char *setxa_buf; /* request */
  209. u32 setxa_len; /* request */
  210. struct nfsd4_change_info setxa_cinfo; /* response */
  211. };
  212. struct nfsd4_removexattr {
  213. char *rmxa_name; /* request */
  214. struct nfsd4_change_info rmxa_cinfo; /* response */
  215. };
  216. struct nfsd4_listxattrs {
  217. u64 lsxa_cookie; /* request */
  218. u32 lsxa_maxcount; /* request */
  219. char *lsxa_buf; /* unfiltered buffer (reply) */
  220. u32 lsxa_len; /* unfiltered len (reply) */
  221. };
  222. struct nfsd4_open {
  223. u32 op_claim_type; /* request */
  224. struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */
  225. u32 op_delegate_type; /* request - CLAIM_PREV only */
  226. stateid_t op_delegate_stateid; /* request - response */
  227. u32 op_why_no_deleg; /* response - DELEG_NONE_EXT only */
  228. u32 op_create; /* request */
  229. u32 op_createmode; /* request */
  230. int op_umask; /* request */
  231. u32 op_bmval[3]; /* request */
  232. struct iattr op_iattr; /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */
  233. nfs4_verifier op_verf __attribute__((aligned(32)));
  234. /* EXCLUSIVE4 */
  235. clientid_t op_clientid; /* request */
  236. struct xdr_netobj op_owner; /* request */
  237. u32 op_seqid; /* request */
  238. u32 op_share_access; /* request */
  239. u32 op_share_deny; /* request */
  240. u32 op_deleg_want; /* request */
  241. stateid_t op_stateid; /* response */
  242. __be32 op_xdr_error; /* see nfsd4_open_omfg() */
  243. u32 op_recall; /* recall */
  244. struct nfsd4_change_info op_cinfo; /* response */
  245. u32 op_rflags; /* response */
  246. bool op_truncate; /* used during processing */
  247. bool op_created; /* used during processing */
  248. struct nfs4_openowner *op_openowner; /* used during processing */
  249. struct nfs4_file *op_file; /* used during processing */
  250. struct nfs4_ol_stateid *op_stp; /* used during processing */
  251. struct nfs4_clnt_odstate *op_odstate; /* used during processing */
  252. struct nfs4_acl *op_acl;
  253. struct xdr_netobj op_label;
  254. };
  255. struct nfsd4_open_confirm {
  256. stateid_t oc_req_stateid /* request */;
  257. u32 oc_seqid /* request */;
  258. stateid_t oc_resp_stateid /* response */;
  259. };
  260. struct nfsd4_open_downgrade {
  261. stateid_t od_stateid;
  262. u32 od_seqid;
  263. u32 od_share_access; /* request */
  264. u32 od_deleg_want; /* request */
  265. u32 od_share_deny; /* request */
  266. };
  267. struct nfsd4_read {
  268. stateid_t rd_stateid; /* request */
  269. u64 rd_offset; /* request */
  270. u32 rd_length; /* request */
  271. int rd_vlen;
  272. struct nfsd_file *rd_nf;
  273. struct svc_rqst *rd_rqstp; /* response */
  274. struct svc_fh *rd_fhp; /* response */
  275. };
  276. struct nfsd4_readdir {
  277. u64 rd_cookie; /* request */
  278. nfs4_verifier rd_verf; /* request */
  279. u32 rd_dircount; /* request */
  280. u32 rd_maxcount; /* request */
  281. u32 rd_bmval[3]; /* request */
  282. struct svc_rqst *rd_rqstp; /* response */
  283. struct svc_fh * rd_fhp; /* response */
  284. struct readdir_cd common;
  285. struct xdr_stream *xdr;
  286. int cookie_offset;
  287. };
  288. struct nfsd4_release_lockowner {
  289. clientid_t rl_clientid;
  290. struct xdr_netobj rl_owner;
  291. };
  292. struct nfsd4_readlink {
  293. struct svc_rqst *rl_rqstp; /* request */
  294. struct svc_fh * rl_fhp; /* request */
  295. };
  296. struct nfsd4_remove {
  297. u32 rm_namelen; /* request */
  298. char * rm_name; /* request */
  299. struct nfsd4_change_info rm_cinfo; /* response */
  300. };
  301. struct nfsd4_rename {
  302. u32 rn_snamelen; /* request */
  303. char * rn_sname; /* request */
  304. u32 rn_tnamelen; /* request */
  305. char * rn_tname; /* request */
  306. struct nfsd4_change_info rn_sinfo; /* response */
  307. struct nfsd4_change_info rn_tinfo; /* response */
  308. };
  309. struct nfsd4_secinfo {
  310. u32 si_namelen; /* request */
  311. char *si_name; /* request */
  312. struct svc_export *si_exp; /* response */
  313. };
  314. struct nfsd4_secinfo_no_name {
  315. u32 sin_style; /* request */
  316. struct svc_export *sin_exp; /* response */
  317. };
  318. struct nfsd4_setattr {
  319. stateid_t sa_stateid; /* request */
  320. u32 sa_bmval[3]; /* request */
  321. struct iattr sa_iattr; /* request */
  322. struct nfs4_acl *sa_acl;
  323. struct xdr_netobj sa_label;
  324. };
  325. struct nfsd4_setclientid {
  326. nfs4_verifier se_verf; /* request */
  327. struct xdr_netobj se_name;
  328. u32 se_callback_prog; /* request */
  329. u32 se_callback_netid_len; /* request */
  330. char * se_callback_netid_val; /* request */
  331. u32 se_callback_addr_len; /* request */
  332. char * se_callback_addr_val; /* request */
  333. u32 se_callback_ident; /* request */
  334. clientid_t se_clientid; /* response */
  335. nfs4_verifier se_confirm; /* response */
  336. };
  337. struct nfsd4_setclientid_confirm {
  338. clientid_t sc_clientid;
  339. nfs4_verifier sc_confirm;
  340. };
  341. struct nfsd4_saved_compoundargs {
  342. __be32 *p;
  343. __be32 *end;
  344. int pagelen;
  345. struct page **pagelist;
  346. };
  347. struct nfsd4_test_stateid_id {
  348. __be32 ts_id_status;
  349. stateid_t ts_id_stateid;
  350. struct list_head ts_id_list;
  351. };
  352. struct nfsd4_test_stateid {
  353. u32 ts_num_ids;
  354. struct list_head ts_stateid_list;
  355. };
  356. struct nfsd4_free_stateid {
  357. stateid_t fr_stateid; /* request */
  358. };
  359. /* also used for NVERIFY */
  360. struct nfsd4_verify {
  361. u32 ve_bmval[3]; /* request */
  362. u32 ve_attrlen; /* request */
  363. char * ve_attrval; /* request */
  364. };
  365. struct nfsd4_write {
  366. stateid_t wr_stateid; /* request */
  367. u64 wr_offset; /* request */
  368. u32 wr_stable_how; /* request */
  369. u32 wr_buflen; /* request */
  370. struct kvec wr_head;
  371. struct page ** wr_pagelist; /* request */
  372. u32 wr_bytes_written; /* response */
  373. u32 wr_how_written; /* response */
  374. nfs4_verifier wr_verifier; /* response */
  375. };
  376. struct nfsd4_exchange_id {
  377. nfs4_verifier verifier;
  378. struct xdr_netobj clname;
  379. u32 flags;
  380. clientid_t clientid;
  381. u32 seqid;
  382. int spa_how;
  383. u32 spo_must_enforce[3];
  384. u32 spo_must_allow[3];
  385. struct xdr_netobj nii_domain;
  386. struct xdr_netobj nii_name;
  387. struct timespec64 nii_time;
  388. };
  389. struct nfsd4_sequence {
  390. struct nfs4_sessionid sessionid; /* request/response */
  391. u32 seqid; /* request/response */
  392. u32 slotid; /* request/response */
  393. u32 maxslots; /* request/response */
  394. u32 cachethis; /* request */
  395. #if 0
  396. u32 target_maxslots; /* response */
  397. #endif /* not yet */
  398. u32 status_flags; /* response */
  399. };
  400. struct nfsd4_destroy_session {
  401. struct nfs4_sessionid sessionid;
  402. };
  403. struct nfsd4_destroy_clientid {
  404. clientid_t clientid;
  405. };
  406. struct nfsd4_reclaim_complete {
  407. u32 rca_one_fs;
  408. };
  409. struct nfsd4_deviceid {
  410. u64 fsid_idx;
  411. u32 generation;
  412. u32 pad;
  413. };
  414. struct nfsd4_layout_seg {
  415. u32 iomode;
  416. u64 offset;
  417. u64 length;
  418. };
  419. struct nfsd4_getdeviceinfo {
  420. struct nfsd4_deviceid gd_devid; /* request */
  421. u32 gd_layout_type; /* request */
  422. u32 gd_maxcount; /* request */
  423. u32 gd_notify_types;/* request - response */
  424. void *gd_device; /* response */
  425. };
  426. struct nfsd4_layoutget {
  427. u64 lg_minlength; /* request */
  428. u32 lg_signal; /* request */
  429. u32 lg_layout_type; /* request */
  430. u32 lg_maxcount; /* request */
  431. stateid_t lg_sid; /* request/response */
  432. struct nfsd4_layout_seg lg_seg; /* request/response */
  433. void *lg_content; /* response */
  434. };
  435. struct nfsd4_layoutcommit {
  436. stateid_t lc_sid; /* request */
  437. struct nfsd4_layout_seg lc_seg; /* request */
  438. u32 lc_reclaim; /* request */
  439. u32 lc_newoffset; /* request */
  440. u64 lc_last_wr; /* request */
  441. struct timespec64 lc_mtime; /* request */
  442. u32 lc_layout_type; /* request */
  443. u32 lc_up_len; /* layout length */
  444. void *lc_up_layout; /* decoded by callback */
  445. u32 lc_size_chg; /* boolean for response */
  446. u64 lc_newsize; /* response */
  447. };
  448. struct nfsd4_layoutreturn {
  449. u32 lr_return_type; /* request */
  450. u32 lr_layout_type; /* request */
  451. struct nfsd4_layout_seg lr_seg; /* request */
  452. u32 lr_reclaim; /* request */
  453. u32 lrf_body_len; /* request */
  454. void *lrf_body; /* request */
  455. stateid_t lr_sid; /* request/response */
  456. u32 lrs_present; /* response */
  457. };
  458. struct nfsd4_fallocate {
  459. /* request */
  460. stateid_t falloc_stateid;
  461. loff_t falloc_offset;
  462. u64 falloc_length;
  463. };
  464. struct nfsd4_clone {
  465. /* request */
  466. stateid_t cl_src_stateid;
  467. stateid_t cl_dst_stateid;
  468. u64 cl_src_pos;
  469. u64 cl_dst_pos;
  470. u64 cl_count;
  471. };
  472. struct nfsd42_write_res {
  473. u64 wr_bytes_written;
  474. u32 wr_stable_how;
  475. nfs4_verifier wr_verifier;
  476. stateid_t cb_stateid;
  477. };
  478. struct nfsd4_copy {
  479. /* request */
  480. stateid_t cp_src_stateid;
  481. stateid_t cp_dst_stateid;
  482. u64 cp_src_pos;
  483. u64 cp_dst_pos;
  484. u64 cp_count;
  485. struct nl4_server cp_src;
  486. bool cp_intra;
  487. /* both */
  488. bool cp_synchronous;
  489. /* response */
  490. struct nfsd42_write_res cp_res;
  491. /* for cb_offload */
  492. struct nfsd4_callback cp_cb;
  493. __be32 nfserr;
  494. struct knfsd_fh fh;
  495. struct nfs4_client *cp_clp;
  496. struct nfsd_file *nf_src;
  497. struct nfsd_file *nf_dst;
  498. copy_stateid_t cp_stateid;
  499. struct list_head copies;
  500. struct task_struct *copy_task;
  501. refcount_t refcount;
  502. bool stopped;
  503. struct vfsmount *ss_mnt;
  504. struct nfs_fh c_fh;
  505. nfs4_stateid stateid;
  506. };
  507. extern bool inter_copy_offload_enable;
  508. struct nfsd4_seek {
  509. /* request */
  510. stateid_t seek_stateid;
  511. loff_t seek_offset;
  512. u32 seek_whence;
  513. /* response */
  514. u32 seek_eof;
  515. loff_t seek_pos;
  516. };
  517. struct nfsd4_offload_status {
  518. /* request */
  519. stateid_t stateid;
  520. /* response */
  521. u64 count;
  522. u32 status;
  523. };
  524. struct nfsd4_copy_notify {
  525. /* request */
  526. stateid_t cpn_src_stateid;
  527. struct nl4_server cpn_dst;
  528. /* response */
  529. stateid_t cpn_cnr_stateid;
  530. u64 cpn_sec;
  531. u32 cpn_nsec;
  532. struct nl4_server cpn_src;
  533. };
  534. struct nfsd4_op {
  535. int opnum;
  536. const struct nfsd4_operation * opdesc;
  537. __be32 status;
  538. union nfsd4_op_u {
  539. struct nfsd4_access access;
  540. struct nfsd4_close close;
  541. struct nfsd4_commit commit;
  542. struct nfsd4_create create;
  543. struct nfsd4_delegreturn delegreturn;
  544. struct nfsd4_getattr getattr;
  545. struct svc_fh * getfh;
  546. struct nfsd4_link link;
  547. struct nfsd4_lock lock;
  548. struct nfsd4_lockt lockt;
  549. struct nfsd4_locku locku;
  550. struct nfsd4_lookup lookup;
  551. struct nfsd4_verify nverify;
  552. struct nfsd4_open open;
  553. struct nfsd4_open_confirm open_confirm;
  554. struct nfsd4_open_downgrade open_downgrade;
  555. struct nfsd4_putfh putfh;
  556. struct nfsd4_read read;
  557. struct nfsd4_readdir readdir;
  558. struct nfsd4_readlink readlink;
  559. struct nfsd4_remove remove;
  560. struct nfsd4_rename rename;
  561. clientid_t renew;
  562. struct nfsd4_secinfo secinfo;
  563. struct nfsd4_setattr setattr;
  564. struct nfsd4_setclientid setclientid;
  565. struct nfsd4_setclientid_confirm setclientid_confirm;
  566. struct nfsd4_verify verify;
  567. struct nfsd4_write write;
  568. struct nfsd4_release_lockowner release_lockowner;
  569. /* NFSv4.1 */
  570. struct nfsd4_exchange_id exchange_id;
  571. struct nfsd4_backchannel_ctl backchannel_ctl;
  572. struct nfsd4_bind_conn_to_session bind_conn_to_session;
  573. struct nfsd4_create_session create_session;
  574. struct nfsd4_destroy_session destroy_session;
  575. struct nfsd4_destroy_clientid destroy_clientid;
  576. struct nfsd4_sequence sequence;
  577. struct nfsd4_reclaim_complete reclaim_complete;
  578. struct nfsd4_test_stateid test_stateid;
  579. struct nfsd4_free_stateid free_stateid;
  580. struct nfsd4_getdeviceinfo getdeviceinfo;
  581. struct nfsd4_layoutget layoutget;
  582. struct nfsd4_layoutcommit layoutcommit;
  583. struct nfsd4_layoutreturn layoutreturn;
  584. struct nfsd4_secinfo_no_name secinfo_no_name;
  585. /* NFSv4.2 */
  586. struct nfsd4_fallocate allocate;
  587. struct nfsd4_fallocate deallocate;
  588. struct nfsd4_clone clone;
  589. struct nfsd4_copy copy;
  590. struct nfsd4_offload_status offload_status;
  591. struct nfsd4_copy_notify copy_notify;
  592. struct nfsd4_seek seek;
  593. struct nfsd4_getxattr getxattr;
  594. struct nfsd4_setxattr setxattr;
  595. struct nfsd4_listxattrs listxattrs;
  596. struct nfsd4_removexattr removexattr;
  597. } u;
  598. struct nfs4_replay * replay;
  599. };
  600. bool nfsd4_cache_this_op(struct nfsd4_op *);
  601. /*
  602. * Memory needed just for the duration of processing one compound:
  603. */
  604. struct svcxdr_tmpbuf {
  605. struct svcxdr_tmpbuf *next;
  606. char buf[];
  607. };
  608. struct nfsd4_compoundargs {
  609. /* scratch variables for XDR decode */
  610. __be32 * p;
  611. __be32 * end;
  612. struct page ** pagelist;
  613. int pagelen;
  614. bool tail;
  615. __be32 tmp[8];
  616. __be32 * tmpp;
  617. struct svcxdr_tmpbuf *to_free;
  618. struct svc_rqst *rqstp;
  619. u32 taglen;
  620. char * tag;
  621. u32 minorversion;
  622. u32 opcnt;
  623. struct nfsd4_op *ops;
  624. struct nfsd4_op iops[8];
  625. int cachetype;
  626. };
  627. struct nfsd4_compoundres {
  628. /* scratch variables for XDR encode */
  629. struct xdr_stream xdr;
  630. struct svc_rqst * rqstp;
  631. u32 taglen;
  632. char * tag;
  633. u32 opcnt;
  634. __be32 * tagp; /* tag, opcount encode location */
  635. struct nfsd4_compound_state cstate;
  636. };
  637. static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp)
  638. {
  639. struct nfsd4_compoundargs *args = resp->rqstp->rq_argp;
  640. return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE;
  641. }
  642. /*
  643. * The session reply cache only needs to cache replies that the client
  644. * actually asked us to. But it's almost free for us to cache compounds
  645. * consisting of only a SEQUENCE op, so we may as well cache those too.
  646. * Also, the protocol doesn't give us a convenient response in the case
  647. * of a replay of a solo SEQUENCE op that wasn't cached
  648. * (RETRY_UNCACHED_REP can only be returned in the second op of a
  649. * compound).
  650. */
  651. static inline bool nfsd4_cache_this(struct nfsd4_compoundres *resp)
  652. {
  653. return (resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS)
  654. || nfsd4_is_solo_sequence(resp);
  655. }
  656. static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp)
  657. {
  658. struct nfsd4_compoundres *resp = rqstp->rq_resp;
  659. struct nfsd4_compoundargs *argp = rqstp->rq_argp;
  660. return argp->opcnt == resp->opcnt;
  661. }
  662. const struct nfsd4_operation *OPDESC(struct nfsd4_op *op);
  663. int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op);
  664. void warn_on_nonidempotent_op(struct nfsd4_op *op);
  665. #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs)
  666. static inline void
  667. set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp)
  668. {
  669. BUG_ON(!fhp->fh_pre_saved);
  670. cinfo->atomic = (u32)fhp->fh_post_saved;
  671. cinfo->change_supported = IS_I_VERSION(d_inode(fhp->fh_dentry));
  672. cinfo->before_change = fhp->fh_pre_change;
  673. cinfo->after_change = fhp->fh_post_change;
  674. cinfo->before_ctime_sec = fhp->fh_pre_ctime.tv_sec;
  675. cinfo->before_ctime_nsec = fhp->fh_pre_ctime.tv_nsec;
  676. cinfo->after_ctime_sec = fhp->fh_post_attr.ctime.tv_sec;
  677. cinfo->after_ctime_nsec = fhp->fh_post_attr.ctime.tv_nsec;
  678. }
  679. bool nfsd4_mach_creds_match(struct nfs4_client *cl, struct svc_rqst *rqstp);
  680. int nfs4svc_decode_voidarg(struct svc_rqst *, __be32 *);
  681. int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *);
  682. int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *);
  683. int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *);
  684. __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32);
  685. void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *);
  686. void nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op);
  687. __be32 nfsd4_encode_fattr_to_buf(__be32 **p, int words,
  688. struct svc_fh *fhp, struct svc_export *exp,
  689. struct dentry *dentry,
  690. u32 *bmval, struct svc_rqst *, int ignore_crossmnt);
  691. extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp,
  692. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  693. extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
  694. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  695. extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp,
  696. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  697. extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *,
  698. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  699. extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *,
  700. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  701. extern __be32 nfsd4_create_session(struct svc_rqst *,
  702. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  703. extern __be32 nfsd4_sequence(struct svc_rqst *,
  704. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  705. extern void nfsd4_sequence_done(struct nfsd4_compoundres *resp);
  706. extern __be32 nfsd4_destroy_session(struct svc_rqst *,
  707. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  708. extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *,
  709. union nfsd4_op_u *u);
  710. __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *,
  711. union nfsd4_op_u *u);
  712. extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *,
  713. struct nfsd4_open *open, struct nfsd_net *nn);
  714. extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp,
  715. struct svc_fh *current_fh, struct nfsd4_open *open);
  716. extern void nfsd4_cstate_clear_replay(struct nfsd4_compound_state *cstate);
  717. extern void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate,
  718. struct nfsd4_open *open);
  719. extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp,
  720. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  721. extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  722. union nfsd4_op_u *u);
  723. extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp,
  724. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  725. extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  726. union nfsd4_op_u *u);
  727. extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  728. union nfsd4_op_u *u);
  729. extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  730. union nfsd4_op_u *u);
  731. extern __be32
  732. nfsd4_release_lockowner(struct svc_rqst *rqstp,
  733. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  734. extern void nfsd4_release_compoundargs(struct svc_rqst *rqstp);
  735. extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp,
  736. struct nfsd4_compound_state *, union nfsd4_op_u *u);
  737. extern __be32 nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *,
  738. union nfsd4_op_u *u);
  739. extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp,
  740. struct nfsd4_compound_state *, union nfsd4_op_u *);
  741. extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp,
  742. struct nfsd4_compound_state *, union nfsd4_op_u *);
  743. extern void nfsd4_bump_seqid(struct nfsd4_compound_state *, __be32 nfserr);
  744. enum nfsd4_op_flags {
  745. ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */
  746. ALLOWED_ON_ABSENT_FS = 1 << 1, /* ops processed on absent fs */
  747. ALLOWED_AS_FIRST_OP = 1 << 2, /* ops reqired first in compound */
  748. /* For rfc 5661 section 2.6.3.1.1: */
  749. OP_HANDLES_WRONGSEC = 1 << 3,
  750. OP_IS_PUTFH_LIKE = 1 << 4,
  751. /*
  752. * These are the ops whose result size we estimate before
  753. * encoding, to avoid performing an op then not being able to
  754. * respond or cache a response. This includes writes and setattrs
  755. * as well as the operations usually called "nonidempotent":
  756. */
  757. OP_MODIFIES_SOMETHING = 1 << 5,
  758. /*
  759. * Cache compounds containing these ops in the xid-based drc:
  760. * We use the DRC for compounds containing non-idempotent
  761. * operations, *except* those that are 4.1-specific (since
  762. * sessions provide their own EOS), and except for stateful
  763. * operations other than setclientid and setclientid_confirm
  764. * (since sequence numbers provide EOS for open, lock, etc in
  765. * the v4.0 case).
  766. */
  767. OP_CACHEME = 1 << 6,
  768. /*
  769. * These are ops which clear current state id.
  770. */
  771. OP_CLEAR_STATEID = 1 << 7,
  772. /* Most ops return only an error on failure; some may do more: */
  773. OP_NONTRIVIAL_ERROR_ENCODE = 1 << 8,
  774. };
  775. struct nfsd4_operation {
  776. __be32 (*op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
  777. union nfsd4_op_u *);
  778. void (*op_release)(union nfsd4_op_u *);
  779. u32 op_flags;
  780. char *op_name;
  781. /* Try to get response size before operation */
  782. u32 (*op_rsize_bop)(struct svc_rqst *, struct nfsd4_op *);
  783. void (*op_get_currentstateid)(struct nfsd4_compound_state *,
  784. union nfsd4_op_u *);
  785. void (*op_set_currentstateid)(struct nfsd4_compound_state *,
  786. union nfsd4_op_u *);
  787. };
  788. #endif
  789. /*
  790. * Local variables:
  791. * c-basic-offset: 8
  792. * End:
  793. */