vfs_file.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  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 = P9_LOCK_ERROR;
  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. goto out_unlock;
  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. default:
  196. WARN_ONCE(1, "unknown lock status code: %d\n", status);
  197. /* fallthough */
  198. case P9_LOCK_ERROR:
  199. case P9_LOCK_GRACE:
  200. res = -ENOLCK;
  201. break;
  202. }
  203. out_unlock:
  204. /*
  205. * incase server returned error for lock request, revert
  206. * it locally
  207. */
  208. if (res < 0 && fl->fl_type != F_UNLCK) {
  209. fl_type = fl->fl_type;
  210. fl->fl_type = F_UNLCK;
  211. res = posix_lock_file_wait(filp, fl);
  212. fl->fl_type = fl_type;
  213. }
  214. out:
  215. return res;
  216. }
  217. static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
  218. {
  219. struct p9_getlock glock;
  220. struct p9_fid *fid;
  221. int res = 0;
  222. fid = filp->private_data;
  223. BUG_ON(fid == NULL);
  224. posix_test_lock(filp, fl);
  225. /*
  226. * if we have a conflicting lock locally, no need to validate
  227. * with server
  228. */
  229. if (fl->fl_type != F_UNLCK)
  230. return res;
  231. /* convert posix lock to p9 tgetlock args */
  232. memset(&glock, 0, sizeof(glock));
  233. glock.type = P9_LOCK_TYPE_UNLCK;
  234. glock.start = fl->fl_start;
  235. if (fl->fl_end == OFFSET_MAX)
  236. glock.length = 0;
  237. else
  238. glock.length = fl->fl_end - fl->fl_start + 1;
  239. glock.proc_id = fl->fl_pid;
  240. glock.client_id = fid->clnt->name;
  241. res = p9_client_getlock_dotl(fid, &glock);
  242. if (res < 0)
  243. return res;
  244. /* map 9p lock type to os lock type */
  245. switch (glock.type) {
  246. case P9_LOCK_TYPE_RDLCK:
  247. fl->fl_type = F_RDLCK;
  248. break;
  249. case P9_LOCK_TYPE_WRLCK:
  250. fl->fl_type = F_WRLCK;
  251. break;
  252. case P9_LOCK_TYPE_UNLCK:
  253. fl->fl_type = F_UNLCK;
  254. break;
  255. }
  256. if (glock.type != P9_LOCK_TYPE_UNLCK) {
  257. fl->fl_start = glock.start;
  258. if (glock.length == 0)
  259. fl->fl_end = OFFSET_MAX;
  260. else
  261. fl->fl_end = glock.start + glock.length - 1;
  262. fl->fl_pid = glock.proc_id;
  263. }
  264. kfree(glock.client_id);
  265. return res;
  266. }
  267. /**
  268. * v9fs_file_lock_dotl - lock a file (or directory)
  269. * @filp: file to be locked
  270. * @cmd: lock command
  271. * @fl: file lock structure
  272. *
  273. */
  274. static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl)
  275. {
  276. struct inode *inode = file_inode(filp);
  277. int ret = -ENOLCK;
  278. p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n",
  279. filp, cmd, fl, filp);
  280. /* No mandatory locks */
  281. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  282. goto out_err;
  283. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  284. filemap_write_and_wait(inode->i_mapping);
  285. invalidate_mapping_pages(&inode->i_data, 0, -1);
  286. }
  287. if (IS_SETLK(cmd) || IS_SETLKW(cmd))
  288. ret = v9fs_file_do_lock(filp, cmd, fl);
  289. else if (IS_GETLK(cmd))
  290. ret = v9fs_file_getlock(filp, fl);
  291. else
  292. ret = -EINVAL;
  293. out_err:
  294. return ret;
  295. }
  296. /**
  297. * v9fs_file_flock_dotl - lock a file
  298. * @filp: file to be locked
  299. * @cmd: lock command
  300. * @fl: file lock structure
  301. *
  302. */
  303. static int v9fs_file_flock_dotl(struct file *filp, int cmd,
  304. struct file_lock *fl)
  305. {
  306. struct inode *inode = file_inode(filp);
  307. int ret = -ENOLCK;
  308. p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n",
  309. filp, cmd, fl, filp);
  310. /* No mandatory locks */
  311. if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
  312. goto out_err;
  313. if (!(fl->fl_flags & FL_FLOCK))
  314. goto out_err;
  315. if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
  316. filemap_write_and_wait(inode->i_mapping);
  317. invalidate_mapping_pages(&inode->i_data, 0, -1);
  318. }
  319. /* Convert flock to posix lock */
  320. fl->fl_flags |= FL_POSIX;
  321. fl->fl_flags ^= FL_FLOCK;
  322. if (IS_SETLK(cmd) | IS_SETLKW(cmd))
  323. ret = v9fs_file_do_lock(filp, cmd, fl);
  324. else
  325. ret = -EINVAL;
  326. out_err:
  327. return ret;
  328. }
  329. /**
  330. * v9fs_file_read - read from a file
  331. * @filp: file pointer to read
  332. * @udata: user data buffer to read data into
  333. * @count: size of buffer
  334. * @offset: offset at which to read data
  335. *
  336. */
  337. static ssize_t
  338. v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
  339. {
  340. struct p9_fid *fid = iocb->ki_filp->private_data;
  341. int ret, err;
  342. p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n",
  343. iov_iter_count(to), iocb->ki_pos);
  344. ret = p9_client_read(fid, iocb->ki_pos, to, &err);
  345. if (!ret)
  346. return err;
  347. iocb->ki_pos += ret;
  348. return ret;
  349. }
  350. /**
  351. * v9fs_file_write - write to a file
  352. * @filp: file pointer to write
  353. * @data: data buffer to write data from
  354. * @count: size of buffer
  355. * @offset: offset at which to write data
  356. *
  357. */
  358. static ssize_t
  359. v9fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  360. {
  361. struct file *file = iocb->ki_filp;
  362. ssize_t retval;
  363. loff_t origin;
  364. int err = 0;
  365. retval = generic_write_checks(iocb, from);
  366. if (retval <= 0)
  367. return retval;
  368. origin = iocb->ki_pos;
  369. retval = p9_client_write(file->private_data, iocb->ki_pos, from, &err);
  370. if (retval > 0) {
  371. struct inode *inode = file_inode(file);
  372. loff_t i_size;
  373. unsigned long pg_start, pg_end;
  374. pg_start = origin >> PAGE_CACHE_SHIFT;
  375. pg_end = (origin + retval - 1) >> PAGE_CACHE_SHIFT;
  376. if (inode->i_mapping && inode->i_mapping->nrpages)
  377. invalidate_inode_pages2_range(inode->i_mapping,
  378. pg_start, pg_end);
  379. iocb->ki_pos += retval;
  380. i_size = i_size_read(inode);
  381. if (iocb->ki_pos > i_size) {
  382. inode_add_bytes(inode, iocb->ki_pos - i_size);
  383. i_size_write(inode, iocb->ki_pos);
  384. }
  385. return retval;
  386. }
  387. return err;
  388. }
  389. static int v9fs_file_fsync(struct file *filp, loff_t start, loff_t end,
  390. int datasync)
  391. {
  392. struct p9_fid *fid;
  393. struct inode *inode = filp->f_mapping->host;
  394. struct p9_wstat wstat;
  395. int retval;
  396. retval = filemap_write_and_wait_range(inode->i_mapping, start, end);
  397. if (retval)
  398. return retval;
  399. mutex_lock(&inode->i_mutex);
  400. p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
  401. fid = filp->private_data;
  402. v9fs_blank_wstat(&wstat);
  403. retval = p9_client_wstat(fid, &wstat);
  404. mutex_unlock(&inode->i_mutex);
  405. return retval;
  406. }
  407. int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
  408. int datasync)
  409. {
  410. struct p9_fid *fid;
  411. struct inode *inode = filp->f_mapping->host;
  412. int retval;
  413. retval = filemap_write_and_wait_range(inode->i_mapping, start, end);
  414. if (retval)
  415. return retval;
  416. mutex_lock(&inode->i_mutex);
  417. p9_debug(P9_DEBUG_VFS, "filp %p datasync %x\n", filp, datasync);
  418. fid = filp->private_data;
  419. retval = p9_client_fsync(fid, datasync);
  420. mutex_unlock(&inode->i_mutex);
  421. return retval;
  422. }
  423. static int
  424. v9fs_file_mmap(struct file *filp, struct vm_area_struct *vma)
  425. {
  426. int retval;
  427. retval = generic_file_mmap(filp, vma);
  428. if (!retval)
  429. vma->vm_ops = &v9fs_file_vm_ops;
  430. return retval;
  431. }
  432. static int
  433. v9fs_mmap_file_mmap(struct file *filp, struct vm_area_struct *vma)
  434. {
  435. int retval;
  436. struct inode *inode;
  437. struct v9fs_inode *v9inode;
  438. struct p9_fid *fid;
  439. inode = file_inode(filp);
  440. v9inode = V9FS_I(inode);
  441. mutex_lock(&v9inode->v_mutex);
  442. if (!v9inode->writeback_fid &&
  443. (vma->vm_flags & VM_WRITE)) {
  444. /*
  445. * clone a fid and add it to writeback_fid
  446. * we do it during mmap instead of
  447. * page dirty time via write_begin/page_mkwrite
  448. * because we want write after unlink usecase
  449. * to work.
  450. */
  451. fid = v9fs_writeback_fid(filp->f_path.dentry);
  452. if (IS_ERR(fid)) {
  453. retval = PTR_ERR(fid);
  454. mutex_unlock(&v9inode->v_mutex);
  455. return retval;
  456. }
  457. v9inode->writeback_fid = (void *) fid;
  458. }
  459. mutex_unlock(&v9inode->v_mutex);
  460. retval = generic_file_mmap(filp, vma);
  461. if (!retval)
  462. vma->vm_ops = &v9fs_mmap_file_vm_ops;
  463. return retval;
  464. }
  465. static int
  466. v9fs_vm_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
  467. {
  468. struct v9fs_inode *v9inode;
  469. struct page *page = vmf->page;
  470. struct file *filp = vma->vm_file;
  471. struct inode *inode = file_inode(filp);
  472. p9_debug(P9_DEBUG_VFS, "page %p fid %lx\n",
  473. page, (unsigned long)filp->private_data);
  474. /* Update file times before taking page lock */
  475. file_update_time(filp);
  476. v9inode = V9FS_I(inode);
  477. /* make sure the cache has finished storing the page */
  478. v9fs_fscache_wait_on_page_write(inode, page);
  479. BUG_ON(!v9inode->writeback_fid);
  480. lock_page(page);
  481. if (page->mapping != inode->i_mapping)
  482. goto out_unlock;
  483. wait_for_stable_page(page);
  484. return VM_FAULT_LOCKED;
  485. out_unlock:
  486. unlock_page(page);
  487. return VM_FAULT_NOPAGE;
  488. }
  489. /**
  490. * v9fs_mmap_file_read - read from a file
  491. * @filp: file pointer to read
  492. * @data: user data buffer to read data into
  493. * @count: size of buffer
  494. * @offset: offset at which to read data
  495. *
  496. */
  497. static ssize_t
  498. v9fs_mmap_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
  499. {
  500. /* TODO: Check if there are dirty pages */
  501. return v9fs_file_read_iter(iocb, to);
  502. }
  503. /**
  504. * v9fs_mmap_file_write - write to a file
  505. * @filp: file pointer to write
  506. * @data: data buffer to write data from
  507. * @count: size of buffer
  508. * @offset: offset at which to write data
  509. *
  510. */
  511. static ssize_t
  512. v9fs_mmap_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  513. {
  514. /*
  515. * TODO: invalidate mmaps on filp's inode between
  516. * offset and offset+count
  517. */
  518. return v9fs_file_write_iter(iocb, from);
  519. }
  520. static void v9fs_mmap_vm_close(struct vm_area_struct *vma)
  521. {
  522. struct inode *inode;
  523. struct writeback_control wbc = {
  524. .nr_to_write = LONG_MAX,
  525. .sync_mode = WB_SYNC_ALL,
  526. .range_start = vma->vm_pgoff * PAGE_SIZE,
  527. /* absolute end, byte at end included */
  528. .range_end = vma->vm_pgoff * PAGE_SIZE +
  529. (vma->vm_end - vma->vm_start - 1),
  530. };
  531. p9_debug(P9_DEBUG_VFS, "9p VMA close, %p, flushing", vma);
  532. inode = file_inode(vma->vm_file);
  533. if (!mapping_cap_writeback_dirty(inode->i_mapping))
  534. wbc.nr_to_write = 0;
  535. might_sleep();
  536. sync_inode(inode, &wbc);
  537. }
  538. static const struct vm_operations_struct v9fs_file_vm_ops = {
  539. .fault = filemap_fault,
  540. .map_pages = filemap_map_pages,
  541. .page_mkwrite = v9fs_vm_page_mkwrite,
  542. };
  543. static const struct vm_operations_struct v9fs_mmap_file_vm_ops = {
  544. .close = v9fs_mmap_vm_close,
  545. .fault = filemap_fault,
  546. .map_pages = filemap_map_pages,
  547. .page_mkwrite = v9fs_vm_page_mkwrite,
  548. };
  549. const struct file_operations v9fs_cached_file_operations = {
  550. .llseek = generic_file_llseek,
  551. .read_iter = generic_file_read_iter,
  552. .write_iter = generic_file_write_iter,
  553. .open = v9fs_file_open,
  554. .release = v9fs_dir_release,
  555. .lock = v9fs_file_lock,
  556. .mmap = v9fs_file_mmap,
  557. .fsync = v9fs_file_fsync,
  558. };
  559. const struct file_operations v9fs_cached_file_operations_dotl = {
  560. .llseek = generic_file_llseek,
  561. .read_iter = generic_file_read_iter,
  562. .write_iter = generic_file_write_iter,
  563. .open = v9fs_file_open,
  564. .release = v9fs_dir_release,
  565. .lock = v9fs_file_lock_dotl,
  566. .flock = v9fs_file_flock_dotl,
  567. .mmap = v9fs_file_mmap,
  568. .fsync = v9fs_file_fsync_dotl,
  569. };
  570. const struct file_operations v9fs_file_operations = {
  571. .llseek = generic_file_llseek,
  572. .read_iter = v9fs_file_read_iter,
  573. .write_iter = v9fs_file_write_iter,
  574. .open = v9fs_file_open,
  575. .release = v9fs_dir_release,
  576. .lock = v9fs_file_lock,
  577. .mmap = generic_file_readonly_mmap,
  578. .fsync = v9fs_file_fsync,
  579. };
  580. const struct file_operations v9fs_file_operations_dotl = {
  581. .llseek = generic_file_llseek,
  582. .read_iter = v9fs_file_read_iter,
  583. .write_iter = v9fs_file_write_iter,
  584. .open = v9fs_file_open,
  585. .release = v9fs_dir_release,
  586. .lock = v9fs_file_lock_dotl,
  587. .flock = v9fs_file_flock_dotl,
  588. .mmap = generic_file_readonly_mmap,
  589. .fsync = v9fs_file_fsync_dotl,
  590. };
  591. const struct file_operations v9fs_mmap_file_operations = {
  592. .llseek = generic_file_llseek,
  593. .read_iter = v9fs_mmap_file_read_iter,
  594. .write_iter = v9fs_mmap_file_write_iter,
  595. .open = v9fs_file_open,
  596. .release = v9fs_dir_release,
  597. .lock = v9fs_file_lock,
  598. .mmap = v9fs_mmap_file_mmap,
  599. .fsync = v9fs_file_fsync,
  600. };
  601. const struct file_operations v9fs_mmap_file_operations_dotl = {
  602. .llseek = generic_file_llseek,
  603. .read_iter = v9fs_mmap_file_read_iter,
  604. .write_iter = v9fs_mmap_file_write_iter,
  605. .open = v9fs_file_open,
  606. .release = v9fs_dir_release,
  607. .lock = v9fs_file_lock_dotl,
  608. .flock = v9fs_file_flock_dotl,
  609. .mmap = v9fs_mmap_file_mmap,
  610. .fsync = v9fs_file_fsync_dotl,
  611. };