xfs_aops.c 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of version 2 of the GNU General Public License as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it would be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. *
  12. * Further, this software is distributed without any warranty that it is
  13. * free of the rightful claim of any third person regarding infringement
  14. * or the like. Any license provided herein, whether implied or
  15. * otherwise, applies only to this software file. Patent licenses, if
  16. * any, provided herein do not apply to combinations of this program with
  17. * other software, or any other product whatsoever.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write the Free Software Foundation, Inc., 59
  21. * Temple Place - Suite 330, Boston MA 02111-1307, USA.
  22. *
  23. * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
  24. * Mountain View, CA 94043, or:
  25. *
  26. * http://www.sgi.com
  27. *
  28. * For further information regarding this notice, see:
  29. *
  30. * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  31. */
  32. #include "xfs.h"
  33. #include "xfs_inum.h"
  34. #include "xfs_log.h"
  35. #include "xfs_sb.h"
  36. #include "xfs_dir.h"
  37. #include "xfs_dir2.h"
  38. #include "xfs_trans.h"
  39. #include "xfs_dmapi.h"
  40. #include "xfs_mount.h"
  41. #include "xfs_bmap_btree.h"
  42. #include "xfs_alloc_btree.h"
  43. #include "xfs_ialloc_btree.h"
  44. #include "xfs_alloc.h"
  45. #include "xfs_btree.h"
  46. #include "xfs_attr_sf.h"
  47. #include "xfs_dir_sf.h"
  48. #include "xfs_dir2_sf.h"
  49. #include "xfs_dinode.h"
  50. #include "xfs_inode.h"
  51. #include "xfs_error.h"
  52. #include "xfs_rw.h"
  53. #include "xfs_iomap.h"
  54. #include <linux/mpage.h>
  55. #include <linux/writeback.h>
  56. STATIC void xfs_count_page_state(struct page *, int *, int *, int *);
  57. STATIC void xfs_convert_page(struct inode *, struct page *, xfs_iomap_t *,
  58. struct writeback_control *wbc, void *, int, int);
  59. #if defined(XFS_RW_TRACE)
  60. void
  61. xfs_page_trace(
  62. int tag,
  63. struct inode *inode,
  64. struct page *page,
  65. int mask)
  66. {
  67. xfs_inode_t *ip;
  68. bhv_desc_t *bdp;
  69. vnode_t *vp = LINVFS_GET_VP(inode);
  70. loff_t isize = i_size_read(inode);
  71. loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
  72. int delalloc = -1, unmapped = -1, unwritten = -1;
  73. if (page_has_buffers(page))
  74. xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
  75. bdp = vn_bhv_lookup(VN_BHV_HEAD(vp), &xfs_vnodeops);
  76. ip = XFS_BHVTOI(bdp);
  77. if (!ip->i_rwtrace)
  78. return;
  79. ktrace_enter(ip->i_rwtrace,
  80. (void *)((unsigned long)tag),
  81. (void *)ip,
  82. (void *)inode,
  83. (void *)page,
  84. (void *)((unsigned long)mask),
  85. (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
  86. (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
  87. (void *)((unsigned long)((isize >> 32) & 0xffffffff)),
  88. (void *)((unsigned long)(isize & 0xffffffff)),
  89. (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
  90. (void *)((unsigned long)(offset & 0xffffffff)),
  91. (void *)((unsigned long)delalloc),
  92. (void *)((unsigned long)unmapped),
  93. (void *)((unsigned long)unwritten),
  94. (void *)NULL,
  95. (void *)NULL);
  96. }
  97. #else
  98. #define xfs_page_trace(tag, inode, page, mask)
  99. #endif
  100. /*
  101. * Schedule IO completion handling on a xfsdatad if this was
  102. * the final hold on this ioend.
  103. */
  104. STATIC void
  105. xfs_finish_ioend(
  106. xfs_ioend_t *ioend)
  107. {
  108. if (atomic_dec_and_test(&ioend->io_remaining))
  109. queue_work(xfsdatad_workqueue, &ioend->io_work);
  110. }
  111. STATIC void
  112. xfs_destroy_ioend(
  113. xfs_ioend_t *ioend)
  114. {
  115. vn_iowake(ioend->io_vnode);
  116. mempool_free(ioend, xfs_ioend_pool);
  117. }
  118. /*
  119. * Issue transactions to convert a buffer range from unwritten
  120. * to written extents.
  121. */
  122. STATIC void
  123. xfs_end_bio_unwritten(
  124. void *data)
  125. {
  126. xfs_ioend_t *ioend = data;
  127. vnode_t *vp = ioend->io_vnode;
  128. xfs_off_t offset = ioend->io_offset;
  129. size_t size = ioend->io_size;
  130. int error;
  131. if (ioend->io_uptodate)
  132. VOP_BMAP(vp, offset, size, BMAPI_UNWRITTEN, NULL, NULL, error);
  133. xfs_destroy_ioend(ioend);
  134. }
  135. /*
  136. * Allocate and initialise an IO completion structure.
  137. * We need to track unwritten extent write completion here initially.
  138. * We'll need to extend this for updating the ondisk inode size later
  139. * (vs. incore size).
  140. */
  141. STATIC xfs_ioend_t *
  142. xfs_alloc_ioend(
  143. struct inode *inode)
  144. {
  145. xfs_ioend_t *ioend;
  146. ioend = mempool_alloc(xfs_ioend_pool, GFP_NOFS);
  147. /*
  148. * Set the count to 1 initially, which will prevent an I/O
  149. * completion callback from happening before we have started
  150. * all the I/O from calling the completion routine too early.
  151. */
  152. atomic_set(&ioend->io_remaining, 1);
  153. ioend->io_uptodate = 1; /* cleared if any I/O fails */
  154. ioend->io_vnode = LINVFS_GET_VP(inode);
  155. atomic_inc(&ioend->io_vnode->v_iocount);
  156. ioend->io_offset = 0;
  157. ioend->io_size = 0;
  158. INIT_WORK(&ioend->io_work, xfs_end_bio_unwritten, ioend);
  159. return ioend;
  160. }
  161. void
  162. linvfs_unwritten_done(
  163. struct buffer_head *bh,
  164. int uptodate)
  165. {
  166. xfs_ioend_t *ioend = bh->b_private;
  167. ASSERT(buffer_unwritten(bh));
  168. bh->b_end_io = NULL;
  169. clear_buffer_unwritten(bh);
  170. if (!uptodate)
  171. ioend->io_uptodate = 0;
  172. xfs_finish_ioend(ioend);
  173. end_buffer_async_write(bh, uptodate);
  174. }
  175. STATIC int
  176. xfs_map_blocks(
  177. struct inode *inode,
  178. loff_t offset,
  179. ssize_t count,
  180. xfs_iomap_t *mapp,
  181. int flags)
  182. {
  183. vnode_t *vp = LINVFS_GET_VP(inode);
  184. int error, nmaps = 1;
  185. VOP_BMAP(vp, offset, count, flags, mapp, &nmaps, error);
  186. if (!error && (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)))
  187. VMODIFY(vp);
  188. return -error;
  189. }
  190. /*
  191. * Finds the corresponding mapping in block @map array of the
  192. * given @offset within a @page.
  193. */
  194. STATIC xfs_iomap_t *
  195. xfs_offset_to_map(
  196. struct page *page,
  197. xfs_iomap_t *iomapp,
  198. unsigned long offset)
  199. {
  200. loff_t full_offset; /* offset from start of file */
  201. ASSERT(offset < PAGE_CACHE_SIZE);
  202. full_offset = page->index; /* NB: using 64bit number */
  203. full_offset <<= PAGE_CACHE_SHIFT; /* offset from file start */
  204. full_offset += offset; /* offset from page start */
  205. if (full_offset < iomapp->iomap_offset)
  206. return NULL;
  207. if (iomapp->iomap_offset + (iomapp->iomap_bsize -1) >= full_offset)
  208. return iomapp;
  209. return NULL;
  210. }
  211. STATIC void
  212. xfs_map_at_offset(
  213. struct page *page,
  214. struct buffer_head *bh,
  215. unsigned long offset,
  216. int block_bits,
  217. xfs_iomap_t *iomapp)
  218. {
  219. xfs_daddr_t bn;
  220. loff_t delta;
  221. int sector_shift;
  222. ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
  223. ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
  224. ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
  225. delta = page->index;
  226. delta <<= PAGE_CACHE_SHIFT;
  227. delta += offset;
  228. delta -= iomapp->iomap_offset;
  229. delta >>= block_bits;
  230. sector_shift = block_bits - BBSHIFT;
  231. bn = iomapp->iomap_bn >> sector_shift;
  232. bn += delta;
  233. BUG_ON(!bn && !(iomapp->iomap_flags & IOMAP_REALTIME));
  234. ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
  235. lock_buffer(bh);
  236. bh->b_blocknr = bn;
  237. bh->b_bdev = iomapp->iomap_target->pbr_bdev;
  238. set_buffer_mapped(bh);
  239. clear_buffer_delay(bh);
  240. }
  241. /*
  242. * Look for a page at index which is unlocked and contains our
  243. * unwritten extent flagged buffers at its head. Returns page
  244. * locked and with an extra reference count, and length of the
  245. * unwritten extent component on this page that we can write,
  246. * in units of filesystem blocks.
  247. */
  248. STATIC struct page *
  249. xfs_probe_unwritten_page(
  250. struct address_space *mapping,
  251. pgoff_t index,
  252. xfs_iomap_t *iomapp,
  253. xfs_ioend_t *ioend,
  254. unsigned long max_offset,
  255. unsigned long *fsbs,
  256. unsigned int bbits)
  257. {
  258. struct page *page;
  259. page = find_trylock_page(mapping, index);
  260. if (!page)
  261. return NULL;
  262. if (PageWriteback(page))
  263. goto out;
  264. if (page->mapping && page_has_buffers(page)) {
  265. struct buffer_head *bh, *head;
  266. unsigned long p_offset = 0;
  267. *fsbs = 0;
  268. bh = head = page_buffers(page);
  269. do {
  270. if (!buffer_unwritten(bh) || !buffer_uptodate(bh))
  271. break;
  272. if (!xfs_offset_to_map(page, iomapp, p_offset))
  273. break;
  274. if (p_offset >= max_offset)
  275. break;
  276. xfs_map_at_offset(page, bh, p_offset, bbits, iomapp);
  277. set_buffer_unwritten_io(bh);
  278. bh->b_private = ioend;
  279. p_offset += bh->b_size;
  280. (*fsbs)++;
  281. } while ((bh = bh->b_this_page) != head);
  282. if (p_offset)
  283. return page;
  284. }
  285. out:
  286. unlock_page(page);
  287. return NULL;
  288. }
  289. /*
  290. * Look for a page at index which is unlocked and not mapped
  291. * yet - clustering for mmap write case.
  292. */
  293. STATIC unsigned int
  294. xfs_probe_unmapped_page(
  295. struct address_space *mapping,
  296. pgoff_t index,
  297. unsigned int pg_offset)
  298. {
  299. struct page *page;
  300. int ret = 0;
  301. page = find_trylock_page(mapping, index);
  302. if (!page)
  303. return 0;
  304. if (PageWriteback(page))
  305. goto out;
  306. if (page->mapping && PageDirty(page)) {
  307. if (page_has_buffers(page)) {
  308. struct buffer_head *bh, *head;
  309. bh = head = page_buffers(page);
  310. do {
  311. if (buffer_mapped(bh) || !buffer_uptodate(bh))
  312. break;
  313. ret += bh->b_size;
  314. if (ret >= pg_offset)
  315. break;
  316. } while ((bh = bh->b_this_page) != head);
  317. } else
  318. ret = PAGE_CACHE_SIZE;
  319. }
  320. out:
  321. unlock_page(page);
  322. return ret;
  323. }
  324. STATIC unsigned int
  325. xfs_probe_unmapped_cluster(
  326. struct inode *inode,
  327. struct page *startpage,
  328. struct buffer_head *bh,
  329. struct buffer_head *head)
  330. {
  331. pgoff_t tindex, tlast, tloff;
  332. unsigned int pg_offset, len, total = 0;
  333. struct address_space *mapping = inode->i_mapping;
  334. /* First sum forwards in this page */
  335. do {
  336. if (buffer_mapped(bh))
  337. break;
  338. total += bh->b_size;
  339. } while ((bh = bh->b_this_page) != head);
  340. /* If we reached the end of the page, sum forwards in
  341. * following pages.
  342. */
  343. if (bh == head) {
  344. tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
  345. /* Prune this back to avoid pathological behavior */
  346. tloff = min(tlast, startpage->index + 64);
  347. for (tindex = startpage->index + 1; tindex < tloff; tindex++) {
  348. len = xfs_probe_unmapped_page(mapping, tindex,
  349. PAGE_CACHE_SIZE);
  350. if (!len)
  351. return total;
  352. total += len;
  353. }
  354. if (tindex == tlast &&
  355. (pg_offset = i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
  356. total += xfs_probe_unmapped_page(mapping,
  357. tindex, pg_offset);
  358. }
  359. }
  360. return total;
  361. }
  362. /*
  363. * Probe for a given page (index) in the inode and test if it is delayed
  364. * and without unwritten buffers. Returns page locked and with an extra
  365. * reference count.
  366. */
  367. STATIC struct page *
  368. xfs_probe_delalloc_page(
  369. struct inode *inode,
  370. pgoff_t index)
  371. {
  372. struct page *page;
  373. page = find_trylock_page(inode->i_mapping, index);
  374. if (!page)
  375. return NULL;
  376. if (PageWriteback(page))
  377. goto out;
  378. if (page->mapping && page_has_buffers(page)) {
  379. struct buffer_head *bh, *head;
  380. int acceptable = 0;
  381. bh = head = page_buffers(page);
  382. do {
  383. if (buffer_unwritten(bh)) {
  384. acceptable = 0;
  385. break;
  386. } else if (buffer_delay(bh)) {
  387. acceptable = 1;
  388. }
  389. } while ((bh = bh->b_this_page) != head);
  390. if (acceptable)
  391. return page;
  392. }
  393. out:
  394. unlock_page(page);
  395. return NULL;
  396. }
  397. STATIC int
  398. xfs_map_unwritten(
  399. struct inode *inode,
  400. struct page *start_page,
  401. struct buffer_head *head,
  402. struct buffer_head *curr,
  403. unsigned long p_offset,
  404. int block_bits,
  405. xfs_iomap_t *iomapp,
  406. struct writeback_control *wbc,
  407. int startio,
  408. int all_bh)
  409. {
  410. struct buffer_head *bh = curr;
  411. xfs_iomap_t *tmp;
  412. xfs_ioend_t *ioend;
  413. loff_t offset;
  414. unsigned long nblocks = 0;
  415. offset = start_page->index;
  416. offset <<= PAGE_CACHE_SHIFT;
  417. offset += p_offset;
  418. ioend = xfs_alloc_ioend(inode);
  419. /* First map forwards in the page consecutive buffers
  420. * covering this unwritten extent
  421. */
  422. do {
  423. if (!buffer_unwritten(bh))
  424. break;
  425. tmp = xfs_offset_to_map(start_page, iomapp, p_offset);
  426. if (!tmp)
  427. break;
  428. xfs_map_at_offset(start_page, bh, p_offset, block_bits, iomapp);
  429. set_buffer_unwritten_io(bh);
  430. bh->b_private = ioend;
  431. p_offset += bh->b_size;
  432. nblocks++;
  433. } while ((bh = bh->b_this_page) != head);
  434. atomic_add(nblocks, &ioend->io_remaining);
  435. /* If we reached the end of the page, map forwards in any
  436. * following pages which are also covered by this extent.
  437. */
  438. if (bh == head) {
  439. struct address_space *mapping = inode->i_mapping;
  440. pgoff_t tindex, tloff, tlast;
  441. unsigned long bs;
  442. unsigned int pg_offset, bbits = inode->i_blkbits;
  443. struct page *page;
  444. tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
  445. tloff = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
  446. tloff = min(tlast, tloff);
  447. for (tindex = start_page->index + 1; tindex < tloff; tindex++) {
  448. page = xfs_probe_unwritten_page(mapping,
  449. tindex, iomapp, ioend,
  450. PAGE_CACHE_SIZE, &bs, bbits);
  451. if (!page)
  452. break;
  453. nblocks += bs;
  454. atomic_add(bs, &ioend->io_remaining);
  455. xfs_convert_page(inode, page, iomapp, wbc, ioend,
  456. startio, all_bh);
  457. /* stop if converting the next page might add
  458. * enough blocks that the corresponding byte
  459. * count won't fit in our ulong page buf length */
  460. if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
  461. goto enough;
  462. }
  463. if (tindex == tlast &&
  464. (pg_offset = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1)))) {
  465. page = xfs_probe_unwritten_page(mapping,
  466. tindex, iomapp, ioend,
  467. pg_offset, &bs, bbits);
  468. if (page) {
  469. nblocks += bs;
  470. atomic_add(bs, &ioend->io_remaining);
  471. xfs_convert_page(inode, page, iomapp, wbc, ioend,
  472. startio, all_bh);
  473. if (nblocks >= ((ULONG_MAX - PAGE_SIZE) >> block_bits))
  474. goto enough;
  475. }
  476. }
  477. }
  478. enough:
  479. ioend->io_size = (xfs_off_t)nblocks << block_bits;
  480. ioend->io_offset = offset;
  481. xfs_finish_ioend(ioend);
  482. return 0;
  483. }
  484. STATIC void
  485. xfs_submit_page(
  486. struct page *page,
  487. struct writeback_control *wbc,
  488. struct buffer_head *bh_arr[],
  489. int bh_count,
  490. int probed_page,
  491. int clear_dirty)
  492. {
  493. struct buffer_head *bh;
  494. int i;
  495. BUG_ON(PageWriteback(page));
  496. if (bh_count)
  497. set_page_writeback(page);
  498. if (clear_dirty)
  499. clear_page_dirty(page);
  500. unlock_page(page);
  501. if (bh_count) {
  502. for (i = 0; i < bh_count; i++) {
  503. bh = bh_arr[i];
  504. mark_buffer_async_write(bh);
  505. if (buffer_unwritten(bh))
  506. set_buffer_unwritten_io(bh);
  507. set_buffer_uptodate(bh);
  508. clear_buffer_dirty(bh);
  509. }
  510. for (i = 0; i < bh_count; i++)
  511. submit_bh(WRITE, bh_arr[i]);
  512. if (probed_page && clear_dirty)
  513. wbc->nr_to_write--; /* Wrote an "extra" page */
  514. }
  515. }
  516. /*
  517. * Allocate & map buffers for page given the extent map. Write it out.
  518. * except for the original page of a writepage, this is called on
  519. * delalloc/unwritten pages only, for the original page it is possible
  520. * that the page has no mapping at all.
  521. */
  522. STATIC void
  523. xfs_convert_page(
  524. struct inode *inode,
  525. struct page *page,
  526. xfs_iomap_t *iomapp,
  527. struct writeback_control *wbc,
  528. void *private,
  529. int startio,
  530. int all_bh)
  531. {
  532. struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
  533. xfs_iomap_t *mp = iomapp, *tmp;
  534. unsigned long offset, end_offset;
  535. int index = 0;
  536. int bbits = inode->i_blkbits;
  537. int len, page_dirty;
  538. end_offset = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1));
  539. /*
  540. * page_dirty is initially a count of buffers on the page before
  541. * EOF and is decrememted as we move each into a cleanable state.
  542. */
  543. len = 1 << inode->i_blkbits;
  544. end_offset = max(end_offset, PAGE_CACHE_SIZE);
  545. end_offset = roundup(end_offset, len);
  546. page_dirty = end_offset / len;
  547. offset = 0;
  548. bh = head = page_buffers(page);
  549. do {
  550. if (offset >= end_offset)
  551. break;
  552. if (!(PageUptodate(page) || buffer_uptodate(bh)))
  553. continue;
  554. if (buffer_mapped(bh) && all_bh &&
  555. !(buffer_unwritten(bh) || buffer_delay(bh))) {
  556. if (startio) {
  557. lock_buffer(bh);
  558. bh_arr[index++] = bh;
  559. page_dirty--;
  560. }
  561. continue;
  562. }
  563. tmp = xfs_offset_to_map(page, mp, offset);
  564. if (!tmp)
  565. continue;
  566. ASSERT(!(tmp->iomap_flags & IOMAP_HOLE));
  567. ASSERT(!(tmp->iomap_flags & IOMAP_DELAY));
  568. /* If this is a new unwritten extent buffer (i.e. one
  569. * that we haven't passed in private data for, we must
  570. * now map this buffer too.
  571. */
  572. if (buffer_unwritten(bh) && !bh->b_end_io) {
  573. ASSERT(tmp->iomap_flags & IOMAP_UNWRITTEN);
  574. xfs_map_unwritten(inode, page, head, bh, offset,
  575. bbits, tmp, wbc, startio, all_bh);
  576. } else if (! (buffer_unwritten(bh) && buffer_locked(bh))) {
  577. xfs_map_at_offset(page, bh, offset, bbits, tmp);
  578. if (buffer_unwritten(bh)) {
  579. set_buffer_unwritten_io(bh);
  580. bh->b_private = private;
  581. ASSERT(private);
  582. }
  583. }
  584. if (startio) {
  585. bh_arr[index++] = bh;
  586. } else {
  587. set_buffer_dirty(bh);
  588. unlock_buffer(bh);
  589. mark_buffer_dirty(bh);
  590. }
  591. page_dirty--;
  592. } while (offset += len, (bh = bh->b_this_page) != head);
  593. if (startio && index) {
  594. xfs_submit_page(page, wbc, bh_arr, index, 1, !page_dirty);
  595. } else {
  596. unlock_page(page);
  597. }
  598. }
  599. /*
  600. * Convert & write out a cluster of pages in the same extent as defined
  601. * by mp and following the start page.
  602. */
  603. STATIC void
  604. xfs_cluster_write(
  605. struct inode *inode,
  606. pgoff_t tindex,
  607. xfs_iomap_t *iomapp,
  608. struct writeback_control *wbc,
  609. int startio,
  610. int all_bh,
  611. pgoff_t tlast)
  612. {
  613. struct page *page;
  614. for (; tindex <= tlast; tindex++) {
  615. page = xfs_probe_delalloc_page(inode, tindex);
  616. if (!page)
  617. break;
  618. xfs_convert_page(inode, page, iomapp, wbc, NULL,
  619. startio, all_bh);
  620. }
  621. }
  622. /*
  623. * Calling this without startio set means we are being asked to make a dirty
  624. * page ready for freeing it's buffers. When called with startio set then
  625. * we are coming from writepage.
  626. *
  627. * When called with startio set it is important that we write the WHOLE
  628. * page if possible.
  629. * The bh->b_state's cannot know if any of the blocks or which block for
  630. * that matter are dirty due to mmap writes, and therefore bh uptodate is
  631. * only vaild if the page itself isn't completely uptodate. Some layers
  632. * may clear the page dirty flag prior to calling write page, under the
  633. * assumption the entire page will be written out; by not writing out the
  634. * whole page the page can be reused before all valid dirty data is
  635. * written out. Note: in the case of a page that has been dirty'd by
  636. * mapwrite and but partially setup by block_prepare_write the
  637. * bh->b_states's will not agree and only ones setup by BPW/BCW will have
  638. * valid state, thus the whole page must be written out thing.
  639. */
  640. STATIC int
  641. xfs_page_state_convert(
  642. struct inode *inode,
  643. struct page *page,
  644. struct writeback_control *wbc,
  645. int startio,
  646. int unmapped) /* also implies page uptodate */
  647. {
  648. struct buffer_head *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
  649. xfs_iomap_t *iomp, iomap;
  650. loff_t offset;
  651. unsigned long p_offset = 0;
  652. __uint64_t end_offset;
  653. pgoff_t end_index, last_index, tlast;
  654. int len, err, i, cnt = 0, uptodate = 1;
  655. int flags;
  656. int page_dirty;
  657. /* wait for other IO threads? */
  658. flags = (startio && wbc->sync_mode != WB_SYNC_NONE) ? 0 : BMAPI_TRYLOCK;
  659. /* Is this page beyond the end of the file? */
  660. offset = i_size_read(inode);
  661. end_index = offset >> PAGE_CACHE_SHIFT;
  662. last_index = (offset - 1) >> PAGE_CACHE_SHIFT;
  663. if (page->index >= end_index) {
  664. if ((page->index >= end_index + 1) ||
  665. !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
  666. err = -EIO;
  667. goto error;
  668. }
  669. }
  670. end_offset = min_t(unsigned long long,
  671. (loff_t)(page->index + 1) << PAGE_CACHE_SHIFT, offset);
  672. offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
  673. /*
  674. * page_dirty is initially a count of buffers on the page before
  675. * EOF and is decrememted as we move each into a cleanable state.
  676. */
  677. len = 1 << inode->i_blkbits;
  678. p_offset = max(p_offset, PAGE_CACHE_SIZE);
  679. p_offset = roundup(p_offset, len);
  680. page_dirty = p_offset / len;
  681. iomp = NULL;
  682. p_offset = 0;
  683. bh = head = page_buffers(page);
  684. do {
  685. if (offset >= end_offset)
  686. break;
  687. if (!buffer_uptodate(bh))
  688. uptodate = 0;
  689. if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio)
  690. continue;
  691. if (iomp) {
  692. iomp = xfs_offset_to_map(page, &iomap, p_offset);
  693. }
  694. /*
  695. * First case, map an unwritten extent and prepare for
  696. * extent state conversion transaction on completion.
  697. */
  698. if (buffer_unwritten(bh)) {
  699. if (!startio)
  700. continue;
  701. if (!iomp) {
  702. err = xfs_map_blocks(inode, offset, len, &iomap,
  703. BMAPI_READ|BMAPI_IGNSTATE);
  704. if (err) {
  705. goto error;
  706. }
  707. iomp = xfs_offset_to_map(page, &iomap,
  708. p_offset);
  709. }
  710. if (iomp) {
  711. if (!bh->b_end_io) {
  712. err = xfs_map_unwritten(inode, page,
  713. head, bh, p_offset,
  714. inode->i_blkbits, iomp,
  715. wbc, startio, unmapped);
  716. if (err) {
  717. goto error;
  718. }
  719. } else {
  720. set_bit(BH_Lock, &bh->b_state);
  721. }
  722. BUG_ON(!buffer_locked(bh));
  723. bh_arr[cnt++] = bh;
  724. page_dirty--;
  725. }
  726. /*
  727. * Second case, allocate space for a delalloc buffer.
  728. * We can return EAGAIN here in the release page case.
  729. */
  730. } else if (buffer_delay(bh)) {
  731. if (!iomp) {
  732. err = xfs_map_blocks(inode, offset, len, &iomap,
  733. BMAPI_ALLOCATE | flags);
  734. if (err) {
  735. goto error;
  736. }
  737. iomp = xfs_offset_to_map(page, &iomap,
  738. p_offset);
  739. }
  740. if (iomp) {
  741. xfs_map_at_offset(page, bh, p_offset,
  742. inode->i_blkbits, iomp);
  743. if (startio) {
  744. bh_arr[cnt++] = bh;
  745. } else {
  746. set_buffer_dirty(bh);
  747. unlock_buffer(bh);
  748. mark_buffer_dirty(bh);
  749. }
  750. page_dirty--;
  751. }
  752. } else if ((buffer_uptodate(bh) || PageUptodate(page)) &&
  753. (unmapped || startio)) {
  754. if (!buffer_mapped(bh)) {
  755. int size;
  756. /*
  757. * Getting here implies an unmapped buffer
  758. * was found, and we are in a path where we
  759. * need to write the whole page out.
  760. */
  761. if (!iomp) {
  762. size = xfs_probe_unmapped_cluster(
  763. inode, page, bh, head);
  764. err = xfs_map_blocks(inode, offset,
  765. size, &iomap,
  766. BMAPI_WRITE|BMAPI_MMAP);
  767. if (err) {
  768. goto error;
  769. }
  770. iomp = xfs_offset_to_map(page, &iomap,
  771. p_offset);
  772. }
  773. if (iomp) {
  774. xfs_map_at_offset(page,
  775. bh, p_offset,
  776. inode->i_blkbits, iomp);
  777. if (startio) {
  778. bh_arr[cnt++] = bh;
  779. } else {
  780. set_buffer_dirty(bh);
  781. unlock_buffer(bh);
  782. mark_buffer_dirty(bh);
  783. }
  784. page_dirty--;
  785. }
  786. } else if (startio) {
  787. if (buffer_uptodate(bh) &&
  788. !test_and_set_bit(BH_Lock, &bh->b_state)) {
  789. bh_arr[cnt++] = bh;
  790. page_dirty--;
  791. }
  792. }
  793. }
  794. } while (offset += len, p_offset += len,
  795. ((bh = bh->b_this_page) != head));
  796. if (uptodate && bh == head)
  797. SetPageUptodate(page);
  798. if (startio) {
  799. xfs_submit_page(page, wbc, bh_arr, cnt, 0, !page_dirty);
  800. }
  801. if (iomp) {
  802. offset = (iomp->iomap_offset + iomp->iomap_bsize - 1) >>
  803. PAGE_CACHE_SHIFT;
  804. tlast = min_t(pgoff_t, offset, last_index);
  805. xfs_cluster_write(inode, page->index + 1, iomp, wbc,
  806. startio, unmapped, tlast);
  807. }
  808. return page_dirty;
  809. error:
  810. for (i = 0; i < cnt; i++) {
  811. unlock_buffer(bh_arr[i]);
  812. }
  813. /*
  814. * If it's delalloc and we have nowhere to put it,
  815. * throw it away, unless the lower layers told
  816. * us to try again.
  817. */
  818. if (err != -EAGAIN) {
  819. if (!unmapped) {
  820. block_invalidatepage(page, 0);
  821. }
  822. ClearPageUptodate(page);
  823. }
  824. return err;
  825. }
  826. STATIC int
  827. __linvfs_get_block(
  828. struct inode *inode,
  829. sector_t iblock,
  830. unsigned long blocks,
  831. struct buffer_head *bh_result,
  832. int create,
  833. int direct,
  834. bmapi_flags_t flags)
  835. {
  836. vnode_t *vp = LINVFS_GET_VP(inode);
  837. xfs_iomap_t iomap;
  838. int retpbbm = 1;
  839. int error;
  840. ssize_t size;
  841. loff_t offset = (loff_t)iblock << inode->i_blkbits;
  842. if (blocks)
  843. size = blocks << inode->i_blkbits;
  844. else
  845. size = 1 << inode->i_blkbits;
  846. VOP_BMAP(vp, offset, size,
  847. create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
  848. if (error)
  849. return -error;
  850. if (retpbbm == 0)
  851. return 0;
  852. if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
  853. xfs_daddr_t bn;
  854. loff_t delta;
  855. /* For unwritten extents do not report a disk address on
  856. * the read case (treat as if we're reading into a hole).
  857. */
  858. if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) {
  859. delta = offset - iomap.iomap_offset;
  860. delta >>= inode->i_blkbits;
  861. bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
  862. bn += delta;
  863. BUG_ON(!bn && !(iomap.iomap_flags & IOMAP_REALTIME));
  864. bh_result->b_blocknr = bn;
  865. set_buffer_mapped(bh_result);
  866. }
  867. if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
  868. if (direct)
  869. bh_result->b_private = inode;
  870. set_buffer_unwritten(bh_result);
  871. set_buffer_delay(bh_result);
  872. }
  873. }
  874. /* If this is a realtime file, data might be on a new device */
  875. bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
  876. /* If we previously allocated a block out beyond eof and
  877. * we are now coming back to use it then we will need to
  878. * flag it as new even if it has a disk address.
  879. */
  880. if (create &&
  881. ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
  882. (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) {
  883. set_buffer_new(bh_result);
  884. }
  885. if (iomap.iomap_flags & IOMAP_DELAY) {
  886. BUG_ON(direct);
  887. if (create) {
  888. set_buffer_uptodate(bh_result);
  889. set_buffer_mapped(bh_result);
  890. set_buffer_delay(bh_result);
  891. }
  892. }
  893. if (blocks) {
  894. bh_result->b_size = (ssize_t)min(
  895. (loff_t)(iomap.iomap_bsize - iomap.iomap_delta),
  896. (loff_t)(blocks << inode->i_blkbits));
  897. }
  898. return 0;
  899. }
  900. int
  901. linvfs_get_block(
  902. struct inode *inode,
  903. sector_t iblock,
  904. struct buffer_head *bh_result,
  905. int create)
  906. {
  907. return __linvfs_get_block(inode, iblock, 0, bh_result,
  908. create, 0, BMAPI_WRITE);
  909. }
  910. STATIC int
  911. linvfs_get_blocks_direct(
  912. struct inode *inode,
  913. sector_t iblock,
  914. unsigned long max_blocks,
  915. struct buffer_head *bh_result,
  916. int create)
  917. {
  918. return __linvfs_get_block(inode, iblock, max_blocks, bh_result,
  919. create, 1, BMAPI_WRITE|BMAPI_DIRECT);
  920. }
  921. STATIC void
  922. linvfs_end_io_direct(
  923. struct kiocb *iocb,
  924. loff_t offset,
  925. ssize_t size,
  926. void *private)
  927. {
  928. xfs_ioend_t *ioend = iocb->private;
  929. /*
  930. * Non-NULL private data means we need to issue a transaction to
  931. * convert a range from unwritten to written extents. This needs
  932. * to happen from process contect but aio+dio I/O completion
  933. * happens from irq context so we need to defer it to a workqueue.
  934. * This is not nessecary for synchronous direct I/O, but we do
  935. * it anyway to keep the code uniform and simpler.
  936. *
  937. * The core direct I/O code might be changed to always call the
  938. * completion handler in the future, in which case all this can
  939. * go away.
  940. */
  941. if (private && size > 0) {
  942. ioend->io_offset = offset;
  943. ioend->io_size = size;
  944. xfs_finish_ioend(ioend);
  945. } else {
  946. ASSERT(size >= 0);
  947. xfs_destroy_ioend(ioend);
  948. }
  949. /*
  950. * blockdev_direct_IO can return an error even afer the I/O
  951. * completion handler was called. Thus we need to protect
  952. * against double-freeing.
  953. */
  954. iocb->private = NULL;
  955. }
  956. STATIC ssize_t
  957. linvfs_direct_IO(
  958. int rw,
  959. struct kiocb *iocb,
  960. const struct iovec *iov,
  961. loff_t offset,
  962. unsigned long nr_segs)
  963. {
  964. struct file *file = iocb->ki_filp;
  965. struct inode *inode = file->f_mapping->host;
  966. vnode_t *vp = LINVFS_GET_VP(inode);
  967. xfs_iomap_t iomap;
  968. int maps = 1;
  969. int error;
  970. ssize_t ret;
  971. VOP_BMAP(vp, offset, 0, BMAPI_DEVICE, &iomap, &maps, error);
  972. if (error)
  973. return -error;
  974. iocb->private = xfs_alloc_ioend(inode);
  975. ret = blockdev_direct_IO_own_locking(rw, iocb, inode,
  976. iomap.iomap_target->pbr_bdev,
  977. iov, offset, nr_segs,
  978. linvfs_get_blocks_direct,
  979. linvfs_end_io_direct);
  980. if (unlikely(ret <= 0 && iocb->private))
  981. xfs_destroy_ioend(iocb->private);
  982. return ret;
  983. }
  984. STATIC sector_t
  985. linvfs_bmap(
  986. struct address_space *mapping,
  987. sector_t block)
  988. {
  989. struct inode *inode = (struct inode *)mapping->host;
  990. vnode_t *vp = LINVFS_GET_VP(inode);
  991. int error;
  992. vn_trace_entry(vp, "linvfs_bmap", (inst_t *)__return_address);
  993. VOP_RWLOCK(vp, VRWLOCK_READ);
  994. VOP_FLUSH_PAGES(vp, (xfs_off_t)0, -1, 0, FI_REMAPF, error);
  995. VOP_RWUNLOCK(vp, VRWLOCK_READ);
  996. return generic_block_bmap(mapping, block, linvfs_get_block);
  997. }
  998. STATIC int
  999. linvfs_readpage(
  1000. struct file *unused,
  1001. struct page *page)
  1002. {
  1003. return mpage_readpage(page, linvfs_get_block);
  1004. }
  1005. STATIC int
  1006. linvfs_readpages(
  1007. struct file *unused,
  1008. struct address_space *mapping,
  1009. struct list_head *pages,
  1010. unsigned nr_pages)
  1011. {
  1012. return mpage_readpages(mapping, pages, nr_pages, linvfs_get_block);
  1013. }
  1014. STATIC void
  1015. xfs_count_page_state(
  1016. struct page *page,
  1017. int *delalloc,
  1018. int *unmapped,
  1019. int *unwritten)
  1020. {
  1021. struct buffer_head *bh, *head;
  1022. *delalloc = *unmapped = *unwritten = 0;
  1023. bh = head = page_buffers(page);
  1024. do {
  1025. if (buffer_uptodate(bh) && !buffer_mapped(bh))
  1026. (*unmapped) = 1;
  1027. else if (buffer_unwritten(bh) && !buffer_delay(bh))
  1028. clear_buffer_unwritten(bh);
  1029. else if (buffer_unwritten(bh))
  1030. (*unwritten) = 1;
  1031. else if (buffer_delay(bh))
  1032. (*delalloc) = 1;
  1033. } while ((bh = bh->b_this_page) != head);
  1034. }
  1035. /*
  1036. * writepage: Called from one of two places:
  1037. *
  1038. * 1. we are flushing a delalloc buffer head.
  1039. *
  1040. * 2. we are writing out a dirty page. Typically the page dirty
  1041. * state is cleared before we get here. In this case is it
  1042. * conceivable we have no buffer heads.
  1043. *
  1044. * For delalloc space on the page we need to allocate space and
  1045. * flush it. For unmapped buffer heads on the page we should
  1046. * allocate space if the page is uptodate. For any other dirty
  1047. * buffer heads on the page we should flush them.
  1048. *
  1049. * If we detect that a transaction would be required to flush
  1050. * the page, we have to check the process flags first, if we
  1051. * are already in a transaction or disk I/O during allocations
  1052. * is off, we need to fail the writepage and redirty the page.
  1053. */
  1054. STATIC int
  1055. linvfs_writepage(
  1056. struct page *page,
  1057. struct writeback_control *wbc)
  1058. {
  1059. int error;
  1060. int need_trans;
  1061. int delalloc, unmapped, unwritten;
  1062. struct inode *inode = page->mapping->host;
  1063. xfs_page_trace(XFS_WRITEPAGE_ENTER, inode, page, 0);
  1064. /*
  1065. * We need a transaction if:
  1066. * 1. There are delalloc buffers on the page
  1067. * 2. The page is uptodate and we have unmapped buffers
  1068. * 3. The page is uptodate and we have no buffers
  1069. * 4. There are unwritten buffers on the page
  1070. */
  1071. if (!page_has_buffers(page)) {
  1072. unmapped = 1;
  1073. need_trans = 1;
  1074. } else {
  1075. xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
  1076. if (!PageUptodate(page))
  1077. unmapped = 0;
  1078. need_trans = delalloc + unmapped + unwritten;
  1079. }
  1080. /*
  1081. * If we need a transaction and the process flags say
  1082. * we are already in a transaction, or no IO is allowed
  1083. * then mark the page dirty again and leave the page
  1084. * as is.
  1085. */
  1086. if (PFLAGS_TEST_FSTRANS() && need_trans)
  1087. goto out_fail;
  1088. /*
  1089. * Delay hooking up buffer heads until we have
  1090. * made our go/no-go decision.
  1091. */
  1092. if (!page_has_buffers(page))
  1093. create_empty_buffers(page, 1 << inode->i_blkbits, 0);
  1094. /*
  1095. * Convert delayed allocate, unwritten or unmapped space
  1096. * to real space and flush out to disk.
  1097. */
  1098. error = xfs_page_state_convert(inode, page, wbc, 1, unmapped);
  1099. if (error == -EAGAIN)
  1100. goto out_fail;
  1101. if (unlikely(error < 0))
  1102. goto out_unlock;
  1103. return 0;
  1104. out_fail:
  1105. redirty_page_for_writepage(wbc, page);
  1106. unlock_page(page);
  1107. return 0;
  1108. out_unlock:
  1109. unlock_page(page);
  1110. return error;
  1111. }
  1112. STATIC int
  1113. linvfs_invalidate_page(
  1114. struct page *page,
  1115. unsigned long offset)
  1116. {
  1117. xfs_page_trace(XFS_INVALIDPAGE_ENTER,
  1118. page->mapping->host, page, offset);
  1119. return block_invalidatepage(page, offset);
  1120. }
  1121. /*
  1122. * Called to move a page into cleanable state - and from there
  1123. * to be released. Possibly the page is already clean. We always
  1124. * have buffer heads in this call.
  1125. *
  1126. * Returns 0 if the page is ok to release, 1 otherwise.
  1127. *
  1128. * Possible scenarios are:
  1129. *
  1130. * 1. We are being called to release a page which has been written
  1131. * to via regular I/O. buffer heads will be dirty and possibly
  1132. * delalloc. If no delalloc buffer heads in this case then we
  1133. * can just return zero.
  1134. *
  1135. * 2. We are called to release a page which has been written via
  1136. * mmap, all we need to do is ensure there is no delalloc
  1137. * state in the buffer heads, if not we can let the caller
  1138. * free them and we should come back later via writepage.
  1139. */
  1140. STATIC int
  1141. linvfs_release_page(
  1142. struct page *page,
  1143. int gfp_mask)
  1144. {
  1145. struct inode *inode = page->mapping->host;
  1146. int dirty, delalloc, unmapped, unwritten;
  1147. struct writeback_control wbc = {
  1148. .sync_mode = WB_SYNC_ALL,
  1149. .nr_to_write = 1,
  1150. };
  1151. xfs_page_trace(XFS_RELEASEPAGE_ENTER, inode, page, gfp_mask);
  1152. xfs_count_page_state(page, &delalloc, &unmapped, &unwritten);
  1153. if (!delalloc && !unwritten)
  1154. goto free_buffers;
  1155. if (!(gfp_mask & __GFP_FS))
  1156. return 0;
  1157. /* If we are already inside a transaction or the thread cannot
  1158. * do I/O, we cannot release this page.
  1159. */
  1160. if (PFLAGS_TEST_FSTRANS())
  1161. return 0;
  1162. /*
  1163. * Convert delalloc space to real space, do not flush the
  1164. * data out to disk, that will be done by the caller.
  1165. * Never need to allocate space here - we will always
  1166. * come back to writepage in that case.
  1167. */
  1168. dirty = xfs_page_state_convert(inode, page, &wbc, 0, 0);
  1169. if (dirty == 0 && !unwritten)
  1170. goto free_buffers;
  1171. return 0;
  1172. free_buffers:
  1173. return try_to_free_buffers(page);
  1174. }
  1175. STATIC int
  1176. linvfs_prepare_write(
  1177. struct file *file,
  1178. struct page *page,
  1179. unsigned int from,
  1180. unsigned int to)
  1181. {
  1182. return block_prepare_write(page, from, to, linvfs_get_block);
  1183. }
  1184. struct address_space_operations linvfs_aops = {
  1185. .readpage = linvfs_readpage,
  1186. .readpages = linvfs_readpages,
  1187. .writepage = linvfs_writepage,
  1188. .sync_page = block_sync_page,
  1189. .releasepage = linvfs_release_page,
  1190. .invalidatepage = linvfs_invalidate_page,
  1191. .prepare_write = linvfs_prepare_write,
  1192. .commit_write = generic_commit_write,
  1193. .bmap = linvfs_bmap,
  1194. .direct_IO = linvfs_direct_IO,
  1195. };