proc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /*
  2. * linux/fs/nfs/proc.c
  3. *
  4. * Copyright (C) 1992, 1993, 1994 Rick Sladkey
  5. *
  6. * OS-independent nfs remote procedure call functions
  7. *
  8. * Tuned by Alan Cox <A.Cox@swansea.ac.uk> for >3K buffers
  9. * so at last we can have decent(ish) throughput off a
  10. * Sun server.
  11. *
  12. * Coding optimized and cleaned up by Florian La Roche.
  13. * Note: Error returns are optimized for NFS_OK, which isn't translated via
  14. * nfs_stat_to_errno(), but happens to be already the right return code.
  15. *
  16. * Also, the code currently doesn't check the size of the packet, when
  17. * it decodes the packet.
  18. *
  19. * Feel free to fix it and mail me the diffs if it worries you.
  20. *
  21. * Completely rewritten to support the new RPC call interface;
  22. * rewrote and moved the entire XDR stuff to xdr.c
  23. * --Olaf Kirch June 1996
  24. *
  25. * The code below initializes all auto variables explicitly, otherwise
  26. * it will fail to work as a module (gcc generates a memset call for an
  27. * incomplete struct).
  28. */
  29. #include <linux/types.h>
  30. #include <linux/param.h>
  31. #include <linux/slab.h>
  32. #include <linux/time.h>
  33. #include <linux/mm.h>
  34. #include <linux/utsname.h>
  35. #include <linux/errno.h>
  36. #include <linux/string.h>
  37. #include <linux/in.h>
  38. #include <linux/pagemap.h>
  39. #include <linux/sunrpc/clnt.h>
  40. #include <linux/nfs.h>
  41. #include <linux/nfs2.h>
  42. #include <linux/nfs_fs.h>
  43. #include <linux/nfs_page.h>
  44. #include <linux/lockd/bind.h>
  45. #include <linux/smp_lock.h>
  46. #define NFSDBG_FACILITY NFSDBG_PROC
  47. extern struct rpc_procinfo nfs_procedures[];
  48. /*
  49. * Bare-bones access to getattr: this is for nfs_read_super.
  50. */
  51. static int
  52. nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
  53. struct nfs_fsinfo *info)
  54. {
  55. struct nfs_fattr *fattr = info->fattr;
  56. struct nfs2_fsstat fsinfo;
  57. int status;
  58. dprintk("%s: call getattr\n", __FUNCTION__);
  59. nfs_fattr_init(fattr);
  60. status = rpc_call(server->client_sys, NFSPROC_GETATTR, fhandle, fattr, 0);
  61. dprintk("%s: reply getattr: %d\n", __FUNCTION__, status);
  62. if (status)
  63. return status;
  64. dprintk("%s: call statfs\n", __FUNCTION__);
  65. status = rpc_call(server->client_sys, NFSPROC_STATFS, fhandle, &fsinfo, 0);
  66. dprintk("%s: reply statfs: %d\n", __FUNCTION__, status);
  67. if (status)
  68. return status;
  69. info->rtmax = NFS_MAXDATA;
  70. info->rtpref = fsinfo.tsize;
  71. info->rtmult = fsinfo.bsize;
  72. info->wtmax = NFS_MAXDATA;
  73. info->wtpref = fsinfo.tsize;
  74. info->wtmult = fsinfo.bsize;
  75. info->dtpref = fsinfo.tsize;
  76. info->maxfilesize = 0x7FFFFFFF;
  77. info->lease_time = 0;
  78. return 0;
  79. }
  80. /*
  81. * One function for each procedure in the NFS protocol.
  82. */
  83. static int
  84. nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
  85. struct nfs_fattr *fattr)
  86. {
  87. int status;
  88. dprintk("NFS call getattr\n");
  89. nfs_fattr_init(fattr);
  90. status = rpc_call(server->client, NFSPROC_GETATTR,
  91. fhandle, fattr, 0);
  92. dprintk("NFS reply getattr: %d\n", status);
  93. return status;
  94. }
  95. static int
  96. nfs_proc_setattr(struct dentry *dentry, struct nfs_fattr *fattr,
  97. struct iattr *sattr)
  98. {
  99. struct inode *inode = dentry->d_inode;
  100. struct nfs_sattrargs arg = {
  101. .fh = NFS_FH(inode),
  102. .sattr = sattr
  103. };
  104. int status;
  105. dprintk("NFS call setattr\n");
  106. nfs_fattr_init(fattr);
  107. status = rpc_call(NFS_CLIENT(inode), NFSPROC_SETATTR, &arg, fattr, 0);
  108. if (status == 0)
  109. nfs_setattr_update_inode(inode, sattr);
  110. dprintk("NFS reply setattr: %d\n", status);
  111. return status;
  112. }
  113. static int
  114. nfs_proc_lookup(struct inode *dir, struct qstr *name,
  115. struct nfs_fh *fhandle, struct nfs_fattr *fattr)
  116. {
  117. struct nfs_diropargs arg = {
  118. .fh = NFS_FH(dir),
  119. .name = name->name,
  120. .len = name->len
  121. };
  122. struct nfs_diropok res = {
  123. .fh = fhandle,
  124. .fattr = fattr
  125. };
  126. int status;
  127. dprintk("NFS call lookup %s\n", name->name);
  128. nfs_fattr_init(fattr);
  129. status = rpc_call(NFS_CLIENT(dir), NFSPROC_LOOKUP, &arg, &res, 0);
  130. dprintk("NFS reply lookup: %d\n", status);
  131. return status;
  132. }
  133. static int nfs_proc_readlink(struct inode *inode, struct page *page,
  134. unsigned int pgbase, unsigned int pglen)
  135. {
  136. struct nfs_readlinkargs args = {
  137. .fh = NFS_FH(inode),
  138. .pgbase = pgbase,
  139. .pglen = pglen,
  140. .pages = &page
  141. };
  142. int status;
  143. dprintk("NFS call readlink\n");
  144. status = rpc_call(NFS_CLIENT(inode), NFSPROC_READLINK, &args, NULL, 0);
  145. dprintk("NFS reply readlink: %d\n", status);
  146. return status;
  147. }
  148. static int nfs_proc_read(struct nfs_read_data *rdata)
  149. {
  150. int flags = rdata->flags;
  151. struct inode * inode = rdata->inode;
  152. struct nfs_fattr * fattr = rdata->res.fattr;
  153. struct rpc_message msg = {
  154. .rpc_proc = &nfs_procedures[NFSPROC_READ],
  155. .rpc_argp = &rdata->args,
  156. .rpc_resp = &rdata->res,
  157. .rpc_cred = rdata->cred,
  158. };
  159. int status;
  160. dprintk("NFS call read %d @ %Ld\n", rdata->args.count,
  161. (long long) rdata->args.offset);
  162. nfs_fattr_init(fattr);
  163. status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
  164. if (status >= 0) {
  165. nfs_refresh_inode(inode, fattr);
  166. /* Emulate the eof flag, which isn't normally needed in NFSv2
  167. * as it is guaranteed to always return the file attributes
  168. */
  169. if (rdata->args.offset + rdata->args.count >= fattr->size)
  170. rdata->res.eof = 1;
  171. }
  172. dprintk("NFS reply read: %d\n", status);
  173. return status;
  174. }
  175. static int nfs_proc_write(struct nfs_write_data *wdata)
  176. {
  177. int flags = wdata->flags;
  178. struct inode * inode = wdata->inode;
  179. struct nfs_fattr * fattr = wdata->res.fattr;
  180. struct rpc_message msg = {
  181. .rpc_proc = &nfs_procedures[NFSPROC_WRITE],
  182. .rpc_argp = &wdata->args,
  183. .rpc_resp = &wdata->res,
  184. .rpc_cred = wdata->cred,
  185. };
  186. int status;
  187. dprintk("NFS call write %d @ %Ld\n", wdata->args.count,
  188. (long long) wdata->args.offset);
  189. nfs_fattr_init(fattr);
  190. status = rpc_call_sync(NFS_CLIENT(inode), &msg, flags);
  191. if (status >= 0) {
  192. nfs_post_op_update_inode(inode, fattr);
  193. wdata->res.count = wdata->args.count;
  194. wdata->verf.committed = NFS_FILE_SYNC;
  195. }
  196. dprintk("NFS reply write: %d\n", status);
  197. return status < 0? status : wdata->res.count;
  198. }
  199. static int
  200. nfs_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
  201. int flags, struct nameidata *nd)
  202. {
  203. struct nfs_fh fhandle;
  204. struct nfs_fattr fattr;
  205. struct nfs_createargs arg = {
  206. .fh = NFS_FH(dir),
  207. .name = dentry->d_name.name,
  208. .len = dentry->d_name.len,
  209. .sattr = sattr
  210. };
  211. struct nfs_diropok res = {
  212. .fh = &fhandle,
  213. .fattr = &fattr
  214. };
  215. int status;
  216. nfs_fattr_init(&fattr);
  217. dprintk("NFS call create %s\n", dentry->d_name.name);
  218. status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
  219. if (status == 0)
  220. status = nfs_instantiate(dentry, &fhandle, &fattr);
  221. dprintk("NFS reply create: %d\n", status);
  222. return status;
  223. }
  224. /*
  225. * In NFSv2, mknod is grafted onto the create call.
  226. */
  227. static int
  228. nfs_proc_mknod(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
  229. dev_t rdev)
  230. {
  231. struct nfs_fh fhandle;
  232. struct nfs_fattr fattr;
  233. struct nfs_createargs arg = {
  234. .fh = NFS_FH(dir),
  235. .name = dentry->d_name.name,
  236. .len = dentry->d_name.len,
  237. .sattr = sattr
  238. };
  239. struct nfs_diropok res = {
  240. .fh = &fhandle,
  241. .fattr = &fattr
  242. };
  243. int status, mode;
  244. dprintk("NFS call mknod %s\n", dentry->d_name.name);
  245. mode = sattr->ia_mode;
  246. if (S_ISFIFO(mode)) {
  247. sattr->ia_mode = (mode & ~S_IFMT) | S_IFCHR;
  248. sattr->ia_valid &= ~ATTR_SIZE;
  249. } else if (S_ISCHR(mode) || S_ISBLK(mode)) {
  250. sattr->ia_valid |= ATTR_SIZE;
  251. sattr->ia_size = new_encode_dev(rdev);/* get out your barf bag */
  252. }
  253. nfs_fattr_init(&fattr);
  254. status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
  255. nfs_mark_for_revalidate(dir);
  256. if (status == -EINVAL && S_ISFIFO(mode)) {
  257. sattr->ia_mode = mode;
  258. nfs_fattr_init(&fattr);
  259. status = rpc_call(NFS_CLIENT(dir), NFSPROC_CREATE, &arg, &res, 0);
  260. }
  261. if (status == 0)
  262. status = nfs_instantiate(dentry, &fhandle, &fattr);
  263. dprintk("NFS reply mknod: %d\n", status);
  264. return status;
  265. }
  266. static int
  267. nfs_proc_remove(struct inode *dir, struct qstr *name)
  268. {
  269. struct nfs_diropargs arg = {
  270. .fh = NFS_FH(dir),
  271. .name = name->name,
  272. .len = name->len
  273. };
  274. struct rpc_message msg = {
  275. .rpc_proc = &nfs_procedures[NFSPROC_REMOVE],
  276. .rpc_argp = &arg,
  277. .rpc_resp = NULL,
  278. .rpc_cred = NULL
  279. };
  280. int status;
  281. dprintk("NFS call remove %s\n", name->name);
  282. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  283. nfs_mark_for_revalidate(dir);
  284. dprintk("NFS reply remove: %d\n", status);
  285. return status;
  286. }
  287. static int
  288. nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir, struct qstr *name)
  289. {
  290. struct nfs_diropargs *arg;
  291. arg = (struct nfs_diropargs *)kmalloc(sizeof(*arg), GFP_KERNEL);
  292. if (!arg)
  293. return -ENOMEM;
  294. arg->fh = NFS_FH(dir->d_inode);
  295. arg->name = name->name;
  296. arg->len = name->len;
  297. msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
  298. msg->rpc_argp = arg;
  299. return 0;
  300. }
  301. static int
  302. nfs_proc_unlink_done(struct dentry *dir, struct rpc_task *task)
  303. {
  304. struct rpc_message *msg = &task->tk_msg;
  305. if (msg->rpc_argp) {
  306. nfs_mark_for_revalidate(dir->d_inode);
  307. kfree(msg->rpc_argp);
  308. }
  309. return 0;
  310. }
  311. static int
  312. nfs_proc_rename(struct inode *old_dir, struct qstr *old_name,
  313. struct inode *new_dir, struct qstr *new_name)
  314. {
  315. struct nfs_renameargs arg = {
  316. .fromfh = NFS_FH(old_dir),
  317. .fromname = old_name->name,
  318. .fromlen = old_name->len,
  319. .tofh = NFS_FH(new_dir),
  320. .toname = new_name->name,
  321. .tolen = new_name->len
  322. };
  323. int status;
  324. dprintk("NFS call rename %s -> %s\n", old_name->name, new_name->name);
  325. status = rpc_call(NFS_CLIENT(old_dir), NFSPROC_RENAME, &arg, NULL, 0);
  326. nfs_mark_for_revalidate(old_dir);
  327. nfs_mark_for_revalidate(new_dir);
  328. dprintk("NFS reply rename: %d\n", status);
  329. return status;
  330. }
  331. static int
  332. nfs_proc_link(struct inode *inode, struct inode *dir, struct qstr *name)
  333. {
  334. struct nfs_linkargs arg = {
  335. .fromfh = NFS_FH(inode),
  336. .tofh = NFS_FH(dir),
  337. .toname = name->name,
  338. .tolen = name->len
  339. };
  340. int status;
  341. dprintk("NFS call link %s\n", name->name);
  342. status = rpc_call(NFS_CLIENT(inode), NFSPROC_LINK, &arg, NULL, 0);
  343. nfs_mark_for_revalidate(dir);
  344. dprintk("NFS reply link: %d\n", status);
  345. return status;
  346. }
  347. static int
  348. nfs_proc_symlink(struct inode *dir, struct qstr *name, struct qstr *path,
  349. struct iattr *sattr, struct nfs_fh *fhandle,
  350. struct nfs_fattr *fattr)
  351. {
  352. struct nfs_symlinkargs arg = {
  353. .fromfh = NFS_FH(dir),
  354. .fromname = name->name,
  355. .fromlen = name->len,
  356. .topath = path->name,
  357. .tolen = path->len,
  358. .sattr = sattr
  359. };
  360. int status;
  361. if (path->len > NFS2_MAXPATHLEN)
  362. return -ENAMETOOLONG;
  363. dprintk("NFS call symlink %s -> %s\n", name->name, path->name);
  364. nfs_fattr_init(fattr);
  365. fhandle->size = 0;
  366. status = rpc_call(NFS_CLIENT(dir), NFSPROC_SYMLINK, &arg, NULL, 0);
  367. nfs_mark_for_revalidate(dir);
  368. dprintk("NFS reply symlink: %d\n", status);
  369. return status;
  370. }
  371. static int
  372. nfs_proc_mkdir(struct inode *dir, struct dentry *dentry, struct iattr *sattr)
  373. {
  374. struct nfs_fh fhandle;
  375. struct nfs_fattr fattr;
  376. struct nfs_createargs arg = {
  377. .fh = NFS_FH(dir),
  378. .name = dentry->d_name.name,
  379. .len = dentry->d_name.len,
  380. .sattr = sattr
  381. };
  382. struct nfs_diropok res = {
  383. .fh = &fhandle,
  384. .fattr = &fattr
  385. };
  386. int status;
  387. dprintk("NFS call mkdir %s\n", dentry->d_name.name);
  388. nfs_fattr_init(&fattr);
  389. status = rpc_call(NFS_CLIENT(dir), NFSPROC_MKDIR, &arg, &res, 0);
  390. nfs_mark_for_revalidate(dir);
  391. if (status == 0)
  392. status = nfs_instantiate(dentry, &fhandle, &fattr);
  393. dprintk("NFS reply mkdir: %d\n", status);
  394. return status;
  395. }
  396. static int
  397. nfs_proc_rmdir(struct inode *dir, struct qstr *name)
  398. {
  399. struct nfs_diropargs arg = {
  400. .fh = NFS_FH(dir),
  401. .name = name->name,
  402. .len = name->len
  403. };
  404. int status;
  405. dprintk("NFS call rmdir %s\n", name->name);
  406. status = rpc_call(NFS_CLIENT(dir), NFSPROC_RMDIR, &arg, NULL, 0);
  407. nfs_mark_for_revalidate(dir);
  408. dprintk("NFS reply rmdir: %d\n", status);
  409. return status;
  410. }
  411. /*
  412. * The READDIR implementation is somewhat hackish - we pass a temporary
  413. * buffer to the encode function, which installs it in the receive
  414. * the receive iovec. The decode function just parses the reply to make
  415. * sure it is syntactically correct; the entries itself are decoded
  416. * from nfs_readdir by calling the decode_entry function directly.
  417. */
  418. static int
  419. nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
  420. u64 cookie, struct page *page, unsigned int count, int plus)
  421. {
  422. struct inode *dir = dentry->d_inode;
  423. struct nfs_readdirargs arg = {
  424. .fh = NFS_FH(dir),
  425. .cookie = cookie,
  426. .count = count,
  427. .pages = &page
  428. };
  429. struct rpc_message msg = {
  430. .rpc_proc = &nfs_procedures[NFSPROC_READDIR],
  431. .rpc_argp = &arg,
  432. .rpc_resp = NULL,
  433. .rpc_cred = cred
  434. };
  435. int status;
  436. lock_kernel();
  437. dprintk("NFS call readdir %d\n", (unsigned int)cookie);
  438. status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
  439. dprintk("NFS reply readdir: %d\n", status);
  440. unlock_kernel();
  441. return status;
  442. }
  443. static int
  444. nfs_proc_statfs(struct nfs_server *server, struct nfs_fh *fhandle,
  445. struct nfs_fsstat *stat)
  446. {
  447. struct nfs2_fsstat fsinfo;
  448. int status;
  449. dprintk("NFS call statfs\n");
  450. nfs_fattr_init(stat->fattr);
  451. status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0);
  452. dprintk("NFS reply statfs: %d\n", status);
  453. if (status)
  454. goto out;
  455. stat->tbytes = (u64)fsinfo.blocks * fsinfo.bsize;
  456. stat->fbytes = (u64)fsinfo.bfree * fsinfo.bsize;
  457. stat->abytes = (u64)fsinfo.bavail * fsinfo.bsize;
  458. stat->tfiles = 0;
  459. stat->ffiles = 0;
  460. stat->afiles = 0;
  461. out:
  462. return status;
  463. }
  464. static int
  465. nfs_proc_fsinfo(struct nfs_server *server, struct nfs_fh *fhandle,
  466. struct nfs_fsinfo *info)
  467. {
  468. struct nfs2_fsstat fsinfo;
  469. int status;
  470. dprintk("NFS call fsinfo\n");
  471. nfs_fattr_init(info->fattr);
  472. status = rpc_call(server->client, NFSPROC_STATFS, fhandle, &fsinfo, 0);
  473. dprintk("NFS reply fsinfo: %d\n", status);
  474. if (status)
  475. goto out;
  476. info->rtmax = NFS_MAXDATA;
  477. info->rtpref = fsinfo.tsize;
  478. info->rtmult = fsinfo.bsize;
  479. info->wtmax = NFS_MAXDATA;
  480. info->wtpref = fsinfo.tsize;
  481. info->wtmult = fsinfo.bsize;
  482. info->dtpref = fsinfo.tsize;
  483. info->maxfilesize = 0x7FFFFFFF;
  484. info->lease_time = 0;
  485. out:
  486. return status;
  487. }
  488. static int
  489. nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle,
  490. struct nfs_pathconf *info)
  491. {
  492. info->max_link = 0;
  493. info->max_namelen = NFS2_MAXNAMLEN;
  494. return 0;
  495. }
  496. extern u32 * nfs_decode_dirent(u32 *, struct nfs_entry *, int);
  497. static void
  498. nfs_read_done(struct rpc_task *task)
  499. {
  500. struct nfs_read_data *data = (struct nfs_read_data *) task->tk_calldata;
  501. if (task->tk_status >= 0) {
  502. nfs_refresh_inode(data->inode, data->res.fattr);
  503. /* Emulate the eof flag, which isn't normally needed in NFSv2
  504. * as it is guaranteed to always return the file attributes
  505. */
  506. if (data->args.offset + data->args.count >= data->res.fattr->size)
  507. data->res.eof = 1;
  508. }
  509. nfs_readpage_result(task);
  510. }
  511. static void
  512. nfs_proc_read_setup(struct nfs_read_data *data)
  513. {
  514. struct rpc_task *task = &data->task;
  515. struct inode *inode = data->inode;
  516. int flags;
  517. struct rpc_message msg = {
  518. .rpc_proc = &nfs_procedures[NFSPROC_READ],
  519. .rpc_argp = &data->args,
  520. .rpc_resp = &data->res,
  521. .rpc_cred = data->cred,
  522. };
  523. /* N.B. Do we need to test? Never called for swapfile inode */
  524. flags = RPC_TASK_ASYNC | (IS_SWAPFILE(inode)? NFS_RPC_SWAPFLAGS : 0);
  525. /* Finalize the task. */
  526. rpc_init_task(task, NFS_CLIENT(inode), nfs_read_done, flags);
  527. rpc_call_setup(task, &msg, 0);
  528. }
  529. static void
  530. nfs_write_done(struct rpc_task *task)
  531. {
  532. struct nfs_write_data *data = (struct nfs_write_data *) task->tk_calldata;
  533. if (task->tk_status >= 0)
  534. nfs_post_op_update_inode(data->inode, data->res.fattr);
  535. nfs_writeback_done(task);
  536. }
  537. static void
  538. nfs_proc_write_setup(struct nfs_write_data *data, int how)
  539. {
  540. struct rpc_task *task = &data->task;
  541. struct inode *inode = data->inode;
  542. int flags;
  543. struct rpc_message msg = {
  544. .rpc_proc = &nfs_procedures[NFSPROC_WRITE],
  545. .rpc_argp = &data->args,
  546. .rpc_resp = &data->res,
  547. .rpc_cred = data->cred,
  548. };
  549. /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
  550. data->args.stable = NFS_FILE_SYNC;
  551. /* Set the initial flags for the task. */
  552. flags = (how & FLUSH_SYNC) ? 0 : RPC_TASK_ASYNC;
  553. /* Finalize the task. */
  554. rpc_init_task(task, NFS_CLIENT(inode), nfs_write_done, flags);
  555. rpc_call_setup(task, &msg, 0);
  556. }
  557. static void
  558. nfs_proc_commit_setup(struct nfs_write_data *data, int how)
  559. {
  560. BUG();
  561. }
  562. static int
  563. nfs_proc_lock(struct file *filp, int cmd, struct file_lock *fl)
  564. {
  565. return nlmclnt_proc(filp->f_dentry->d_inode, cmd, fl);
  566. }
  567. struct nfs_rpc_ops nfs_v2_clientops = {
  568. .version = 2, /* protocol version */
  569. .dentry_ops = &nfs_dentry_operations,
  570. .dir_inode_ops = &nfs_dir_inode_operations,
  571. .file_inode_ops = &nfs_file_inode_operations,
  572. .getroot = nfs_proc_get_root,
  573. .getattr = nfs_proc_getattr,
  574. .setattr = nfs_proc_setattr,
  575. .lookup = nfs_proc_lookup,
  576. .access = NULL, /* access */
  577. .readlink = nfs_proc_readlink,
  578. .read = nfs_proc_read,
  579. .write = nfs_proc_write,
  580. .commit = NULL, /* commit */
  581. .create = nfs_proc_create,
  582. .remove = nfs_proc_remove,
  583. .unlink_setup = nfs_proc_unlink_setup,
  584. .unlink_done = nfs_proc_unlink_done,
  585. .rename = nfs_proc_rename,
  586. .link = nfs_proc_link,
  587. .symlink = nfs_proc_symlink,
  588. .mkdir = nfs_proc_mkdir,
  589. .rmdir = nfs_proc_rmdir,
  590. .readdir = nfs_proc_readdir,
  591. .mknod = nfs_proc_mknod,
  592. .statfs = nfs_proc_statfs,
  593. .fsinfo = nfs_proc_fsinfo,
  594. .pathconf = nfs_proc_pathconf,
  595. .decode_dirent = nfs_decode_dirent,
  596. .read_setup = nfs_proc_read_setup,
  597. .write_setup = nfs_proc_write_setup,
  598. .commit_setup = nfs_proc_commit_setup,
  599. .file_open = nfs_open,
  600. .file_release = nfs_release,
  601. .lock = nfs_proc_lock,
  602. };