vfs_file.c 17 KB

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