vfs_file.c 17 KB

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