nfs3proc.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Process version 3 NFS requests.
  4. *
  5. * Copyright (C) 1996, 1997, 1998 Olaf Kirch <okir@monad.swb.de>
  6. */
  7. #include <linux/fs.h>
  8. #include <linux/ext2_fs.h>
  9. #include <linux/magic.h>
  10. #include <linux/namei.h>
  11. #include "cache.h"
  12. #include "xdr3.h"
  13. #include "vfs.h"
  14. #include "filecache.h"
  15. #define NFSDDBG_FACILITY NFSDDBG_PROC
  16. static int nfs3_ftypes[] = {
  17. 0, /* NF3NON */
  18. S_IFREG, /* NF3REG */
  19. S_IFDIR, /* NF3DIR */
  20. S_IFBLK, /* NF3BLK */
  21. S_IFCHR, /* NF3CHR */
  22. S_IFLNK, /* NF3LNK */
  23. S_IFSOCK, /* NF3SOCK */
  24. S_IFIFO, /* NF3FIFO */
  25. };
  26. static __be32 nfsd3_map_status(__be32 status)
  27. {
  28. switch (status) {
  29. case nfs_ok:
  30. break;
  31. case nfserr_nofilehandle:
  32. status = nfserr_badhandle;
  33. break;
  34. case nfserr_wrongsec:
  35. case nfserr_file_open:
  36. status = nfserr_acces;
  37. break;
  38. case nfserr_symlink_not_dir:
  39. status = nfserr_notdir;
  40. break;
  41. case nfserr_symlink:
  42. case nfserr_wrong_type:
  43. status = nfserr_inval;
  44. break;
  45. }
  46. return status;
  47. }
  48. /*
  49. * NULL call.
  50. */
  51. static __be32
  52. nfsd3_proc_null(struct svc_rqst *rqstp)
  53. {
  54. return rpc_success;
  55. }
  56. /*
  57. * Get a file's attributes
  58. */
  59. static __be32
  60. nfsd3_proc_getattr(struct svc_rqst *rqstp)
  61. {
  62. struct nfsd_fhandle *argp = rqstp->rq_argp;
  63. struct nfsd3_attrstat *resp = rqstp->rq_resp;
  64. dprintk("nfsd: GETATTR(3) %s\n",
  65. SVCFH_fmt(&argp->fh));
  66. fh_copy(&resp->fh, &argp->fh);
  67. resp->status = fh_verify(rqstp, &resp->fh, 0,
  68. NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
  69. if (resp->status != nfs_ok)
  70. goto out;
  71. resp->status = fh_getattr(&resp->fh, &resp->stat);
  72. out:
  73. resp->status = nfsd3_map_status(resp->status);
  74. return rpc_success;
  75. }
  76. /*
  77. * Set a file's attributes
  78. */
  79. static __be32
  80. nfsd3_proc_setattr(struct svc_rqst *rqstp)
  81. {
  82. struct nfsd3_sattrargs *argp = rqstp->rq_argp;
  83. struct nfsd3_attrstat *resp = rqstp->rq_resp;
  84. struct nfsd_attrs attrs = {
  85. .na_iattr = &argp->attrs,
  86. };
  87. const struct timespec64 *guardtime = NULL;
  88. dprintk("nfsd: SETATTR(3) %s\n",
  89. SVCFH_fmt(&argp->fh));
  90. fh_copy(&resp->fh, &argp->fh);
  91. if (argp->check_guard)
  92. guardtime = &argp->guardtime;
  93. resp->status = nfsd_setattr(rqstp, &resp->fh, &attrs, guardtime);
  94. resp->status = nfsd3_map_status(resp->status);
  95. return rpc_success;
  96. }
  97. /*
  98. * Look up a path name component
  99. */
  100. static __be32
  101. nfsd3_proc_lookup(struct svc_rqst *rqstp)
  102. {
  103. struct nfsd3_diropargs *argp = rqstp->rq_argp;
  104. struct nfsd3_diropres *resp = rqstp->rq_resp;
  105. dprintk("nfsd: LOOKUP(3) %s %.*s\n",
  106. SVCFH_fmt(&argp->fh),
  107. argp->len,
  108. argp->name);
  109. fh_copy(&resp->dirfh, &argp->fh);
  110. fh_init(&resp->fh, NFS3_FHSIZE);
  111. resp->status = nfsd_lookup(rqstp, &resp->dirfh,
  112. argp->name, argp->len,
  113. &resp->fh);
  114. resp->status = nfsd3_map_status(resp->status);
  115. return rpc_success;
  116. }
  117. /*
  118. * Check file access
  119. */
  120. static __be32
  121. nfsd3_proc_access(struct svc_rqst *rqstp)
  122. {
  123. struct nfsd3_accessargs *argp = rqstp->rq_argp;
  124. struct nfsd3_accessres *resp = rqstp->rq_resp;
  125. dprintk("nfsd: ACCESS(3) %s 0x%x\n",
  126. SVCFH_fmt(&argp->fh),
  127. argp->access);
  128. fh_copy(&resp->fh, &argp->fh);
  129. resp->access = argp->access;
  130. resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL);
  131. resp->status = nfsd3_map_status(resp->status);
  132. return rpc_success;
  133. }
  134. /*
  135. * Read a symlink.
  136. */
  137. static __be32
  138. nfsd3_proc_readlink(struct svc_rqst *rqstp)
  139. {
  140. struct nfsd_fhandle *argp = rqstp->rq_argp;
  141. struct nfsd3_readlinkres *resp = rqstp->rq_resp;
  142. dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh));
  143. /* Read the symlink. */
  144. fh_copy(&resp->fh, &argp->fh);
  145. resp->len = NFS3_MAXPATHLEN;
  146. resp->pages = rqstp->rq_next_page++;
  147. resp->status = nfsd_readlink(rqstp, &resp->fh,
  148. page_address(*resp->pages), &resp->len);
  149. resp->status = nfsd3_map_status(resp->status);
  150. return rpc_success;
  151. }
  152. /*
  153. * Read a portion of a file.
  154. */
  155. static __be32
  156. nfsd3_proc_read(struct svc_rqst *rqstp)
  157. {
  158. struct nfsd3_readargs *argp = rqstp->rq_argp;
  159. struct nfsd3_readres *resp = rqstp->rq_resp;
  160. dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
  161. SVCFH_fmt(&argp->fh),
  162. (unsigned long) argp->count,
  163. (unsigned long long) argp->offset);
  164. argp->count = min_t(u32, argp->count, svc_max_payload(rqstp));
  165. argp->count = min_t(u32, argp->count, rqstp->rq_res.buflen);
  166. if (argp->offset > (u64)OFFSET_MAX)
  167. argp->offset = (u64)OFFSET_MAX;
  168. if (argp->offset + argp->count > (u64)OFFSET_MAX)
  169. argp->count = (u64)OFFSET_MAX - argp->offset;
  170. resp->pages = rqstp->rq_next_page;
  171. /* Obtain buffer pointer for payload.
  172. * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof)
  173. * + 1 (xdr opaque byte count) = 26
  174. */
  175. resp->count = argp->count;
  176. svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3) << 2) +
  177. resp->count + 4);
  178. fh_copy(&resp->fh, &argp->fh);
  179. resp->status = nfsd_read(rqstp, &resp->fh, argp->offset,
  180. &resp->count, &resp->eof);
  181. resp->status = nfsd3_map_status(resp->status);
  182. return rpc_success;
  183. }
  184. /*
  185. * Write data to a file
  186. */
  187. static __be32
  188. nfsd3_proc_write(struct svc_rqst *rqstp)
  189. {
  190. struct nfsd3_writeargs *argp = rqstp->rq_argp;
  191. struct nfsd3_writeres *resp = rqstp->rq_resp;
  192. unsigned long cnt = argp->len;
  193. unsigned int nvecs;
  194. dprintk("nfsd: WRITE(3) %s %d bytes at %Lu%s\n",
  195. SVCFH_fmt(&argp->fh),
  196. argp->len,
  197. (unsigned long long) argp->offset,
  198. argp->stable ? " stable" : "");
  199. resp->status = nfserr_fbig;
  200. if (argp->offset > (u64)OFFSET_MAX ||
  201. argp->offset + argp->len > (u64)OFFSET_MAX)
  202. return rpc_success;
  203. fh_copy(&resp->fh, &argp->fh);
  204. resp->committed = argp->stable;
  205. nvecs = svc_fill_write_vector(rqstp, &argp->payload);
  206. resp->status = nfsd_write(rqstp, &resp->fh, argp->offset,
  207. rqstp->rq_vec, nvecs, &cnt,
  208. resp->committed, resp->verf);
  209. resp->count = cnt;
  210. resp->status = nfsd3_map_status(resp->status);
  211. return rpc_success;
  212. }
  213. /*
  214. * Implement NFSv3's unchecked, guarded, and exclusive CREATE
  215. * semantics for regular files. Except for the created file,
  216. * this operation is stateless on the server.
  217. *
  218. * Upon return, caller must release @fhp and @resfhp.
  219. */
  220. static __be32
  221. nfsd3_create_file(struct svc_rqst *rqstp, struct svc_fh *fhp,
  222. struct svc_fh *resfhp, struct nfsd3_createargs *argp)
  223. {
  224. struct iattr *iap = &argp->attrs;
  225. struct dentry *parent, *child;
  226. struct nfsd_attrs attrs = {
  227. .na_iattr = iap,
  228. };
  229. __u32 v_mtime, v_atime;
  230. struct inode *inode;
  231. __be32 status;
  232. int host_err;
  233. if (isdotent(argp->name, argp->len))
  234. return nfserr_exist;
  235. if (!(iap->ia_valid & ATTR_MODE))
  236. iap->ia_mode = 0;
  237. status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_EXEC);
  238. if (status != nfs_ok)
  239. return status;
  240. parent = fhp->fh_dentry;
  241. inode = d_inode(parent);
  242. host_err = fh_want_write(fhp);
  243. if (host_err)
  244. return nfserrno(host_err);
  245. inode_lock_nested(inode, I_MUTEX_PARENT);
  246. child = lookup_one_len(argp->name, parent, argp->len);
  247. if (IS_ERR(child)) {
  248. status = nfserrno(PTR_ERR(child));
  249. goto out;
  250. }
  251. if (d_really_is_negative(child)) {
  252. status = fh_verify(rqstp, fhp, S_IFDIR, NFSD_MAY_CREATE);
  253. if (status != nfs_ok)
  254. goto out;
  255. }
  256. status = fh_compose(resfhp, fhp->fh_export, child, fhp);
  257. if (status != nfs_ok)
  258. goto out;
  259. v_mtime = 0;
  260. v_atime = 0;
  261. if (argp->createmode == NFS3_CREATE_EXCLUSIVE) {
  262. u32 *verifier = (u32 *)argp->verf;
  263. /*
  264. * Solaris 7 gets confused (bugid 4218508) if these have
  265. * the high bit set, as do xfs filesystems without the
  266. * "bigtime" feature. So just clear the high bits.
  267. */
  268. v_mtime = verifier[0] & 0x7fffffff;
  269. v_atime = verifier[1] & 0x7fffffff;
  270. }
  271. if (d_really_is_positive(child)) {
  272. status = nfs_ok;
  273. switch (argp->createmode) {
  274. case NFS3_CREATE_UNCHECKED:
  275. if (!d_is_reg(child))
  276. break;
  277. iap->ia_valid &= ATTR_SIZE;
  278. goto set_attr;
  279. case NFS3_CREATE_GUARDED:
  280. status = nfserr_exist;
  281. break;
  282. case NFS3_CREATE_EXCLUSIVE:
  283. if (inode_get_mtime_sec(d_inode(child)) == v_mtime &&
  284. inode_get_atime_sec(d_inode(child)) == v_atime &&
  285. d_inode(child)->i_size == 0) {
  286. break;
  287. }
  288. status = nfserr_exist;
  289. }
  290. goto out;
  291. }
  292. if (!IS_POSIXACL(inode))
  293. iap->ia_mode &= ~current_umask();
  294. status = fh_fill_pre_attrs(fhp);
  295. if (status != nfs_ok)
  296. goto out;
  297. host_err = vfs_create(&nop_mnt_idmap, inode, child, iap->ia_mode, true);
  298. if (host_err < 0) {
  299. status = nfserrno(host_err);
  300. goto out;
  301. }
  302. fh_fill_post_attrs(fhp);
  303. /* A newly created file already has a file size of zero. */
  304. if ((iap->ia_valid & ATTR_SIZE) && (iap->ia_size == 0))
  305. iap->ia_valid &= ~ATTR_SIZE;
  306. if (argp->createmode == NFS3_CREATE_EXCLUSIVE) {
  307. iap->ia_valid = ATTR_MTIME | ATTR_ATIME |
  308. ATTR_MTIME_SET | ATTR_ATIME_SET;
  309. iap->ia_mtime.tv_sec = v_mtime;
  310. iap->ia_atime.tv_sec = v_atime;
  311. iap->ia_mtime.tv_nsec = 0;
  312. iap->ia_atime.tv_nsec = 0;
  313. }
  314. set_attr:
  315. status = nfsd_create_setattr(rqstp, fhp, resfhp, &attrs);
  316. out:
  317. inode_unlock(inode);
  318. if (child && !IS_ERR(child))
  319. dput(child);
  320. fh_drop_write(fhp);
  321. return status;
  322. }
  323. static __be32
  324. nfsd3_proc_create(struct svc_rqst *rqstp)
  325. {
  326. struct nfsd3_createargs *argp = rqstp->rq_argp;
  327. struct nfsd3_diropres *resp = rqstp->rq_resp;
  328. svc_fh *dirfhp, *newfhp;
  329. dprintk("nfsd: CREATE(3) %s %.*s\n",
  330. SVCFH_fmt(&argp->fh),
  331. argp->len,
  332. argp->name);
  333. dirfhp = fh_copy(&resp->dirfh, &argp->fh);
  334. newfhp = fh_init(&resp->fh, NFS3_FHSIZE);
  335. resp->status = nfsd3_create_file(rqstp, dirfhp, newfhp, argp);
  336. resp->status = nfsd3_map_status(resp->status);
  337. return rpc_success;
  338. }
  339. /*
  340. * Make directory. This operation is not idempotent.
  341. */
  342. static __be32
  343. nfsd3_proc_mkdir(struct svc_rqst *rqstp)
  344. {
  345. struct nfsd3_createargs *argp = rqstp->rq_argp;
  346. struct nfsd3_diropres *resp = rqstp->rq_resp;
  347. struct nfsd_attrs attrs = {
  348. .na_iattr = &argp->attrs,
  349. };
  350. dprintk("nfsd: MKDIR(3) %s %.*s\n",
  351. SVCFH_fmt(&argp->fh),
  352. argp->len,
  353. argp->name);
  354. argp->attrs.ia_valid &= ~ATTR_SIZE;
  355. fh_copy(&resp->dirfh, &argp->fh);
  356. fh_init(&resp->fh, NFS3_FHSIZE);
  357. resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
  358. &attrs, S_IFDIR, 0, &resp->fh);
  359. resp->status = nfsd3_map_status(resp->status);
  360. return rpc_success;
  361. }
  362. static __be32
  363. nfsd3_proc_symlink(struct svc_rqst *rqstp)
  364. {
  365. struct nfsd3_symlinkargs *argp = rqstp->rq_argp;
  366. struct nfsd3_diropres *resp = rqstp->rq_resp;
  367. struct nfsd_attrs attrs = {
  368. .na_iattr = &argp->attrs,
  369. };
  370. if (argp->tlen == 0) {
  371. resp->status = nfserr_inval;
  372. goto out;
  373. }
  374. if (argp->tlen > NFS3_MAXPATHLEN) {
  375. resp->status = nfserr_nametoolong;
  376. goto out;
  377. }
  378. argp->tname = svc_fill_symlink_pathname(rqstp, &argp->first,
  379. page_address(rqstp->rq_arg.pages[0]),
  380. argp->tlen);
  381. if (IS_ERR(argp->tname)) {
  382. resp->status = nfserrno(PTR_ERR(argp->tname));
  383. goto out;
  384. }
  385. dprintk("nfsd: SYMLINK(3) %s %.*s -> %.*s\n",
  386. SVCFH_fmt(&argp->ffh),
  387. argp->flen, argp->fname,
  388. argp->tlen, argp->tname);
  389. fh_copy(&resp->dirfh, &argp->ffh);
  390. fh_init(&resp->fh, NFS3_FHSIZE);
  391. resp->status = nfsd_symlink(rqstp, &resp->dirfh, argp->fname,
  392. argp->flen, argp->tname, &attrs, &resp->fh);
  393. kfree(argp->tname);
  394. out:
  395. resp->status = nfsd3_map_status(resp->status);
  396. return rpc_success;
  397. }
  398. /*
  399. * Make socket/fifo/device.
  400. */
  401. static __be32
  402. nfsd3_proc_mknod(struct svc_rqst *rqstp)
  403. {
  404. struct nfsd3_mknodargs *argp = rqstp->rq_argp;
  405. struct nfsd3_diropres *resp = rqstp->rq_resp;
  406. struct nfsd_attrs attrs = {
  407. .na_iattr = &argp->attrs,
  408. };
  409. int type;
  410. dev_t rdev = 0;
  411. dprintk("nfsd: MKNOD(3) %s %.*s\n",
  412. SVCFH_fmt(&argp->fh),
  413. argp->len,
  414. argp->name);
  415. fh_copy(&resp->dirfh, &argp->fh);
  416. fh_init(&resp->fh, NFS3_FHSIZE);
  417. if (argp->ftype == NF3CHR || argp->ftype == NF3BLK) {
  418. rdev = MKDEV(argp->major, argp->minor);
  419. if (MAJOR(rdev) != argp->major ||
  420. MINOR(rdev) != argp->minor) {
  421. resp->status = nfserr_inval;
  422. goto out;
  423. }
  424. } else if (argp->ftype != NF3SOCK && argp->ftype != NF3FIFO) {
  425. resp->status = nfserr_badtype;
  426. goto out;
  427. }
  428. type = nfs3_ftypes[argp->ftype];
  429. resp->status = nfsd_create(rqstp, &resp->dirfh, argp->name, argp->len,
  430. &attrs, type, rdev, &resp->fh);
  431. out:
  432. resp->status = nfsd3_map_status(resp->status);
  433. return rpc_success;
  434. }
  435. /*
  436. * Remove file/fifo/socket etc.
  437. */
  438. static __be32
  439. nfsd3_proc_remove(struct svc_rqst *rqstp)
  440. {
  441. struct nfsd3_diropargs *argp = rqstp->rq_argp;
  442. struct nfsd3_attrstat *resp = rqstp->rq_resp;
  443. dprintk("nfsd: REMOVE(3) %s %.*s\n",
  444. SVCFH_fmt(&argp->fh),
  445. argp->len,
  446. argp->name);
  447. /* Unlink. -S_IFDIR means file must not be a directory */
  448. fh_copy(&resp->fh, &argp->fh);
  449. resp->status = nfsd_unlink(rqstp, &resp->fh, -S_IFDIR,
  450. argp->name, argp->len);
  451. resp->status = nfsd3_map_status(resp->status);
  452. return rpc_success;
  453. }
  454. /*
  455. * Remove a directory
  456. */
  457. static __be32
  458. nfsd3_proc_rmdir(struct svc_rqst *rqstp)
  459. {
  460. struct nfsd3_diropargs *argp = rqstp->rq_argp;
  461. struct nfsd3_attrstat *resp = rqstp->rq_resp;
  462. dprintk("nfsd: RMDIR(3) %s %.*s\n",
  463. SVCFH_fmt(&argp->fh),
  464. argp->len,
  465. argp->name);
  466. fh_copy(&resp->fh, &argp->fh);
  467. resp->status = nfsd_unlink(rqstp, &resp->fh, S_IFDIR,
  468. argp->name, argp->len);
  469. resp->status = nfsd3_map_status(resp->status);
  470. return rpc_success;
  471. }
  472. static __be32
  473. nfsd3_proc_rename(struct svc_rqst *rqstp)
  474. {
  475. struct nfsd3_renameargs *argp = rqstp->rq_argp;
  476. struct nfsd3_renameres *resp = rqstp->rq_resp;
  477. dprintk("nfsd: RENAME(3) %s %.*s ->\n",
  478. SVCFH_fmt(&argp->ffh),
  479. argp->flen,
  480. argp->fname);
  481. dprintk("nfsd: -> %s %.*s\n",
  482. SVCFH_fmt(&argp->tfh),
  483. argp->tlen,
  484. argp->tname);
  485. fh_copy(&resp->ffh, &argp->ffh);
  486. fh_copy(&resp->tfh, &argp->tfh);
  487. resp->status = nfsd_rename(rqstp, &resp->ffh, argp->fname, argp->flen,
  488. &resp->tfh, argp->tname, argp->tlen);
  489. resp->status = nfsd3_map_status(resp->status);
  490. return rpc_success;
  491. }
  492. static __be32
  493. nfsd3_proc_link(struct svc_rqst *rqstp)
  494. {
  495. struct nfsd3_linkargs *argp = rqstp->rq_argp;
  496. struct nfsd3_linkres *resp = rqstp->rq_resp;
  497. dprintk("nfsd: LINK(3) %s ->\n",
  498. SVCFH_fmt(&argp->ffh));
  499. dprintk("nfsd: -> %s %.*s\n",
  500. SVCFH_fmt(&argp->tfh),
  501. argp->tlen,
  502. argp->tname);
  503. fh_copy(&resp->fh, &argp->ffh);
  504. fh_copy(&resp->tfh, &argp->tfh);
  505. resp->status = nfsd_link(rqstp, &resp->tfh, argp->tname, argp->tlen,
  506. &resp->fh);
  507. resp->status = nfsd3_map_status(resp->status);
  508. return rpc_success;
  509. }
  510. static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp,
  511. struct nfsd3_readdirres *resp,
  512. u32 count)
  513. {
  514. struct xdr_buf *buf = &resp->dirlist;
  515. struct xdr_stream *xdr = &resp->xdr;
  516. unsigned int sendbuf = min_t(unsigned int, rqstp->rq_res.buflen,
  517. svc_max_payload(rqstp));
  518. memset(buf, 0, sizeof(*buf));
  519. /* Reserve room for the NULL ptr & eof flag (-2 words) */
  520. buf->buflen = clamp(count, (u32)(XDR_UNIT * 2), sendbuf);
  521. buf->buflen -= XDR_UNIT * 2;
  522. buf->pages = rqstp->rq_next_page;
  523. rqstp->rq_next_page += (buf->buflen + PAGE_SIZE - 1) >> PAGE_SHIFT;
  524. xdr_init_encode_pages(xdr, buf, buf->pages, NULL);
  525. }
  526. /*
  527. * Read a portion of a directory.
  528. */
  529. static __be32
  530. nfsd3_proc_readdir(struct svc_rqst *rqstp)
  531. {
  532. struct nfsd3_readdirargs *argp = rqstp->rq_argp;
  533. struct nfsd3_readdirres *resp = rqstp->rq_resp;
  534. loff_t offset;
  535. dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
  536. SVCFH_fmt(&argp->fh),
  537. argp->count, (u32) argp->cookie);
  538. nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
  539. fh_copy(&resp->fh, &argp->fh);
  540. resp->common.err = nfs_ok;
  541. resp->cookie_offset = 0;
  542. resp->rqstp = rqstp;
  543. offset = argp->cookie;
  544. resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
  545. &resp->common, nfs3svc_encode_entry3);
  546. memcpy(resp->verf, argp->verf, 8);
  547. nfs3svc_encode_cookie3(resp, offset);
  548. /* Recycle only pages that were part of the reply */
  549. rqstp->rq_next_page = resp->xdr.page_ptr + 1;
  550. resp->status = nfsd3_map_status(resp->status);
  551. return rpc_success;
  552. }
  553. /*
  554. * Read a portion of a directory, including file handles and attrs.
  555. * For now, we choose to ignore the dircount parameter.
  556. */
  557. static __be32
  558. nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
  559. {
  560. struct nfsd3_readdirargs *argp = rqstp->rq_argp;
  561. struct nfsd3_readdirres *resp = rqstp->rq_resp;
  562. loff_t offset;
  563. dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
  564. SVCFH_fmt(&argp->fh),
  565. argp->count, (u32) argp->cookie);
  566. nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
  567. fh_copy(&resp->fh, &argp->fh);
  568. resp->common.err = nfs_ok;
  569. resp->cookie_offset = 0;
  570. resp->rqstp = rqstp;
  571. offset = argp->cookie;
  572. resp->status = fh_verify(rqstp, &resp->fh, S_IFDIR, NFSD_MAY_NOP);
  573. if (resp->status != nfs_ok)
  574. goto out;
  575. if (resp->fh.fh_export->ex_flags & NFSEXP_NOREADDIRPLUS) {
  576. resp->status = nfserr_notsupp;
  577. goto out;
  578. }
  579. resp->status = nfsd_readdir(rqstp, &resp->fh, &offset,
  580. &resp->common, nfs3svc_encode_entryplus3);
  581. memcpy(resp->verf, argp->verf, 8);
  582. nfs3svc_encode_cookie3(resp, offset);
  583. /* Recycle only pages that were part of the reply */
  584. rqstp->rq_next_page = resp->xdr.page_ptr + 1;
  585. out:
  586. resp->status = nfsd3_map_status(resp->status);
  587. return rpc_success;
  588. }
  589. /*
  590. * Get file system stats
  591. */
  592. static __be32
  593. nfsd3_proc_fsstat(struct svc_rqst *rqstp)
  594. {
  595. struct nfsd_fhandle *argp = rqstp->rq_argp;
  596. struct nfsd3_fsstatres *resp = rqstp->rq_resp;
  597. dprintk("nfsd: FSSTAT(3) %s\n",
  598. SVCFH_fmt(&argp->fh));
  599. resp->status = nfsd_statfs(rqstp, &argp->fh, &resp->stats, 0);
  600. fh_put(&argp->fh);
  601. resp->status = nfsd3_map_status(resp->status);
  602. return rpc_success;
  603. }
  604. /*
  605. * Get file system info
  606. */
  607. static __be32
  608. nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
  609. {
  610. struct nfsd_fhandle *argp = rqstp->rq_argp;
  611. struct nfsd3_fsinfores *resp = rqstp->rq_resp;
  612. u32 max_blocksize = svc_max_payload(rqstp);
  613. dprintk("nfsd: FSINFO(3) %s\n",
  614. SVCFH_fmt(&argp->fh));
  615. resp->f_rtmax = max_blocksize;
  616. resp->f_rtpref = max_blocksize;
  617. resp->f_rtmult = PAGE_SIZE;
  618. resp->f_wtmax = max_blocksize;
  619. resp->f_wtpref = max_blocksize;
  620. resp->f_wtmult = PAGE_SIZE;
  621. resp->f_dtpref = max_blocksize;
  622. resp->f_maxfilesize = ~(u32) 0;
  623. resp->f_properties = NFS3_FSF_DEFAULT;
  624. resp->status = fh_verify(rqstp, &argp->fh, 0,
  625. NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
  626. /* Check special features of the file system. May request
  627. * different read/write sizes for file systems known to have
  628. * problems with large blocks */
  629. if (resp->status == nfs_ok) {
  630. struct super_block *sb = argp->fh.fh_dentry->d_sb;
  631. /* Note that we don't care for remote fs's here */
  632. if (sb->s_magic == MSDOS_SUPER_MAGIC) {
  633. resp->f_properties = NFS3_FSF_BILLYBOY;
  634. }
  635. resp->f_maxfilesize = sb->s_maxbytes;
  636. }
  637. fh_put(&argp->fh);
  638. resp->status = nfsd3_map_status(resp->status);
  639. return rpc_success;
  640. }
  641. /*
  642. * Get pathconf info for the specified file
  643. */
  644. static __be32
  645. nfsd3_proc_pathconf(struct svc_rqst *rqstp)
  646. {
  647. struct nfsd_fhandle *argp = rqstp->rq_argp;
  648. struct nfsd3_pathconfres *resp = rqstp->rq_resp;
  649. dprintk("nfsd: PATHCONF(3) %s\n",
  650. SVCFH_fmt(&argp->fh));
  651. /* Set default pathconf */
  652. resp->p_link_max = 255; /* at least */
  653. resp->p_name_max = 255; /* at least */
  654. resp->p_no_trunc = 0;
  655. resp->p_chown_restricted = 1;
  656. resp->p_case_insensitive = 0;
  657. resp->p_case_preserving = 1;
  658. resp->status = fh_verify(rqstp, &argp->fh, 0, NFSD_MAY_NOP);
  659. if (resp->status == nfs_ok) {
  660. struct super_block *sb = argp->fh.fh_dentry->d_sb;
  661. /* Note that we don't care for remote fs's here */
  662. switch (sb->s_magic) {
  663. case EXT2_SUPER_MAGIC:
  664. resp->p_link_max = EXT2_LINK_MAX;
  665. resp->p_name_max = EXT2_NAME_LEN;
  666. break;
  667. case MSDOS_SUPER_MAGIC:
  668. resp->p_case_insensitive = 1;
  669. resp->p_case_preserving = 0;
  670. break;
  671. }
  672. }
  673. fh_put(&argp->fh);
  674. resp->status = nfsd3_map_status(resp->status);
  675. return rpc_success;
  676. }
  677. /*
  678. * Commit a file (range) to stable storage.
  679. */
  680. static __be32
  681. nfsd3_proc_commit(struct svc_rqst *rqstp)
  682. {
  683. struct nfsd3_commitargs *argp = rqstp->rq_argp;
  684. struct nfsd3_commitres *resp = rqstp->rq_resp;
  685. struct nfsd_file *nf;
  686. dprintk("nfsd: COMMIT(3) %s %u@%Lu\n",
  687. SVCFH_fmt(&argp->fh),
  688. argp->count,
  689. (unsigned long long) argp->offset);
  690. fh_copy(&resp->fh, &argp->fh);
  691. resp->status = nfsd_file_acquire_gc(rqstp, &resp->fh, NFSD_MAY_WRITE |
  692. NFSD_MAY_NOT_BREAK_LEASE, &nf);
  693. if (resp->status)
  694. goto out;
  695. resp->status = nfsd_commit(rqstp, &resp->fh, nf, argp->offset,
  696. argp->count, resp->verf);
  697. nfsd_file_put(nf);
  698. out:
  699. resp->status = nfsd3_map_status(resp->status);
  700. return rpc_success;
  701. }
  702. /*
  703. * NFSv3 Server procedures.
  704. * Only the results of non-idempotent operations are cached.
  705. */
  706. #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat
  707. #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat
  708. #define nfsd3_mkdirargs nfsd3_createargs
  709. #define nfsd3_readdirplusargs nfsd3_readdirargs
  710. #define nfsd3_fhandleargs nfsd_fhandle
  711. #define nfsd3_attrstatres nfsd3_attrstat
  712. #define nfsd3_wccstatres nfsd3_attrstat
  713. #define nfsd3_createres nfsd3_diropres
  714. #define ST 1 /* status*/
  715. #define FH 17 /* filehandle with length */
  716. #define AT 21 /* attributes */
  717. #define pAT (1+AT) /* post attributes - conditional */
  718. #define WC (7+pAT) /* WCC attributes */
  719. static const struct svc_procedure nfsd_procedures3[22] = {
  720. [NFS3PROC_NULL] = {
  721. .pc_func = nfsd3_proc_null,
  722. .pc_decode = nfssvc_decode_voidarg,
  723. .pc_encode = nfssvc_encode_voidres,
  724. .pc_argsize = sizeof(struct nfsd_voidargs),
  725. .pc_argzero = sizeof(struct nfsd_voidargs),
  726. .pc_ressize = sizeof(struct nfsd_voidres),
  727. .pc_cachetype = RC_NOCACHE,
  728. .pc_xdrressize = ST,
  729. .pc_name = "NULL",
  730. },
  731. [NFS3PROC_GETATTR] = {
  732. .pc_func = nfsd3_proc_getattr,
  733. .pc_decode = nfs3svc_decode_fhandleargs,
  734. .pc_encode = nfs3svc_encode_getattrres,
  735. .pc_release = nfs3svc_release_fhandle,
  736. .pc_argsize = sizeof(struct nfsd_fhandle),
  737. .pc_argzero = sizeof(struct nfsd_fhandle),
  738. .pc_ressize = sizeof(struct nfsd3_attrstatres),
  739. .pc_cachetype = RC_NOCACHE,
  740. .pc_xdrressize = ST+AT,
  741. .pc_name = "GETATTR",
  742. },
  743. [NFS3PROC_SETATTR] = {
  744. .pc_func = nfsd3_proc_setattr,
  745. .pc_decode = nfs3svc_decode_sattrargs,
  746. .pc_encode = nfs3svc_encode_wccstatres,
  747. .pc_release = nfs3svc_release_fhandle,
  748. .pc_argsize = sizeof(struct nfsd3_sattrargs),
  749. .pc_argzero = sizeof(struct nfsd3_sattrargs),
  750. .pc_ressize = sizeof(struct nfsd3_wccstatres),
  751. .pc_cachetype = RC_REPLBUFF,
  752. .pc_xdrressize = ST+WC,
  753. .pc_name = "SETATTR",
  754. },
  755. [NFS3PROC_LOOKUP] = {
  756. .pc_func = nfsd3_proc_lookup,
  757. .pc_decode = nfs3svc_decode_diropargs,
  758. .pc_encode = nfs3svc_encode_lookupres,
  759. .pc_release = nfs3svc_release_fhandle2,
  760. .pc_argsize = sizeof(struct nfsd3_diropargs),
  761. .pc_argzero = sizeof(struct nfsd3_diropargs),
  762. .pc_ressize = sizeof(struct nfsd3_diropres),
  763. .pc_cachetype = RC_NOCACHE,
  764. .pc_xdrressize = ST+FH+pAT+pAT,
  765. .pc_name = "LOOKUP",
  766. },
  767. [NFS3PROC_ACCESS] = {
  768. .pc_func = nfsd3_proc_access,
  769. .pc_decode = nfs3svc_decode_accessargs,
  770. .pc_encode = nfs3svc_encode_accessres,
  771. .pc_release = nfs3svc_release_fhandle,
  772. .pc_argsize = sizeof(struct nfsd3_accessargs),
  773. .pc_argzero = sizeof(struct nfsd3_accessargs),
  774. .pc_ressize = sizeof(struct nfsd3_accessres),
  775. .pc_cachetype = RC_NOCACHE,
  776. .pc_xdrressize = ST+pAT+1,
  777. .pc_name = "ACCESS",
  778. },
  779. [NFS3PROC_READLINK] = {
  780. .pc_func = nfsd3_proc_readlink,
  781. .pc_decode = nfs3svc_decode_fhandleargs,
  782. .pc_encode = nfs3svc_encode_readlinkres,
  783. .pc_release = nfs3svc_release_fhandle,
  784. .pc_argsize = sizeof(struct nfsd_fhandle),
  785. .pc_argzero = sizeof(struct nfsd_fhandle),
  786. .pc_ressize = sizeof(struct nfsd3_readlinkres),
  787. .pc_cachetype = RC_NOCACHE,
  788. .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4,
  789. .pc_name = "READLINK",
  790. },
  791. [NFS3PROC_READ] = {
  792. .pc_func = nfsd3_proc_read,
  793. .pc_decode = nfs3svc_decode_readargs,
  794. .pc_encode = nfs3svc_encode_readres,
  795. .pc_release = nfs3svc_release_fhandle,
  796. .pc_argsize = sizeof(struct nfsd3_readargs),
  797. .pc_argzero = sizeof(struct nfsd3_readargs),
  798. .pc_ressize = sizeof(struct nfsd3_readres),
  799. .pc_cachetype = RC_NOCACHE,
  800. .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4,
  801. .pc_name = "READ",
  802. },
  803. [NFS3PROC_WRITE] = {
  804. .pc_func = nfsd3_proc_write,
  805. .pc_decode = nfs3svc_decode_writeargs,
  806. .pc_encode = nfs3svc_encode_writeres,
  807. .pc_release = nfs3svc_release_fhandle,
  808. .pc_argsize = sizeof(struct nfsd3_writeargs),
  809. .pc_argzero = sizeof(struct nfsd3_writeargs),
  810. .pc_ressize = sizeof(struct nfsd3_writeres),
  811. .pc_cachetype = RC_REPLBUFF,
  812. .pc_xdrressize = ST+WC+4,
  813. .pc_name = "WRITE",
  814. },
  815. [NFS3PROC_CREATE] = {
  816. .pc_func = nfsd3_proc_create,
  817. .pc_decode = nfs3svc_decode_createargs,
  818. .pc_encode = nfs3svc_encode_createres,
  819. .pc_release = nfs3svc_release_fhandle2,
  820. .pc_argsize = sizeof(struct nfsd3_createargs),
  821. .pc_argzero = sizeof(struct nfsd3_createargs),
  822. .pc_ressize = sizeof(struct nfsd3_createres),
  823. .pc_cachetype = RC_REPLBUFF,
  824. .pc_xdrressize = ST+(1+FH+pAT)+WC,
  825. .pc_name = "CREATE",
  826. },
  827. [NFS3PROC_MKDIR] = {
  828. .pc_func = nfsd3_proc_mkdir,
  829. .pc_decode = nfs3svc_decode_mkdirargs,
  830. .pc_encode = nfs3svc_encode_createres,
  831. .pc_release = nfs3svc_release_fhandle2,
  832. .pc_argsize = sizeof(struct nfsd3_mkdirargs),
  833. .pc_argzero = sizeof(struct nfsd3_mkdirargs),
  834. .pc_ressize = sizeof(struct nfsd3_createres),
  835. .pc_cachetype = RC_REPLBUFF,
  836. .pc_xdrressize = ST+(1+FH+pAT)+WC,
  837. .pc_name = "MKDIR",
  838. },
  839. [NFS3PROC_SYMLINK] = {
  840. .pc_func = nfsd3_proc_symlink,
  841. .pc_decode = nfs3svc_decode_symlinkargs,
  842. .pc_encode = nfs3svc_encode_createres,
  843. .pc_release = nfs3svc_release_fhandle2,
  844. .pc_argsize = sizeof(struct nfsd3_symlinkargs),
  845. .pc_argzero = sizeof(struct nfsd3_symlinkargs),
  846. .pc_ressize = sizeof(struct nfsd3_createres),
  847. .pc_cachetype = RC_REPLBUFF,
  848. .pc_xdrressize = ST+(1+FH+pAT)+WC,
  849. .pc_name = "SYMLINK",
  850. },
  851. [NFS3PROC_MKNOD] = {
  852. .pc_func = nfsd3_proc_mknod,
  853. .pc_decode = nfs3svc_decode_mknodargs,
  854. .pc_encode = nfs3svc_encode_createres,
  855. .pc_release = nfs3svc_release_fhandle2,
  856. .pc_argsize = sizeof(struct nfsd3_mknodargs),
  857. .pc_argzero = sizeof(struct nfsd3_mknodargs),
  858. .pc_ressize = sizeof(struct nfsd3_createres),
  859. .pc_cachetype = RC_REPLBUFF,
  860. .pc_xdrressize = ST+(1+FH+pAT)+WC,
  861. .pc_name = "MKNOD",
  862. },
  863. [NFS3PROC_REMOVE] = {
  864. .pc_func = nfsd3_proc_remove,
  865. .pc_decode = nfs3svc_decode_diropargs,
  866. .pc_encode = nfs3svc_encode_wccstatres,
  867. .pc_release = nfs3svc_release_fhandle,
  868. .pc_argsize = sizeof(struct nfsd3_diropargs),
  869. .pc_argzero = sizeof(struct nfsd3_diropargs),
  870. .pc_ressize = sizeof(struct nfsd3_wccstatres),
  871. .pc_cachetype = RC_REPLBUFF,
  872. .pc_xdrressize = ST+WC,
  873. .pc_name = "REMOVE",
  874. },
  875. [NFS3PROC_RMDIR] = {
  876. .pc_func = nfsd3_proc_rmdir,
  877. .pc_decode = nfs3svc_decode_diropargs,
  878. .pc_encode = nfs3svc_encode_wccstatres,
  879. .pc_release = nfs3svc_release_fhandle,
  880. .pc_argsize = sizeof(struct nfsd3_diropargs),
  881. .pc_argzero = sizeof(struct nfsd3_diropargs),
  882. .pc_ressize = sizeof(struct nfsd3_wccstatres),
  883. .pc_cachetype = RC_REPLBUFF,
  884. .pc_xdrressize = ST+WC,
  885. .pc_name = "RMDIR",
  886. },
  887. [NFS3PROC_RENAME] = {
  888. .pc_func = nfsd3_proc_rename,
  889. .pc_decode = nfs3svc_decode_renameargs,
  890. .pc_encode = nfs3svc_encode_renameres,
  891. .pc_release = nfs3svc_release_fhandle2,
  892. .pc_argsize = sizeof(struct nfsd3_renameargs),
  893. .pc_argzero = sizeof(struct nfsd3_renameargs),
  894. .pc_ressize = sizeof(struct nfsd3_renameres),
  895. .pc_cachetype = RC_REPLBUFF,
  896. .pc_xdrressize = ST+WC+WC,
  897. .pc_name = "RENAME",
  898. },
  899. [NFS3PROC_LINK] = {
  900. .pc_func = nfsd3_proc_link,
  901. .pc_decode = nfs3svc_decode_linkargs,
  902. .pc_encode = nfs3svc_encode_linkres,
  903. .pc_release = nfs3svc_release_fhandle2,
  904. .pc_argsize = sizeof(struct nfsd3_linkargs),
  905. .pc_argzero = sizeof(struct nfsd3_linkargs),
  906. .pc_ressize = sizeof(struct nfsd3_linkres),
  907. .pc_cachetype = RC_REPLBUFF,
  908. .pc_xdrressize = ST+pAT+WC,
  909. .pc_name = "LINK",
  910. },
  911. [NFS3PROC_READDIR] = {
  912. .pc_func = nfsd3_proc_readdir,
  913. .pc_decode = nfs3svc_decode_readdirargs,
  914. .pc_encode = nfs3svc_encode_readdirres,
  915. .pc_release = nfs3svc_release_fhandle,
  916. .pc_argsize = sizeof(struct nfsd3_readdirargs),
  917. .pc_argzero = sizeof(struct nfsd3_readdirargs),
  918. .pc_ressize = sizeof(struct nfsd3_readdirres),
  919. .pc_cachetype = RC_NOCACHE,
  920. .pc_name = "READDIR",
  921. },
  922. [NFS3PROC_READDIRPLUS] = {
  923. .pc_func = nfsd3_proc_readdirplus,
  924. .pc_decode = nfs3svc_decode_readdirplusargs,
  925. .pc_encode = nfs3svc_encode_readdirres,
  926. .pc_release = nfs3svc_release_fhandle,
  927. .pc_argsize = sizeof(struct nfsd3_readdirplusargs),
  928. .pc_argzero = sizeof(struct nfsd3_readdirplusargs),
  929. .pc_ressize = sizeof(struct nfsd3_readdirres),
  930. .pc_cachetype = RC_NOCACHE,
  931. .pc_name = "READDIRPLUS",
  932. },
  933. [NFS3PROC_FSSTAT] = {
  934. .pc_func = nfsd3_proc_fsstat,
  935. .pc_decode = nfs3svc_decode_fhandleargs,
  936. .pc_encode = nfs3svc_encode_fsstatres,
  937. .pc_argsize = sizeof(struct nfsd3_fhandleargs),
  938. .pc_argzero = sizeof(struct nfsd3_fhandleargs),
  939. .pc_ressize = sizeof(struct nfsd3_fsstatres),
  940. .pc_cachetype = RC_NOCACHE,
  941. .pc_xdrressize = ST+pAT+2*6+1,
  942. .pc_name = "FSSTAT",
  943. },
  944. [NFS3PROC_FSINFO] = {
  945. .pc_func = nfsd3_proc_fsinfo,
  946. .pc_decode = nfs3svc_decode_fhandleargs,
  947. .pc_encode = nfs3svc_encode_fsinfores,
  948. .pc_argsize = sizeof(struct nfsd3_fhandleargs),
  949. .pc_argzero = sizeof(struct nfsd3_fhandleargs),
  950. .pc_ressize = sizeof(struct nfsd3_fsinfores),
  951. .pc_cachetype = RC_NOCACHE,
  952. .pc_xdrressize = ST+pAT+12,
  953. .pc_name = "FSINFO",
  954. },
  955. [NFS3PROC_PATHCONF] = {
  956. .pc_func = nfsd3_proc_pathconf,
  957. .pc_decode = nfs3svc_decode_fhandleargs,
  958. .pc_encode = nfs3svc_encode_pathconfres,
  959. .pc_argsize = sizeof(struct nfsd3_fhandleargs),
  960. .pc_argzero = sizeof(struct nfsd3_fhandleargs),
  961. .pc_ressize = sizeof(struct nfsd3_pathconfres),
  962. .pc_cachetype = RC_NOCACHE,
  963. .pc_xdrressize = ST+pAT+6,
  964. .pc_name = "PATHCONF",
  965. },
  966. [NFS3PROC_COMMIT] = {
  967. .pc_func = nfsd3_proc_commit,
  968. .pc_decode = nfs3svc_decode_commitargs,
  969. .pc_encode = nfs3svc_encode_commitres,
  970. .pc_release = nfs3svc_release_fhandle,
  971. .pc_argsize = sizeof(struct nfsd3_commitargs),
  972. .pc_argzero = sizeof(struct nfsd3_commitargs),
  973. .pc_ressize = sizeof(struct nfsd3_commitres),
  974. .pc_cachetype = RC_NOCACHE,
  975. .pc_xdrressize = ST+WC+2,
  976. .pc_name = "COMMIT",
  977. },
  978. };
  979. static DEFINE_PER_CPU_ALIGNED(unsigned long,
  980. nfsd_count3[ARRAY_SIZE(nfsd_procedures3)]);
  981. const struct svc_version nfsd_version3 = {
  982. .vs_vers = 3,
  983. .vs_nproc = ARRAY_SIZE(nfsd_procedures3),
  984. .vs_proc = nfsd_procedures3,
  985. .vs_dispatch = nfsd_dispatch,
  986. .vs_count = nfsd_count3,
  987. .vs_xdrsize = NFS3_SVC_XDRSIZE,
  988. };