ops_address.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
  4. *
  5. * This copyrighted material is made available to anyone wishing to use,
  6. * modify, copy, or redistribute it subject to the terms and conditions
  7. * of the GNU General Public License v.2.
  8. */
  9. #include <linux/sched.h>
  10. #include <linux/slab.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/completion.h>
  13. #include <linux/buffer_head.h>
  14. #include <linux/pagemap.h>
  15. #include <linux/pagevec.h>
  16. #include <linux/mpage.h>
  17. #include <linux/fs.h>
  18. #include <linux/gfs2_ondisk.h>
  19. #include "gfs2.h"
  20. #include "lm_interface.h"
  21. #include "incore.h"
  22. #include "bmap.h"
  23. #include "glock.h"
  24. #include "inode.h"
  25. #include "log.h"
  26. #include "meta_io.h"
  27. #include "ops_address.h"
  28. #include "page.h"
  29. #include "quota.h"
  30. #include "trans.h"
  31. #include "rgrp.h"
  32. #include "ops_file.h"
  33. #include "util.h"
  34. /**
  35. * gfs2_get_block - Fills in a buffer head with details about a block
  36. * @inode: The inode
  37. * @lblock: The block number to look up
  38. * @bh_result: The buffer head to return the result in
  39. * @create: Non-zero if we may add block to the file
  40. *
  41. * Returns: errno
  42. */
  43. int gfs2_get_block(struct inode *inode, sector_t lblock,
  44. struct buffer_head *bh_result, int create)
  45. {
  46. int new = create;
  47. uint64_t dblock;
  48. int error;
  49. int boundary;
  50. error = gfs2_block_map(inode, lblock, &new, &dblock, &boundary);
  51. if (error)
  52. return error;
  53. if (!dblock)
  54. return 0;
  55. map_bh(bh_result, inode->i_sb, dblock);
  56. if (new)
  57. set_buffer_new(bh_result);
  58. if (boundary)
  59. set_buffer_boundary(bh_result);
  60. return 0;
  61. }
  62. /**
  63. * get_block_noalloc - Fills in a buffer head with details about a block
  64. * @inode: The inode
  65. * @lblock: The block number to look up
  66. * @bh_result: The buffer head to return the result in
  67. * @create: Non-zero if we may add block to the file
  68. *
  69. * Returns: errno
  70. */
  71. static int get_block_noalloc(struct inode *inode, sector_t lblock,
  72. struct buffer_head *bh_result, int create)
  73. {
  74. struct gfs2_inode *ip = inode->u.generic_ip;
  75. int new = 0;
  76. uint64_t dblock;
  77. int error;
  78. int boundary;
  79. error = gfs2_block_map(inode, lblock, &new, &dblock, &boundary);
  80. if (error)
  81. return error;
  82. if (dblock)
  83. map_bh(bh_result, inode->i_sb, dblock);
  84. else if (gfs2_assert_withdraw(ip->i_sbd, !create))
  85. error = -EIO;
  86. if (boundary)
  87. set_buffer_boundary(bh_result);
  88. return error;
  89. }
  90. /**
  91. * gfs2_writepage - Write complete page
  92. * @page: Page to write
  93. *
  94. * Returns: errno
  95. *
  96. * Some of this is copied from block_write_full_page() although we still
  97. * call it to do most of the work.
  98. */
  99. static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
  100. {
  101. struct inode *inode = page->mapping->host;
  102. struct gfs2_inode *ip = page->mapping->host->u.generic_ip;
  103. struct gfs2_sbd *sdp = ip->i_sbd;
  104. loff_t i_size = i_size_read(inode);
  105. pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
  106. unsigned offset;
  107. int error;
  108. int done_trans = 0;
  109. if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl))) {
  110. unlock_page(page);
  111. return -EIO;
  112. }
  113. if (current->journal_info)
  114. goto out_ignore;
  115. /* Is the page fully outside i_size? (truncate in progress) */
  116. offset = i_size & (PAGE_CACHE_SIZE-1);
  117. if (page->index > end_index || (page->index == end_index && !offset)) {
  118. page->mapping->a_ops->invalidatepage(page, 0);
  119. unlock_page(page);
  120. return 0; /* don't care */
  121. }
  122. if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) {
  123. error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0);
  124. if (error)
  125. goto out_ignore;
  126. gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1);
  127. done_trans = 1;
  128. }
  129. error = block_write_full_page(page, get_block_noalloc, wbc);
  130. if (done_trans)
  131. gfs2_trans_end(sdp);
  132. gfs2_meta_cache_flush(ip);
  133. return error;
  134. out_ignore:
  135. redirty_page_for_writepage(wbc, page);
  136. unlock_page(page);
  137. return 0;
  138. }
  139. static int zero_readpage(struct page *page)
  140. {
  141. void *kaddr;
  142. kaddr = kmap_atomic(page, KM_USER0);
  143. memset(kaddr, 0, PAGE_CACHE_SIZE);
  144. kunmap_atomic(page, KM_USER0);
  145. SetPageUptodate(page);
  146. return 0;
  147. }
  148. /**
  149. * stuffed_readpage - Fill in a Linux page with stuffed file data
  150. * @ip: the inode
  151. * @page: the page
  152. *
  153. * Returns: errno
  154. */
  155. static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
  156. {
  157. struct buffer_head *dibh;
  158. void *kaddr;
  159. int error;
  160. /* Only the first page of a stuffed file might contain data */
  161. if (unlikely(page->index))
  162. return zero_readpage(page);
  163. error = gfs2_meta_inode_buffer(ip, &dibh);
  164. if (error)
  165. return error;
  166. kaddr = kmap_atomic(page, KM_USER0);
  167. memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
  168. ip->i_di.di_size);
  169. memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size);
  170. kunmap_atomic(page, KM_USER0);
  171. brelse(dibh);
  172. SetPageUptodate(page);
  173. return 0;
  174. }
  175. /**
  176. * gfs2_readpage - readpage with locking
  177. * @file: The file to read a page for. N.B. This may be NULL if we are
  178. * reading an internal file.
  179. * @page: The page to read
  180. *
  181. * Returns: errno
  182. */
  183. static int gfs2_readpage(struct file *file, struct page *page)
  184. {
  185. struct gfs2_inode *ip = page->mapping->host->u.generic_ip;
  186. struct gfs2_sbd *sdp = ip->i_sbd;
  187. struct gfs2_holder gh;
  188. int error;
  189. if (likely(file != &gfs2_internal_file_sentinal)) {
  190. gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|GL_AOP, &gh);
  191. error = gfs2_glock_nq_m_atime(1, &gh);
  192. if (unlikely(error))
  193. goto out_unlock;
  194. }
  195. if (gfs2_is_stuffed(ip)) {
  196. error = stuffed_readpage(ip, page);
  197. unlock_page(page);
  198. } else
  199. error = mpage_readpage(page, gfs2_get_block);
  200. if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
  201. error = -EIO;
  202. if (file != &gfs2_internal_file_sentinal) {
  203. gfs2_glock_dq_m(1, &gh);
  204. gfs2_holder_uninit(&gh);
  205. }
  206. out:
  207. return error;
  208. out_unlock:
  209. unlock_page(page);
  210. if (file != &gfs2_internal_file_sentinal)
  211. gfs2_holder_uninit(&gh);
  212. goto out;
  213. }
  214. #define list_to_page(head) (list_entry((head)->prev, struct page, lru))
  215. /**
  216. * gfs2_readpages - Read a bunch of pages at once
  217. *
  218. * Some notes:
  219. * 1. This is only for readahead, so we can simply ignore any things
  220. * which are slightly inconvenient (such as locking conflicts between
  221. * the page lock and the glock) and return having done no I/O. Its
  222. * obviously not something we'd want to do on too regular a basis.
  223. * Any I/O we ignore at this time will be done via readpage later.
  224. * 2. We have to handle stuffed files here too.
  225. * 3. mpage_readpages() does most of the heavy lifting in the common case.
  226. * 4. gfs2_get_block() is relied upon to set BH_Boundary in the right places.
  227. * 5. We use LM_FLAG_TRY_1CB here, effectively we then have lock-ahead as
  228. * well as read-ahead.
  229. */
  230. static int gfs2_readpages(struct file *file, struct address_space *mapping,
  231. struct list_head *pages, unsigned nr_pages)
  232. {
  233. struct inode *inode = mapping->host;
  234. struct gfs2_inode *ip = inode->u.generic_ip;
  235. struct gfs2_sbd *sdp = ip->i_sbd;
  236. struct gfs2_holder gh;
  237. unsigned page_idx;
  238. int ret;
  239. if (likely(file != &gfs2_internal_file_sentinal)) {
  240. gfs2_holder_init(ip->i_gl, LM_ST_SHARED,
  241. LM_FLAG_TRY_1CB|GL_ATIME|GL_AOP, &gh);
  242. ret = gfs2_glock_nq_m_atime(1, &gh);
  243. if (ret == GLR_TRYFAILED)
  244. goto out_noerror;
  245. if (unlikely(ret))
  246. goto out_unlock;
  247. }
  248. if (gfs2_is_stuffed(ip)) {
  249. struct pagevec lru_pvec;
  250. pagevec_init(&lru_pvec, 0);
  251. for (page_idx = 0; page_idx < nr_pages; page_idx++) {
  252. struct page *page = list_to_page(pages);
  253. list_del(&page->lru);
  254. if (!add_to_page_cache(page, mapping,
  255. page->index, GFP_KERNEL)) {
  256. ret = stuffed_readpage(ip, page);
  257. unlock_page(page);
  258. if (!pagevec_add(&lru_pvec, page))
  259. __pagevec_lru_add(&lru_pvec);
  260. }
  261. page_cache_release(page);
  262. }
  263. pagevec_lru_add(&lru_pvec);
  264. ret = 0;
  265. } else {
  266. /* What we really want to do .... */
  267. ret = mpage_readpages(mapping, pages, nr_pages, gfs2_get_block);
  268. }
  269. if (likely(file != &gfs2_internal_file_sentinal)) {
  270. gfs2_glock_dq_m(1, &gh);
  271. gfs2_holder_uninit(&gh);
  272. }
  273. out:
  274. if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
  275. ret = -EIO;
  276. return ret;
  277. out_noerror:
  278. ret = 0;
  279. out_unlock:
  280. /* unlock all pages, we can't do any I/O right now */
  281. for (page_idx = 0; page_idx < nr_pages; page_idx++) {
  282. struct page *page = list_to_page(pages);
  283. list_del(&page->lru);
  284. unlock_page(page);
  285. page_cache_release(page);
  286. }
  287. if (likely(file != &gfs2_internal_file_sentinal))
  288. gfs2_holder_uninit(&gh);
  289. goto out;
  290. }
  291. /**
  292. * gfs2_prepare_write - Prepare to write a page to a file
  293. * @file: The file to write to
  294. * @page: The page which is to be prepared for writing
  295. * @from: From (byte range within page)
  296. * @to: To (byte range within page)
  297. *
  298. * Returns: errno
  299. */
  300. static int gfs2_prepare_write(struct file *file, struct page *page,
  301. unsigned from, unsigned to)
  302. {
  303. struct gfs2_inode *ip = page->mapping->host->u.generic_ip;
  304. struct gfs2_sbd *sdp = ip->i_sbd;
  305. unsigned int data_blocks, ind_blocks, rblocks;
  306. int alloc_required;
  307. int error = 0;
  308. loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + from;
  309. loff_t end = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
  310. struct gfs2_alloc *al;
  311. gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_ATIME|GL_AOP, &ip->i_gh);
  312. error = gfs2_glock_nq_m_atime(1, &ip->i_gh);
  313. if (error)
  314. goto out_uninit;
  315. gfs2_write_calc_reserv(ip, to - from, &data_blocks, &ind_blocks);
  316. error = gfs2_write_alloc_required(ip, pos, from - to, &alloc_required);
  317. if (error)
  318. goto out_unlock;
  319. if (alloc_required) {
  320. al = gfs2_alloc_get(ip);
  321. error = gfs2_quota_lock(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE);
  322. if (error)
  323. goto out_alloc_put;
  324. error = gfs2_quota_check(ip, ip->i_di.di_uid, ip->i_di.di_gid);
  325. if (error)
  326. goto out_qunlock;
  327. al->al_requested = data_blocks + ind_blocks;
  328. error = gfs2_inplace_reserve(ip);
  329. if (error)
  330. goto out_qunlock;
  331. }
  332. rblocks = RES_DINODE + ind_blocks;
  333. if (gfs2_is_jdata(ip))
  334. rblocks += data_blocks ? data_blocks : 1;
  335. if (ind_blocks || data_blocks)
  336. rblocks += RES_STATFS + RES_QUOTA;
  337. error = gfs2_trans_begin(sdp, rblocks, 0);
  338. if (error)
  339. goto out;
  340. if (gfs2_is_stuffed(ip)) {
  341. if (end > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
  342. error = gfs2_unstuff_dinode(ip, gfs2_unstuffer_page,
  343. page);
  344. if (error == 0)
  345. goto prepare_write;
  346. } else if (!PageUptodate(page))
  347. error = stuffed_readpage(ip, page);
  348. goto out;
  349. }
  350. prepare_write:
  351. error = block_prepare_write(page, from, to, gfs2_get_block);
  352. out:
  353. if (error) {
  354. gfs2_trans_end(sdp);
  355. if (alloc_required) {
  356. gfs2_inplace_release(ip);
  357. out_qunlock:
  358. gfs2_quota_unlock(ip);
  359. out_alloc_put:
  360. gfs2_alloc_put(ip);
  361. }
  362. out_unlock:
  363. gfs2_glock_dq_m(1, &ip->i_gh);
  364. out_uninit:
  365. gfs2_holder_uninit(&ip->i_gh);
  366. }
  367. return error;
  368. }
  369. /**
  370. * gfs2_commit_write - Commit write to a file
  371. * @file: The file to write to
  372. * @page: The page containing the data
  373. * @from: From (byte range within page)
  374. * @to: To (byte range within page)
  375. *
  376. * Returns: errno
  377. */
  378. static int gfs2_commit_write(struct file *file, struct page *page,
  379. unsigned from, unsigned to)
  380. {
  381. struct inode *inode = page->mapping->host;
  382. struct gfs2_inode *ip = inode->u.generic_ip;
  383. struct gfs2_sbd *sdp = ip->i_sbd;
  384. int error = -EOPNOTSUPP;
  385. struct buffer_head *dibh;
  386. struct gfs2_alloc *al = &ip->i_alloc;;
  387. if (gfs2_assert_withdraw(sdp, gfs2_glock_is_locked_by_me(ip->i_gl)))
  388. goto fail_nounlock;
  389. error = gfs2_meta_inode_buffer(ip, &dibh);
  390. if (error)
  391. goto fail_endtrans;
  392. gfs2_trans_add_bh(ip->i_gl, dibh, 1);
  393. if (gfs2_is_stuffed(ip)) {
  394. uint64_t file_size;
  395. void *kaddr;
  396. file_size = ((uint64_t)page->index << PAGE_CACHE_SHIFT) + to;
  397. kaddr = kmap_atomic(page, KM_USER0);
  398. memcpy(dibh->b_data + sizeof(struct gfs2_dinode) + from,
  399. (char *)kaddr + from, to - from);
  400. kunmap_atomic(page, KM_USER0);
  401. SetPageUptodate(page);
  402. if (inode->i_size < file_size)
  403. i_size_write(inode, file_size);
  404. } else {
  405. if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED ||
  406. gfs2_is_jdata(ip))
  407. gfs2_page_add_databufs(ip, page, from, to);
  408. error = generic_commit_write(file, page, from, to);
  409. if (error)
  410. goto fail;
  411. }
  412. if (ip->i_di.di_size < inode->i_size)
  413. ip->i_di.di_size = inode->i_size;
  414. gfs2_dinode_out(&ip->i_di, dibh->b_data);
  415. brelse(dibh);
  416. gfs2_trans_end(sdp);
  417. if (al->al_requested) {
  418. gfs2_inplace_release(ip);
  419. gfs2_quota_unlock(ip);
  420. gfs2_alloc_put(ip);
  421. }
  422. gfs2_glock_dq_m(1, &ip->i_gh);
  423. gfs2_holder_uninit(&ip->i_gh);
  424. return 0;
  425. fail:
  426. brelse(dibh);
  427. fail_endtrans:
  428. gfs2_trans_end(sdp);
  429. if (al->al_requested) {
  430. gfs2_inplace_release(ip);
  431. gfs2_quota_unlock(ip);
  432. gfs2_alloc_put(ip);
  433. }
  434. gfs2_glock_dq_m(1, &ip->i_gh);
  435. gfs2_holder_uninit(&ip->i_gh);
  436. fail_nounlock:
  437. ClearPageUptodate(page);
  438. return error;
  439. }
  440. /**
  441. * gfs2_bmap - Block map function
  442. * @mapping: Address space info
  443. * @lblock: The block to map
  444. *
  445. * Returns: The disk address for the block or 0 on hole or error
  446. */
  447. static sector_t gfs2_bmap(struct address_space *mapping, sector_t lblock)
  448. {
  449. struct gfs2_inode *ip = mapping->host->u.generic_ip;
  450. struct gfs2_holder i_gh;
  451. sector_t dblock = 0;
  452. int error;
  453. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
  454. if (error)
  455. return 0;
  456. if (!gfs2_is_stuffed(ip))
  457. dblock = generic_block_bmap(mapping, lblock, gfs2_get_block);
  458. gfs2_glock_dq_uninit(&i_gh);
  459. return dblock;
  460. }
  461. static void discard_buffer(struct gfs2_sbd *sdp, struct buffer_head *bh)
  462. {
  463. struct gfs2_bufdata *bd;
  464. gfs2_log_lock(sdp);
  465. bd = bh->b_private;
  466. if (bd) {
  467. bd->bd_bh = NULL;
  468. bh->b_private = NULL;
  469. gfs2_log_unlock(sdp);
  470. brelse(bh);
  471. } else
  472. gfs2_log_unlock(sdp);
  473. lock_buffer(bh);
  474. clear_buffer_dirty(bh);
  475. bh->b_bdev = NULL;
  476. clear_buffer_mapped(bh);
  477. clear_buffer_req(bh);
  478. clear_buffer_new(bh);
  479. clear_buffer_delay(bh);
  480. unlock_buffer(bh);
  481. }
  482. static void gfs2_invalidatepage(struct page *page, unsigned long offset)
  483. {
  484. struct gfs2_sbd *sdp = page->mapping->host->i_sb->s_fs_info;
  485. struct buffer_head *head, *bh, *next;
  486. unsigned int curr_off = 0;
  487. BUG_ON(!PageLocked(page));
  488. if (!page_has_buffers(page))
  489. return;
  490. bh = head = page_buffers(page);
  491. do {
  492. unsigned int next_off = curr_off + bh->b_size;
  493. next = bh->b_this_page;
  494. if (offset <= curr_off)
  495. discard_buffer(sdp, bh);
  496. curr_off = next_off;
  497. bh = next;
  498. } while (bh != head);
  499. if (!offset)
  500. try_to_release_page(page, 0);
  501. return;
  502. }
  503. static ssize_t gfs2_direct_IO_write(struct kiocb *iocb, const struct iovec *iov,
  504. loff_t offset, unsigned long nr_segs)
  505. {
  506. struct file *file = iocb->ki_filp;
  507. struct inode *inode = file->f_mapping->host;
  508. struct gfs2_inode *ip = inode->u.generic_ip;
  509. struct gfs2_holder gh;
  510. int rv;
  511. /*
  512. * Shared lock, even though its write, since we do no allocation
  513. * on this path. All we need change is atime.
  514. */
  515. gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME, &gh);
  516. rv = gfs2_glock_nq_m_atime(1, &gh);
  517. if (rv)
  518. goto out;
  519. /*
  520. * Should we return an error here? I can't see that O_DIRECT for
  521. * a journaled file makes any sense. For now we'll silently fall
  522. * back to buffered I/O, likewise we do the same for stuffed
  523. * files since they are (a) small and (b) unaligned.
  524. */
  525. if (gfs2_is_jdata(ip))
  526. goto out;
  527. if (gfs2_is_stuffed(ip))
  528. goto out;
  529. rv = __blockdev_direct_IO(WRITE, iocb, inode, inode->i_sb->s_bdev,
  530. iov, offset, nr_segs, gfs2_get_block,
  531. NULL, DIO_OWN_LOCKING);
  532. out:
  533. gfs2_glock_dq_m(1, &gh);
  534. gfs2_holder_uninit(&gh);
  535. return rv;
  536. }
  537. /**
  538. * gfs2_direct_IO
  539. *
  540. * This is called with a shared lock already held for the read path.
  541. * Currently, no locks are held when the write path is called.
  542. */
  543. static ssize_t gfs2_direct_IO(int rw, struct kiocb *iocb,
  544. const struct iovec *iov, loff_t offset,
  545. unsigned long nr_segs)
  546. {
  547. struct file *file = iocb->ki_filp;
  548. struct inode *inode = file->f_mapping->host;
  549. struct gfs2_inode *ip = inode->u.generic_ip;
  550. struct gfs2_sbd *sdp = ip->i_sbd;
  551. if (rw == WRITE)
  552. return gfs2_direct_IO_write(iocb, iov, offset, nr_segs);
  553. if (gfs2_assert_warn(sdp, gfs2_glock_is_locked_by_me(ip->i_gl)) ||
  554. gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip)))
  555. return -EINVAL;
  556. return __blockdev_direct_IO(READ, iocb, inode, inode->i_sb->s_bdev, iov,
  557. offset, nr_segs, gfs2_get_block, NULL,
  558. DIO_OWN_LOCKING);
  559. }
  560. struct address_space_operations gfs2_file_aops = {
  561. .writepage = gfs2_writepage,
  562. .readpage = gfs2_readpage,
  563. .readpages = gfs2_readpages,
  564. .sync_page = block_sync_page,
  565. .prepare_write = gfs2_prepare_write,
  566. .commit_write = gfs2_commit_write,
  567. .bmap = gfs2_bmap,
  568. .invalidatepage = gfs2_invalidatepage,
  569. .direct_IO = gfs2_direct_IO,
  570. };