vfs_file.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. /*
  2. * linux/fs/9p/vfs_file.c
  3. *
  4. * This file contians vfs file ops for 9P2000.
  5. *
  6. * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com>
  7. * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to:
  20. * Free Software Foundation
  21. * 51 Franklin Street, Fifth Floor
  22. * Boston, MA 02111-1301 USA
  23. *
  24. */
  25. #include <linux/module.h>
  26. #include <linux/errno.h>
  27. #include <linux/fs.h>
  28. #include <linux/sched.h>
  29. #include <linux/file.h>
  30. #include <linux/stat.h>
  31. #include <linux/string.h>
  32. #include <linux/inet.h>
  33. #include <linux/list.h>
  34. #include <linux/pagemap.h>
  35. #include <linux/utsname.h>
  36. #include <asm/uaccess.h>
  37. #include <linux/idr.h>
  38. #include <net/9p/9p.h>
  39. #include <net/9p/client.h>
  40. #include "v9fs.h"
  41. #include "v9fs_vfs.h"
  42. #include "fid.h"
  43. #include "cache.h"
  44. static const struct vm_operations_struct v9fs_file_vm_ops;
  45. /**
  46. * v9fs_file_open - open a file (or directory)
  47. * @inode: inode to be opened
  48. * @file: file being opened
  49. *
  50. */
  51. int v9fs_file_open(struct inode *inode, struct file *file)
  52. {
  53. int err;
  54. struct v9fs_inode *v9inode;
  55. struct v9fs_session_info *v9ses;
  56. struct p9_fid *fid;
  57. int omode;
  58. P9_DPRINTK(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file);
  59. v9inode = V9FS_I(inode);
  60. v9ses = v9fs_inode2v9ses(inode);
  61. if (v9fs_proto_dotl(v9ses))
  62. omode = file->f_flags;
  63. else
  64. omode = v9fs_uflags2omode(file->f_flags,
  65. v9fs_proto_dotu(v9ses));
  66. fid = file->private_data;
  67. if (!fid) {
  68. fid = v9fs_fid_clone(file->f_path.dentry);
  69. if (IS_ERR(fid))
  70. return PTR_ERR(fid);
  71. err = p9_client_open(fid, omode);
  72. if (err < 0) {
  73. p9_client_clunk(fid);
  74. return err;
  75. }
  76. if (file->f_flags & O_TRUNC) {
  77. i_size_write(inode, 0);
  78. inode->i_blocks = 0;
  79. }
  80. if ((file->f_flags & O_APPEND) &&
  81. (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)))
  82. generic_file_llseek(file, 0, SEEK_END);
  83. }
  84. file->private_data = fid;
  85. if (v9ses->cache && !v9inode->writeback_fid) {
  86. /*
  87. * clone a fid and add it to writeback_fid
  88. * we do it during open time instead of
  89. * page dirty time via write_begin/page_mkwrite
  90. * because we want write after unlink usecase
  91. * to work.
  92. */
  93. fid = v9fs_writeback_fid(file->f_path.dentry);
  94. if (IS_ERR(fid)) {
  95. err = PTR_ERR(fid);
  96. goto out_error;
  97. }
  98. v9inode->writeback_fid = (void *) fid;
  99. }
  100. #ifdef CONFIG_9P_FSCACHE
  101. if (v9ses->cache)
  102. v9fs_cache_inode_set_cookie(inode, file);
  103. #endif
  104. return 0;
  105. out_error:
  106. p9_client_clunk(file->private_data);
  107. file->private_data = NULL;
  108. return err;
  109. }
  110. /**
  111. * v9fs_file_lock - lock a file (or directory)
  112. * @filp: file to be locked
  113. * @cmd: lock command
  114. * @fl: file lock structure
  115. *
  116. * Bugs: this looks like a local only lock, we should extend into 9P
  117. * by using open exclusive
  118. */
  119. static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
  120. {
  121. int res = 0;
  122. struct inode *inode = filp->f_path.dentry->d_inode;
  123. P9_DPRINTK(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
  124. /* No mandatory locks */
  125. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  126. return -ENOLCK;
  127. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  128. filemap_write_and_wait(inode->i_mapping);
  129. invalidate_mapping_pages(&inode->i_data, 0, -1);
  130. }
  131. return res;
  132. }
  133. static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
  134. {
  135. struct p9_flock flock;
  136. struct p9_fid *fid;
  137. uint8_t status;
  138. int res = 0;
  139. unsigned char fl_type;
  140. fid = filp->private_data;
  141. BUG_ON(fid == NULL);
  142. if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
  143. BUG();
  144. res = posix_lock_file_wait(filp, fl);
  145. if (res < 0)
  146. goto out;
  147. /* convert posix lock to p9 tlock args */
  148. memset(&flock, 0, sizeof(flock));
  149. flock.type = fl->fl_type;
  150. flock.start = fl->fl_start;
  151. if (fl->fl_end == OFFSET_MAX)
  152. flock.length = 0;
  153. else
  154. flock.length = fl->fl_end - fl->fl_start + 1;
  155. flock.proc_id = fl->fl_pid;
  156. flock.client_id = utsname()->nodename;
  157. if (IS_SETLKW(cmd))
  158. flock.flags = P9_LOCK_FLAGS_BLOCK;
  159. /*
  160. * if its a blocked request and we get P9_LOCK_BLOCKED as the status
  161. * for lock request, keep on trying
  162. */
  163. for (;;) {
  164. res = p9_client_lock_dotl(fid, &flock, &status);
  165. if (res < 0)
  166. break;
  167. if (status != P9_LOCK_BLOCKED)
  168. break;
  169. if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd))
  170. break;
  171. schedule_timeout_interruptible(P9_LOCK_TIMEOUT);
  172. }
  173. /* map 9p status to VFS status */
  174. switch (status) {
  175. case P9_LOCK_SUCCESS:
  176. res = 0;
  177. break;
  178. case P9_LOCK_BLOCKED:
  179. res = -EAGAIN;
  180. break;
  181. case P9_LOCK_ERROR:
  182. case P9_LOCK_GRACE:
  183. res = -ENOLCK;
  184. break;
  185. default:
  186. BUG();
  187. }
  188. /*
  189. * incase server returned error for lock request, revert
  190. * it locally
  191. */
  192. if (res < 0 && fl->fl_type != F_UNLCK) {
  193. fl_type = fl->fl_type;
  194. fl->fl_type = F_UNLCK;
  195. res = posix_lock_file_wait(filp, fl);
  196. fl->fl_type = fl_type;
  197. }
  198. out:
  199. return res;
  200. }
  201. static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
  202. {
  203. struct p9_getlock glock;
  204. struct p9_fid *fid;
  205. int res = 0;
  206. fid = filp->private_data;
  207. BUG_ON(fid == NULL);
  208. posix_test_lock(filp, fl);
  209. /*
  210. * if we have a conflicting lock locally, no need to validate
  211. * with server
  212. */
  213. if (fl->fl_type != F_UNLCK)
  214. return res;
  215. /* convert posix lock to p9 tgetlock args */
  216. memset(&glock, 0, sizeof(glock));
  217. glock.type = fl->fl_type;
  218. glock.start = fl->fl_start;
  219. if (fl->fl_end == OFFSET_MAX)
  220. glock.length = 0;
  221. else
  222. glock.length = fl->fl_end - fl->fl_start + 1;
  223. glock.proc_id = fl->fl_pid;
  224. glock.client_id = utsname()->nodename;
  225. res = p9_client_getlock_dotl(fid, &glock);
  226. if (res < 0)
  227. return res;
  228. if (glock.type != F_UNLCK) {
  229. fl->fl_type = glock.type;
  230. fl->fl_start = glock.start;
  231. if (glock.length == 0)
  232. fl->fl_end = OFFSET_MAX;
  233. else
  234. fl->fl_end = glock.start + glock.length - 1;
  235. fl->fl_pid = glock.proc_id;
  236. } else
  237. fl->fl_type = F_UNLCK;
  238. return res;
  239. }
  240. /**
  241. * v9fs_file_lock_dotl - lock a file (or directory)
  242. * @filp: file to be locked
  243. * @cmd: lock command
  244. * @fl: file lock structure
  245. *
  246. */
  247. static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl)
  248. {
  249. struct inode *inode = filp->f_path.dentry->d_inode;
  250. int ret = -ENOLCK;
  251. P9_DPRINTK(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", filp,
  252. cmd, fl, filp->f_path.dentry->d_name.name);
  253. /* No mandatory locks */
  254. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  255. goto out_err;
  256. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  257. filemap_write_and_wait(inode->i_mapping);
  258. invalidate_mapping_pages(&inode->i_data, 0, -1);
  259. }
  260. if (IS_SETLK(cmd) || IS_SETLKW(cmd))
  261. ret = v9fs_file_do_lock(filp, cmd, fl);
  262. else if (IS_GETLK(cmd))
  263. ret = v9fs_file_getlock(filp, fl);
  264. else
  265. ret = -EINVAL;
  266. out_err:
  267. return ret;
  268. }
  269. /**
  270. * v9fs_file_flock_dotl - lock a file
  271. * @filp: file to be locked
  272. * @cmd: lock command
  273. * @fl: file lock structure
  274. *
  275. */
  276. static int v9fs_file_flock_dotl(struct file *filp, int cmd,
  277. struct file_lock *fl)
  278. {
  279. struct inode *inode = filp->f_path.dentry->d_inode;
  280. int ret = -ENOLCK;
  281. P9_DPRINTK(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %s\n", filp,
  282. cmd, fl, filp->f_path.dentry->d_name.name);
  283. /* No mandatory locks */
  284. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  285. goto out_err;
  286. if (!(fl->fl_flags & FL_FLOCK))
  287. goto out_err;
  288. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  289. filemap_write_and_wait(inode->i_mapping);
  290. invalidate_mapping_pages(&inode->i_data, 0, -1);
  291. }
  292. /* Convert flock to posix lock */
  293. fl->fl_owner = (fl_owner_t)filp;
  294. fl->fl_start = 0;
  295. fl->fl_end = OFFSET_MAX;
  296. fl->fl_flags |= FL_POSIX;
  297. fl->fl_flags ^= FL_FLOCK;
  298. if (IS_SETLK(cmd) | IS_SETLKW(cmd))
  299. ret = v9fs_file_do_lock(filp, cmd, fl);
  300. else
  301. ret = -EINVAL;
  302. out_err:
  303. return ret;
  304. }
  305. /**
  306. * v9fs_fid_readn - read from a fid
  307. * @fid: fid to read
  308. * @data: data buffer to read data into
  309. * @udata: user data buffer to read data into
  310. * @count: size of buffer
  311. * @offset: offset at which to read data
  312. *
  313. */
  314. ssize_t
  315. v9fs_fid_readn(struct p9_fid *fid, char *data, char __user *udata, u32 count,
  316. u64 offset)
  317. {
  318. int n, total, size;
  319. P9_DPRINTK(P9_DEBUG_VFS, "fid %d offset %llu count %d\n", fid->fid,
  320. (long long unsigned) offset, count);
  321. n = 0;
  322. total = 0;
  323. size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
  324. do {
  325. n = p9_client_read(fid, data, udata, offset, count);
  326. if (n <= 0)
  327. break;
  328. if (data)
  329. data += n;
  330. if (udata)
  331. udata += n;
  332. offset += n;
  333. count -= n;
  334. total += n;
  335. } while (count > 0 && n == size);
  336. if (n < 0)
  337. total = n;
  338. return total;
  339. }
  340. /**
  341. * v9fs_file_readn - read from a file
  342. * @filp: file pointer to read
  343. * @data: data buffer to read data into
  344. * @udata: user data buffer to read data into
  345. * @count: size of buffer
  346. * @offset: offset at which to read data
  347. *
  348. */
  349. ssize_t
  350. v9fs_file_readn(struct file *filp, char *data, char __user *udata, u32 count,
  351. u64 offset)
  352. {
  353. return v9fs_fid_readn(filp->private_data, data, udata, count, offset);
  354. }
  355. /**
  356. * v9fs_file_read - read from a file
  357. * @filp: file pointer to read
  358. * @udata: user data buffer to read data into
  359. * @count: size of buffer
  360. * @offset: offset at which to read data
  361. *
  362. */
  363. static ssize_t
  364. v9fs_file_read(struct file *filp, char __user *udata, size_t count,
  365. loff_t * offset)
  366. {
  367. int ret;
  368. struct p9_fid *fid;
  369. size_t size;
  370. P9_DPRINTK(P9_DEBUG_VFS, "count %zu offset %lld\n", count, *offset);
  371. fid = filp->private_data;
  372. size = fid->iounit ? fid->iounit : fid->clnt->msize - P9_IOHDRSZ;
  373. if (count > size)
  374. ret = v9fs_file_readn(filp, NULL, udata, count, *offset);
  375. else
  376. ret = p9_client_read(fid, NULL, udata, *offset, count);
  377. if (ret > 0)
  378. *offset += ret;
  379. return ret;
  380. }
  381. ssize_t
  382. v9fs_file_write_internal(struct inode *inode, struct p9_fid *fid,
  383. const char __user *data, size_t count,
  384. loff_t *offset, int invalidate)
  385. {
  386. int n;
  387. loff_t i_size;
  388. size_t total = 0;
  389. struct p9_client *clnt;
  390. loff_t origin = *offset;
  391. unsigned long pg_start, pg_end;
  392. P9_DPRINTK(P9_DEBUG_VFS, "data %p count %d offset %x\n", data,
  393. (int)count, (int)*offset);
  394. clnt = fid->clnt;
  395. do {
  396. n = p9_client_write(fid, NULL, data+total, origin+total, count);
  397. if (n <= 0)
  398. break;
  399. count -= n;
  400. total += n;
  401. } while (count > 0);
  402. if (invalidate && (total > 0)) {
  403. pg_start = origin >> PAGE_CACHE_SHIFT;
  404. pg_end = (origin + total - 1) >> PAGE_CACHE_SHIFT;
  405. if (inode->i_mapping && inode->i_mapping->nrpages)
  406. invalidate_inode_pages2_range(inode->i_mapping,
  407. pg_start, pg_end);
  408. *offset += total;
  409. i_size = i_size_read(inode);
  410. if (*offset > i_size) {
  411. inode_add_bytes(inode, *offset - i_size);
  412. i_size_write(inode, *offset);
  413. }
  414. }
  415. if (n < 0)
  416. return n;
  417. return total;
  418. }
  419. /**
  420. * v9fs_file_write - write to a file
  421. * @filp: file pointer to write
  422. * @data: data buffer to write data from
  423. * @count: size of buffer
  424. * @offset: offset at which to write data
  425. *
  426. */
  427. static ssize_t
  428. v9fs_file_write(struct file *filp, const char __user * data,
  429. size_t count, loff_t *offset)
  430. {
  431. ssize_t retval = 0;
  432. loff_t origin = *offset;
  433. retval = generic_write_checks(filp, &origin, &count, 0);
  434. if (retval)
  435. goto out;
  436. retval = -EINVAL;
  437. if ((ssize_t) count < 0)
  438. goto out;
  439. retval = 0;
  440. if (!count)
  441. goto out;
  442. return v9fs_file_write_internal(filp->f_path.dentry->d_inode,
  443. filp->private_data,
  444. data, count, offset, 1);
  445. out:
  446. return retval;
  447. }
  448. static int v9fs_file_fsync(struct file *filp, int datasync)
  449. {
  450. struct p9_fid *fid;
  451. struct p9_wstat wstat;
  452. int retval;
  453. P9_DPRINTK(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
  454. fid = filp->private_data;
  455. v9fs_blank_wstat(&wstat);
  456. retval = p9_client_wstat(fid, &wstat);
  457. return retval;
  458. }
  459. int v9fs_file_fsync_dotl(struct file *filp, int datasync)
  460. {
  461. struct p9_fid *fid;
  462. int retval;
  463. P9_DPRINTK(P9_DEBUG_VFS, "v9fs_file_fsync_dotl: filp %p datasync %x\n",
  464. filp, datasync);
  465. fid = filp->private_data;
  466. retval = p9_client_fsync(fid, datasync);
  467. return retval;
  468. }
  469. static int
  470. v9fs_file_mmap(struct file *file, struct vm_area_struct *vma)
  471. {
  472. int retval;
  473. retval = generic_file_mmap(file, vma);
  474. if (!retval)
  475. vma->vm_ops = &v9fs_file_vm_ops;
  476. return retval;
  477. }
  478. static int
  479. v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
  480. {
  481. struct v9fs_inode *v9inode;
  482. struct page *page = vmf->page;
  483. struct file *filp = vma->vm_file;
  484. struct inode *inode = filp->f_path.dentry->d_inode;
  485. P9_DPRINTK(P9_DEBUG_VFS, "page %p fid %lx\n",
  486. page, (unsigned long)filp->private_data);
  487. v9inode = V9FS_I(inode);
  488. /* make sure the cache has finished storing the page */
  489. v9fs_fscache_wait_on_page_write(inode, page);
  490. BUG_ON(!v9inode->writeback_fid);
  491. lock_page(page);
  492. if (page->mapping != inode->i_mapping)
  493. goto out_unlock;
  494. return VM_FAULT_LOCKED;
  495. out_unlock:
  496. unlock_page(page);
  497. return VM_FAULT_NOPAGE;
  498. }
  499. static ssize_t
  500. v9fs_direct_read(struct file *filp, char __user *udata, size_t count,
  501. loff_t *offsetp)
  502. {
  503. loff_t size, offset;
  504. struct inode *inode;
  505. struct address_space *mapping;
  506. offset = *offsetp;
  507. mapping = filp->f_mapping;
  508. inode = mapping->host;
  509. if (!count)
  510. return 0;
  511. size = i_size_read(inode);
  512. if (offset < size)
  513. filemap_write_and_wait_range(mapping, offset,
  514. offset + count - 1);
  515. return v9fs_file_read(filp, udata, count, offsetp);
  516. }
  517. /**
  518. * v9fs_cached_file_read - read from a file
  519. * @filp: file pointer to read
  520. * @udata: user data buffer to read data into
  521. * @count: size of buffer
  522. * @offset: offset at which to read data
  523. *
  524. */
  525. static ssize_t
  526. v9fs_cached_file_read(struct file *filp, char __user *data, size_t count,
  527. loff_t *offset)
  528. {
  529. if (filp->f_flags & O_DIRECT)
  530. return v9fs_direct_read(filp, data, count, offset);
  531. return do_sync_read(filp, data, count, offset);
  532. }
  533. static ssize_t
  534. v9fs_direct_write(struct file *filp, const char __user * data,
  535. size_t count, loff_t *offsetp)
  536. {
  537. loff_t offset;
  538. ssize_t retval;
  539. struct inode *inode;
  540. struct address_space *mapping;
  541. offset = *offsetp;
  542. mapping = filp->f_mapping;
  543. inode = mapping->host;
  544. if (!count)
  545. return 0;
  546. mutex_lock(&inode->i_mutex);
  547. retval = filemap_write_and_wait_range(mapping, offset,
  548. offset + count - 1);
  549. if (retval)
  550. goto err_out;
  551. /*
  552. * After a write we want buffered reads to be sure to go to disk to get
  553. * the new data. We invalidate clean cached page from the region we're
  554. * about to write. We do this *before* the write so that if we fail
  555. * here we fall back to buffered write
  556. */
  557. if (mapping->nrpages) {
  558. pgoff_t pg_start = offset >> PAGE_CACHE_SHIFT;
  559. pgoff_t pg_end = (offset + count - 1) >> PAGE_CACHE_SHIFT;
  560. retval = invalidate_inode_pages2_range(mapping,
  561. pg_start, pg_end);
  562. /*
  563. * If a page can not be invalidated, fall back
  564. * to buffered write.
  565. */
  566. if (retval) {
  567. if (retval == -EBUSY)
  568. goto buff_write;
  569. goto err_out;
  570. }
  571. }
  572. retval = v9fs_file_write(filp, data, count, offsetp);
  573. err_out:
  574. mutex_unlock(&inode->i_mutex);
  575. return retval;
  576. buff_write:
  577. mutex_unlock(&inode->i_mutex);
  578. return do_sync_write(filp, data, count, offsetp);
  579. }
  580. /**
  581. * v9fs_cached_file_write - write to a file
  582. * @filp: file pointer to write
  583. * @data: data buffer to write data from
  584. * @count: size of buffer
  585. * @offset: offset at which to write data
  586. *
  587. */
  588. static ssize_t
  589. v9fs_cached_file_write(struct file *filp, const char __user * data,
  590. size_t count, loff_t *offset)
  591. {
  592. if (filp->f_flags & O_DIRECT)
  593. return v9fs_direct_write(filp, data, count, offset);
  594. return do_sync_write(filp, data, count, offset);
  595. }
  596. static const struct vm_operations_struct v9fs_file_vm_ops = {
  597. .fault = filemap_fault,
  598. .page_mkwrite = v9fs_vm_page_mkwrite,
  599. };
  600. const struct file_operations v9fs_cached_file_operations = {
  601. .llseek = generic_file_llseek,
  602. .read = v9fs_cached_file_read,
  603. .write = v9fs_cached_file_write,
  604. .aio_read = generic_file_aio_read,
  605. .aio_write = generic_file_aio_write,
  606. .open = v9fs_file_open,
  607. .release = v9fs_dir_release,
  608. .lock = v9fs_file_lock,
  609. .mmap = v9fs_file_mmap,
  610. .fsync = v9fs_file_fsync,
  611. };
  612. const struct file_operations v9fs_cached_file_operations_dotl = {
  613. .llseek = generic_file_llseek,
  614. .read = v9fs_cached_file_read,
  615. .write = v9fs_cached_file_write,
  616. .aio_read = generic_file_aio_read,
  617. .aio_write = generic_file_aio_write,
  618. .open = v9fs_file_open,
  619. .release = v9fs_dir_release,
  620. .lock = v9fs_file_lock_dotl,
  621. .flock = v9fs_file_flock_dotl,
  622. .mmap = v9fs_file_mmap,
  623. .fsync = v9fs_file_fsync_dotl,
  624. };
  625. const struct file_operations v9fs_file_operations = {
  626. .llseek = generic_file_llseek,
  627. .read = v9fs_file_read,
  628. .write = v9fs_file_write,
  629. .open = v9fs_file_open,
  630. .release = v9fs_dir_release,
  631. .lock = v9fs_file_lock,
  632. .mmap = generic_file_readonly_mmap,
  633. .fsync = v9fs_file_fsync,
  634. };
  635. const struct file_operations v9fs_file_operations_dotl = {
  636. .llseek = generic_file_llseek,
  637. .read = v9fs_file_read,
  638. .write = v9fs_file_write,
  639. .open = v9fs_file_open,
  640. .release = v9fs_dir_release,
  641. .lock = v9fs_file_lock_dotl,
  642. .flock = v9fs_file_flock_dotl,
  643. .mmap = generic_file_readonly_mmap,
  644. .fsync = v9fs_file_fsync_dotl,
  645. };