vfs_file.c 17 KB

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