vfs_file.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  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 <linux/uio.h>
  39. #include <linux/slab.h>
  40. #include <net/9p/9p.h>
  41. #include <net/9p/client.h>
  42. #include "v9fs.h"
  43. #include "v9fs_vfs.h"
  44. #include "fid.h"
  45. #include "cache.h"
  46. static const struct vm_operations_struct v9fs_file_vm_ops;
  47. static const struct vm_operations_struct v9fs_mmap_file_vm_ops;
  48. /**
  49. * v9fs_file_open - open a file (or directory)
  50. * @inode: inode to be opened
  51. * @file: file being opened
  52. *
  53. */
  54. int v9fs_file_open(struct inode *inode, struct file *file)
  55. {
  56. int err;
  57. struct v9fs_inode *v9inode;
  58. struct v9fs_session_info *v9ses;
  59. struct p9_fid *fid;
  60. int omode;
  61. p9_debug(P9_DEBUG_VFS, "inode: %p file: %p\n", inode, file);
  62. v9inode = V9FS_I(inode);
  63. v9ses = v9fs_inode2v9ses(inode);
  64. if (v9fs_proto_dotl(v9ses))
  65. omode = v9fs_open_to_dotl_flags(file->f_flags);
  66. else
  67. omode = v9fs_uflags2omode(file->f_flags,
  68. v9fs_proto_dotu(v9ses));
  69. fid = file->private_data;
  70. if (!fid) {
  71. fid = v9fs_fid_clone(file->f_path.dentry);
  72. if (IS_ERR(fid))
  73. return PTR_ERR(fid);
  74. err = p9_client_open(fid, omode);
  75. if (err < 0) {
  76. p9_client_clunk(fid);
  77. return err;
  78. }
  79. if ((file->f_flags & O_APPEND) &&
  80. (!v9fs_proto_dotu(v9ses) && !v9fs_proto_dotl(v9ses)))
  81. generic_file_llseek(file, 0, SEEK_END);
  82. }
  83. file->private_data = fid;
  84. mutex_lock(&v9inode->v_mutex);
  85. if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
  86. !v9inode->writeback_fid &&
  87. ((file->f_flags & O_ACCMODE) != O_RDONLY)) {
  88. /*
  89. * clone a fid and add it to writeback_fid
  90. * we do it during open time instead of
  91. * page dirty time via write_begin/page_mkwrite
  92. * because we want write after unlink usecase
  93. * to work.
  94. */
  95. fid = v9fs_writeback_fid(file->f_path.dentry);
  96. if (IS_ERR(fid)) {
  97. err = PTR_ERR(fid);
  98. mutex_unlock(&v9inode->v_mutex);
  99. goto out_error;
  100. }
  101. v9inode->writeback_fid = (void *) fid;
  102. }
  103. mutex_unlock(&v9inode->v_mutex);
  104. if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
  105. v9fs_cache_inode_set_cookie(inode, file);
  106. return 0;
  107. out_error:
  108. p9_client_clunk(file->private_data);
  109. file->private_data = NULL;
  110. return err;
  111. }
  112. /**
  113. * v9fs_file_lock - lock a file (or directory)
  114. * @filp: file to be locked
  115. * @cmd: lock command
  116. * @fl: file lock structure
  117. *
  118. * Bugs: this looks like a local only lock, we should extend into 9P
  119. * by using open exclusive
  120. */
  121. static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl)
  122. {
  123. int res = 0;
  124. struct inode *inode = file_inode(filp);
  125. p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl);
  126. /* No mandatory locks */
  127. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  128. return -ENOLCK;
  129. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  130. filemap_write_and_wait(inode->i_mapping);
  131. invalidate_mapping_pages(&inode->i_data, 0, -1);
  132. }
  133. return res;
  134. }
  135. static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
  136. {
  137. struct p9_flock flock;
  138. struct p9_fid *fid;
  139. uint8_t status;
  140. int res = 0;
  141. unsigned char fl_type;
  142. fid = filp->private_data;
  143. BUG_ON(fid == NULL);
  144. if ((fl->fl_flags & FL_POSIX) != FL_POSIX)
  145. BUG();
  146. res = posix_lock_file_wait(filp, fl);
  147. if (res < 0)
  148. goto out;
  149. /* convert posix lock to p9 tlock args */
  150. memset(&flock, 0, sizeof(flock));
  151. /* map the lock type */
  152. switch (fl->fl_type) {
  153. case F_RDLCK:
  154. flock.type = P9_LOCK_TYPE_RDLCK;
  155. break;
  156. case F_WRLCK:
  157. flock.type = P9_LOCK_TYPE_WRLCK;
  158. break;
  159. case F_UNLCK:
  160. flock.type = P9_LOCK_TYPE_UNLCK;
  161. break;
  162. }
  163. flock.start = fl->fl_start;
  164. if (fl->fl_end == OFFSET_MAX)
  165. flock.length = 0;
  166. else
  167. flock.length = fl->fl_end - fl->fl_start + 1;
  168. flock.proc_id = fl->fl_pid;
  169. flock.client_id = fid->clnt->name;
  170. if (IS_SETLKW(cmd))
  171. flock.flags = P9_LOCK_FLAGS_BLOCK;
  172. /*
  173. * if its a blocked request and we get P9_LOCK_BLOCKED as the status
  174. * for lock request, keep on trying
  175. */
  176. for (;;) {
  177. res = p9_client_lock_dotl(fid, &flock, &status);
  178. if (res < 0)
  179. break;
  180. if (status != P9_LOCK_BLOCKED)
  181. break;
  182. if (status == P9_LOCK_BLOCKED && !IS_SETLKW(cmd))
  183. break;
  184. if (schedule_timeout_interruptible(P9_LOCK_TIMEOUT) != 0)
  185. break;
  186. }
  187. /* map 9p status to VFS status */
  188. switch (status) {
  189. case P9_LOCK_SUCCESS:
  190. res = 0;
  191. break;
  192. case P9_LOCK_BLOCKED:
  193. res = -EAGAIN;
  194. break;
  195. case P9_LOCK_ERROR:
  196. case P9_LOCK_GRACE:
  197. res = -ENOLCK;
  198. break;
  199. default:
  200. BUG();
  201. }
  202. /*
  203. * incase server returned error for lock request, revert
  204. * it locally
  205. */
  206. if (res < 0 && fl->fl_type != F_UNLCK) {
  207. fl_type = fl->fl_type;
  208. fl->fl_type = F_UNLCK;
  209. res = posix_lock_file_wait(filp, fl);
  210. fl->fl_type = fl_type;
  211. }
  212. out:
  213. return res;
  214. }
  215. static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
  216. {
  217. struct p9_getlock glock;
  218. struct p9_fid *fid;
  219. int res = 0;
  220. fid = filp->private_data;
  221. BUG_ON(fid == NULL);
  222. posix_test_lock(filp, fl);
  223. /*
  224. * if we have a conflicting lock locally, no need to validate
  225. * with server
  226. */
  227. if (fl->fl_type != F_UNLCK)
  228. return res;
  229. /* convert posix lock to p9 tgetlock args */
  230. memset(&glock, 0, sizeof(glock));
  231. glock.type = P9_LOCK_TYPE_UNLCK;
  232. glock.start = fl->fl_start;
  233. if (fl->fl_end == OFFSET_MAX)
  234. glock.length = 0;
  235. else
  236. glock.length = fl->fl_end - fl->fl_start + 1;
  237. glock.proc_id = fl->fl_pid;
  238. glock.client_id = fid->clnt->name;
  239. res = p9_client_getlock_dotl(fid, &glock);
  240. if (res < 0)
  241. return res;
  242. /* map 9p lock type to os lock type */
  243. switch (glock.type) {
  244. case P9_LOCK_TYPE_RDLCK:
  245. fl->fl_type = F_RDLCK;
  246. break;
  247. case P9_LOCK_TYPE_WRLCK:
  248. fl->fl_type = F_WRLCK;
  249. break;
  250. case P9_LOCK_TYPE_UNLCK:
  251. fl->fl_type = F_UNLCK;
  252. break;
  253. }
  254. if (glock.type != P9_LOCK_TYPE_UNLCK) {
  255. fl->fl_start = glock.start;
  256. if (glock.length == 0)
  257. fl->fl_end = OFFSET_MAX;
  258. else
  259. fl->fl_end = glock.start + glock.length - 1;
  260. fl->fl_pid = glock.proc_id;
  261. }
  262. kfree(glock.client_id);
  263. return res;
  264. }
  265. /**
  266. * v9fs_file_lock_dotl - lock a file (or directory)
  267. * @filp: file to be locked
  268. * @cmd: lock command
  269. * @fl: file lock structure
  270. *
  271. */
  272. static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl)
  273. {
  274. struct inode *inode = file_inode(filp);
  275. int ret = -ENOLCK;
  276. p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n",
  277. filp, cmd, fl, filp);
  278. /* No mandatory locks */
  279. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  280. goto out_err;
  281. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  282. filemap_write_and_wait(inode->i_mapping);
  283. invalidate_mapping_pages(&inode->i_data, 0, -1);
  284. }
  285. if (IS_SETLK(cmd) || IS_SETLKW(cmd))
  286. ret = v9fs_file_do_lock(filp, cmd, fl);
  287. else if (IS_GETLK(cmd))
  288. ret = v9fs_file_getlock(filp, fl);
  289. else
  290. ret = -EINVAL;
  291. out_err:
  292. return ret;
  293. }
  294. /**
  295. * v9fs_file_flock_dotl - lock a file
  296. * @filp: file to be locked
  297. * @cmd: lock command
  298. * @fl: file lock structure
  299. *
  300. */
  301. static int v9fs_file_flock_dotl(struct file *filp, int cmd,
  302. struct file_lock *fl)
  303. {
  304. struct inode *inode = file_inode(filp);
  305. int ret = -ENOLCK;
  306. p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n",
  307. filp, cmd, fl, filp);
  308. /* No mandatory locks */
  309. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  310. goto out_err;
  311. if (!(fl->fl_flags & FL_FLOCK))
  312. goto out_err;
  313. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  314. filemap_write_and_wait(inode->i_mapping);
  315. invalidate_mapping_pages(&inode->i_data, 0, -1);
  316. }
  317. /* Convert flock to posix lock */
  318. fl->fl_flags |= FL_POSIX;
  319. fl->fl_flags ^= FL_FLOCK;
  320. if (IS_SETLK(cmd) | IS_SETLKW(cmd))
  321. ret = v9fs_file_do_lock(filp, cmd, fl);
  322. else
  323. ret = -EINVAL;
  324. out_err:
  325. return ret;
  326. }
  327. /**
  328. * v9fs_file_read - read from a file
  329. * @filp: file pointer to read
  330. * @udata: user data buffer to read data into
  331. * @count: size of buffer
  332. * @offset: offset at which to read data
  333. *
  334. */
  335. static ssize_t
  336. v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
  337. {
  338. struct p9_fid *fid = iocb->ki_filp->private_data;
  339. int ret, err;
  340. p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n",
  341. iov_iter_count(to), iocb->ki_pos);
  342. ret = p9_client_read(fid, iocb->ki_pos, to, &err);
  343. if (!ret)
  344. return err;
  345. iocb->ki_pos += ret;
  346. return ret;
  347. }
  348. /**
  349. * v9fs_file_write - write to a file
  350. * @filp: file pointer to write
  351. * @data: data buffer to write data from
  352. * @count: size of buffer
  353. * @offset: offset at which to write data
  354. *
  355. */
  356. static ssize_t
  357. v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  358. {
  359. struct file *file = iocb->ki_filp;
  360. ssize_t retval;
  361. loff_t origin;
  362. int err = 0;
  363. retval = generic_write_checks(iocb, from);
  364. if (retval <= 0)
  365. return retval;
  366. origin = iocb->ki_pos;
  367. retval = p9_client_write(file->private_data, iocb->ki_pos, from, &err);
  368. if (retval > 0) {
  369. struct inode *inode = file_inode(file);
  370. loff_t i_size;
  371. unsigned long pg_start, pg_end;
  372. pg_start = origin >> PAGE_CACHE_SHIFT;
  373. pg_end = (origin + retval - 1) >> PAGE_CACHE_SHIFT;
  374. if (inode->i_mapping && inode->i_mapping->nrpages)
  375. invalidate_inode_pages2_range(inode->i_mapping,
  376. pg_start, pg_end);
  377. iocb->ki_pos += retval;
  378. i_size = i_size_read(inode);
  379. if (iocb->ki_pos > i_size) {
  380. inode_add_bytes(inode, iocb->ki_pos - i_size);
  381. i_size_write(inode, iocb->ki_pos);
  382. }
  383. return retval;
  384. }
  385. return err;
  386. }
  387. static int v9fs_file_fsync(struct file *filp, loff_t start, loff_t end,
  388. int datasync)
  389. {
  390. struct p9_fid *fid;
  391. struct inode *inode = filp->f_mapping->host;
  392. struct p9_wstat wstat;
  393. int retval;
  394. retval = filemap_write_and_wait_range(inode->i_mapping, start, end);
  395. if (retval)
  396. return retval;
  397. mutex_lock(&inode->i_mutex);
  398. p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
  399. fid = filp->private_data;
  400. v9fs_blank_wstat(&wstat);
  401. retval = p9_client_wstat(fid, &wstat);
  402. mutex_unlock(&inode->i_mutex);
  403. return retval;
  404. }
  405. int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
  406. int datasync)
  407. {
  408. struct p9_fid *fid;
  409. struct inode *inode = filp->f_mapping->host;
  410. int retval;
  411. retval = filemap_write_and_wait_range(inode->i_mapping, start, end);
  412. if (retval)
  413. return retval;
  414. mutex_lock(&inode->i_mutex);
  415. p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
  416. fid = filp->private_data;
  417. retval = p9_client_fsync(fid, datasync);
  418. mutex_unlock(&inode->i_mutex);
  419. return retval;
  420. }
  421. static int
  422. v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
  423. {
  424. int retval;
  425. retval = generic_file_mmap(filp, vma);
  426. if (!retval)
  427. vma->vm_ops = &v9fs_file_vm_ops;
  428. return retval;
  429. }
  430. static int
  431. v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma)
  432. {
  433. int retval;
  434. struct inode *inode;
  435. struct v9fs_inode *v9inode;
  436. struct p9_fid *fid;
  437. inode = file_inode(filp);
  438. v9inode = V9FS_I(inode);
  439. mutex_lock(&v9inode->v_mutex);
  440. if (!v9inode->writeback_fid &&
  441. (vma->vm_flags & VM_WRITE)) {
  442. /*
  443. * clone a fid and add it to writeback_fid
  444. * we do it during mmap instead of
  445. * page dirty time via write_begin/page_mkwrite
  446. * because we want write after unlink usecase
  447. * to work.
  448. */
  449. fid = v9fs_writeback_fid(filp->f_path.dentry);
  450. if (IS_ERR(fid)) {
  451. retval = PTR_ERR(fid);
  452. mutex_unlock(&v9inode->v_mutex);
  453. return retval;
  454. }
  455. v9inode->writeback_fid = (void *) fid;
  456. }
  457. mutex_unlock(&v9inode->v_mutex);
  458. retval = generic_file_mmap(filp, vma);
  459. if (!retval)
  460. vma->vm_ops = &v9fs_mmap_file_vm_ops;
  461. return retval;
  462. }
  463. static int
  464. v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
  465. {
  466. struct v9fs_inode *v9inode;
  467. struct page *page = vmf->page;
  468. struct file *filp = vma->vm_file;
  469. struct inode *inode = file_inode(filp);
  470. p9_debug(P9_DEBUG_VFS, "page %p fid %lx\n",
  471. page, (unsigned long)filp->private_data);
  472. /* Update file times before taking page lock */
  473. file_update_time(filp);
  474. v9inode = V9FS_I(inode);
  475. /* make sure the cache has finished storing the page */
  476. v9fs_fscache_wait_on_page_write(inode, page);
  477. BUG_ON(!v9inode->writeback_fid);
  478. lock_page(page);
  479. if (page->mapping != inode->i_mapping)
  480. goto out_unlock;
  481. wait_for_stable_page(page);
  482. return VM_FAULT_LOCKED;
  483. out_unlock:
  484. unlock_page(page);
  485. return VM_FAULT_NOPAGE;
  486. }
  487. /**
  488. * v9fs_mmap_file_read - read from a file
  489. * @filp: file pointer to read
  490. * @data: user data buffer to read data into
  491. * @count: size of buffer
  492. * @offset: offset at which to read data
  493. *
  494. */
  495. static ssize_t
  496. v9fs_mmap_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
  497. {
  498. /* TODO: Check if there are dirty pages */
  499. return v9fs_file_read_iter(iocb, to);
  500. }
  501. /**
  502. * v9fs_mmap_file_write - write to a file
  503. * @filp: file pointer to write
  504. * @data: data buffer to write data from
  505. * @count: size of buffer
  506. * @offset: offset at which to write data
  507. *
  508. */
  509. static ssize_t
  510. v9fs_mmap_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  511. {
  512. /*
  513. * TODO: invalidate mmaps on filp's inode between
  514. * offset and offset+count
  515. */
  516. return v9fs_file_write_iter(iocb, from);
  517. }
  518. static void v9fs_mmap_vm_close(struct vm_area_struct *vma)
  519. {
  520. struct inode *inode;
  521. struct writeback_control wbc = {
  522. .nr_to_write = LONG_MAX,
  523. .sync_mode = WB_SYNC_ALL,
  524. .range_start = vma->vm_pgoff * PAGE_SIZE,
  525. /* absolute end, byte at end included */
  526. .range_end = vma->vm_pgoff * PAGE_SIZE +
  527. (vma->vm_end - vma->vm_start - 1),
  528. };
  529. p9_debug(P9_DEBUG_VFS, "9p VMA close, %p, flushing", vma);
  530. inode = file_inode(vma->vm_file);
  531. if (!mapping_cap_writeback_dirty(inode->i_mapping))
  532. wbc.nr_to_write = 0;
  533. might_sleep();
  534. sync_inode(inode, &wbc);
  535. }
  536. static const struct vm_operations_struct v9fs_file_vm_ops = {
  537. .fault = filemap_fault,
  538. .map_pages = filemap_map_pages,
  539. .page_mkwrite = v9fs_vm_page_mkwrite,
  540. };
  541. static const struct vm_operations_struct v9fs_mmap_file_vm_ops = {
  542. .close = v9fs_mmap_vm_close,
  543. .fault = filemap_fault,
  544. .map_pages = filemap_map_pages,
  545. .page_mkwrite = v9fs_vm_page_mkwrite,
  546. };
  547. const struct file_operations v9fs_cached_file_operations = {
  548. .llseek = generic_file_llseek,
  549. .read_iter = generic_file_read_iter,
  550. .write_iter = generic_file_write_iter,
  551. .open = v9fs_file_open,
  552. .release = v9fs_dir_release,
  553. .lock = v9fs_file_lock,
  554. .mmap = v9fs_file_mmap,
  555. .fsync = v9fs_file_fsync,
  556. };
  557. const struct file_operations v9fs_cached_file_operations_dotl = {
  558. .llseek = generic_file_llseek,
  559. .read_iter = generic_file_read_iter,
  560. .write_iter = generic_file_write_iter,
  561. .open = v9fs_file_open,
  562. .release = v9fs_dir_release,
  563. .lock = v9fs_file_lock_dotl,
  564. .flock = v9fs_file_flock_dotl,
  565. .mmap = v9fs_file_mmap,
  566. .fsync = v9fs_file_fsync_dotl,
  567. };
  568. const struct file_operations v9fs_file_operations = {
  569. .llseek = generic_file_llseek,
  570. .read_iter = v9fs_file_read_iter,
  571. .write_iter = v9fs_file_write_iter,
  572. .open = v9fs_file_open,
  573. .release = v9fs_dir_release,
  574. .lock = v9fs_file_lock,
  575. .mmap = generic_file_readonly_mmap,
  576. .fsync = v9fs_file_fsync,
  577. };
  578. const struct file_operations v9fs_file_operations_dotl = {
  579. .llseek = generic_file_llseek,
  580. .read_iter = v9fs_file_read_iter,
  581. .write_iter = v9fs_file_write_iter,
  582. .open = v9fs_file_open,
  583. .release = v9fs_dir_release,
  584. .lock = v9fs_file_lock_dotl,
  585. .flock = v9fs_file_flock_dotl,
  586. .mmap = generic_file_readonly_mmap,
  587. .fsync = v9fs_file_fsync_dotl,
  588. };
  589. const struct file_operations v9fs_mmap_file_operations = {
  590. .llseek = generic_file_llseek,
  591. .read_iter = v9fs_mmap_file_read_iter,
  592. .write_iter = v9fs_mmap_file_write_iter,
  593. .open = v9fs_file_open,
  594. .release = v9fs_dir_release,
  595. .lock = v9fs_file_lock,
  596. .mmap = v9fs_mmap_file_mmap,
  597. .fsync = v9fs_file_fsync,
  598. };
  599. const struct file_operations v9fs_mmap_file_operations_dotl = {
  600. .llseek = generic_file_llseek,
  601. .read_iter = v9fs_mmap_file_read_iter,
  602. .write_iter = v9fs_mmap_file_write_iter,
  603. .open = v9fs_file_open,
  604. .release = v9fs_dir_release,
  605. .lock = v9fs_file_lock_dotl,
  606. .flock = v9fs_file_flock_dotl,
  607. .mmap = v9fs_mmap_file_mmap,
  608. .fsync = v9fs_file_fsync_dotl,
  609. };