ops_address.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. /*
  2. * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
  3. * Copyright (C) 2004-2006 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. int new = 0;
  75. uint64_t dblock;
  76. int error;
  77. int boundary;
  78. error = gfs2_block_map(inode, lblock, &new, &dblock, &boundary);
  79. if (error)
  80. return error;
  81. if (dblock)
  82. map_bh(bh_result, inode->i_sb, dblock);
  83. else if (gfs2_assert_withdraw(GFS2_SB(inode), !create))
  84. error = -EIO;
  85. if (boundary)
  86. set_buffer_boundary(bh_result);
  87. return error;
  88. }
  89. /**
  90. * gfs2_writepage - Write complete page
  91. * @page: Page to write
  92. *
  93. * Returns: errno
  94. *
  95. * Some of this is copied from block_write_full_page() although we still
  96. * call it to do most of the work.
  97. */
  98. static int gfs2_writepage(struct page *page, struct writeback_control *wbc)
  99. {
  100. struct inode *inode = page->mapping->host;
  101. struct gfs2_inode *ip = GFS2_I(page->mapping->host);
  102. struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
  103. loff_t i_size = i_size_read(inode);
  104. pgoff_t end_index = i_size >> PAGE_CACHE_SHIFT;
  105. unsigned offset;
  106. int error;
  107. int done_trans = 0;
  108. if (gfs2_assert_withdraw(sdp, gfs2_glock_is_held_excl(ip->i_gl))) {
  109. unlock_page(page);
  110. return -EIO;
  111. }
  112. if (current->journal_info)
  113. goto out_ignore;
  114. /* Is the page fully outside i_size? (truncate in progress) */
  115. offset = i_size & (PAGE_CACHE_SIZE-1);
  116. if (page->index > end_index || (page->index == end_index && !offset)) {
  117. page->mapping->a_ops->invalidatepage(page, 0);
  118. unlock_page(page);
  119. return 0; /* don't care */
  120. }
  121. if (sdp->sd_args.ar_data == GFS2_DATA_ORDERED || gfs2_is_jdata(ip)) {
  122. error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0);
  123. if (error)
  124. goto out_ignore;
  125. gfs2_page_add_databufs(ip, page, 0, sdp->sd_vfs->s_blocksize-1);
  126. done_trans = 1;
  127. }
  128. error = block_write_full_page(page, get_block_noalloc, wbc);
  129. if (done_trans)
  130. gfs2_trans_end(sdp);
  131. gfs2_meta_cache_flush(ip);
  132. return error;
  133. out_ignore:
  134. redirty_page_for_writepage(wbc, page);
  135. unlock_page(page);
  136. return 0;
  137. }
  138. static int zero_readpage(struct page *page)
  139. {
  140. void *kaddr;
  141. kaddr = kmap_atomic(page, KM_USER0);
  142. memset(kaddr, 0, PAGE_CACHE_SIZE);
  143. kunmap_atomic(page, KM_USER0);
  144. SetPageUptodate(page);
  145. return 0;
  146. }
  147. /**
  148. * stuffed_readpage - Fill in a Linux page with stuffed file data
  149. * @ip: the inode
  150. * @page: the page
  151. *
  152. * Returns: errno
  153. */
  154. static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
  155. {
  156. struct buffer_head *dibh;
  157. void *kaddr;
  158. int error;
  159. /* Only the first page of a stuffed file might contain data */
  160. if (unlikely(page->index))
  161. return zero_readpage(page);
  162. error = gfs2_meta_inode_buffer(ip, &dibh);
  163. if (error)
  164. return error;
  165. kaddr = kmap_atomic(page, KM_USER0);
  166. memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode),
  167. ip->i_di.di_size);
  168. memset(kaddr + ip->i_di.di_size, 0, PAGE_CACHE_SIZE - ip->i_di.di_size);
  169. kunmap_atomic(page, KM_USER0);
  170. brelse(dibh);
  171. SetPageUptodate(page);
  172. return 0;
  173. }
  174. /**
  175. * gfs2_readpage - readpage with locking
  176. * @file: The file to read a page for. N.B. This may be NULL if we are
  177. * reading an internal file.
  178. * @page: The page to read
  179. *
  180. * Returns: errno
  181. */
  182. static int gfs2_readpage(struct file *file, struct page *page)
  183. {
  184. struct gfs2_inode *ip = GFS2_I(page->mapping->host);
  185. struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
  186. struct gfs2_holder gh;
  187. int error;
  188. if (likely(file != &gfs2_internal_file_sentinal)) {
  189. gfs2_holder_init(ip->i_gl, LM_ST_SHARED, GL_ATIME|GL_AOP, &gh);
  190. error = gfs2_glock_nq_m_atime(1, &gh);
  191. if (unlikely(error))
  192. goto out_unlock;
  193. }
  194. if (gfs2_is_stuffed(ip)) {
  195. error = stuffed_readpage(ip, page);
  196. unlock_page(page);
  197. } else
  198. error = mpage_readpage(page, gfs2_get_block);
  199. if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)))
  200. error = -EIO;
  201. if (file != &gfs2_internal_file_sentinal) {
  202. gfs2_glock_dq_m(1, &gh);
  203. gfs2_holder_uninit(&gh);
  204. }
  205. out:
  206. return error;
  207. out_unlock:
  208. unlock_page(page);
  209. if (file != &gfs2_internal_file_sentinal)
  210. gfs2_holder_uninit(&gh);
  211. goto out;
  212. }
  213. /**
  214. * gfs2_readpages - Read a bunch of pages at once
  215. *
  216. * Some notes:
  217. * 1. This is only for readahead, so we can simply ignore any things
  218. * which are slightly inconvenient (such as locking conflicts between
  219. * the page lock and the glock) and return having done no I/O. Its
  220. * obviously not something we'd want to do on too regular a basis.
  221. * Any I/O we ignore at this time will be done via readpage later.
  222. * 2. We have to handle stuffed files here too.
  223. * 3. mpage_readpages() does most of the heavy lifting in the common case.
  224. * 4. gfs2_get_block() is relied upon to set BH_Boundary in the right places.
  225. * 5. We use LM_FLAG_TRY_1CB here, effectively we then have lock-ahead as
  226. * well as read-ahead.
  227. */
  228. static int gfs2_readpages(struct file *file, struct address_space *mapping,
  229. struct list_head *pages, unsigned nr_pages)
  230. {
  231. struct inode *inode = mapping->host;
  232. struct gfs2_inode *ip = GFS2_I(inode);
  233. struct gfs2_sbd *sdp = GFS2_SB(inode);
  234. struct gfs2_holder gh;
  235. unsigned page_idx;
  236. int ret;
  237. if (likely(file != &gfs2_internal_file_sentinal)) {
  238. gfs2_holder_init(ip->i_gl, LM_ST_SHARED,
  239. LM_FLAG_TRY_1CB|GL_ATIME|GL_AOP, &gh);
  240. ret = gfs2_glock_nq_m_atime(1, &gh);
  241. if (ret == GLR_TRYFAILED)
  242. goto out_noerror;
  243. if (unlikely(ret))
  244. goto out_unlock;
  245. }
  246. if (gfs2_is_stuffed(ip)) {
  247. struct pagevec lru_pvec;
  248. pagevec_init(&lru_pvec, 0);
  249. for (page_idx = 0; page_idx < nr_pages; page_idx++) {
  250. struct page *page = list_entry(pages->prev, struct page, lru);
  251. prefetchw(&page->flags);
  252. list_del(&page->lru);
  253. if (!add_to_page_cache(page, mapping,
  254. page->index, GFP_KERNEL)) {
  255. ret = stuffed_readpage(ip, page);
  256. unlock_page(page);
  257. if (!pagevec_add(&lru_pvec, page))
  258. __pagevec_lru_add(&lru_pvec);
  259. } else {
  260. page_cache_release(page);
  261. }
  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_entry(pages->prev, struct page, lru);
  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 = GFS2_I(page->mapping->host);
  304. struct gfs2_sbd *sdp = GFS2_SB(page->mapping->host);
  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 = GFS2_I(inode);
  383. struct gfs2_sbd *sdp = GFS2_SB(inode);
  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 = GFS2_I(mapping->host);
  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 = GFS2_I(inode);
  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 = GFS2_I(inode);
  550. struct gfs2_sbd *sdp = GFS2_SB(inode);
  551. int ret;
  552. if (rw == WRITE)
  553. return gfs2_direct_IO_write(iocb, iov, offset, nr_segs);
  554. if (gfs2_assert_warn(sdp, gfs2_glock_is_locked_by_me(ip->i_gl)) ||
  555. gfs2_assert_warn(sdp, !gfs2_is_stuffed(ip)))
  556. return -EINVAL;
  557. mutex_lock(&inode->i_mutex);
  558. ret = __blockdev_direct_IO(READ, iocb, inode, inode->i_sb->s_bdev, iov,
  559. offset, nr_segs, gfs2_get_block, NULL,
  560. DIO_OWN_LOCKING);
  561. mutex_unlock(&inode->i_mutex);
  562. return ret;
  563. }
  564. const struct address_space_operations gfs2_file_aops = {
  565. .writepage = gfs2_writepage,
  566. .readpage = gfs2_readpage,
  567. .readpages = gfs2_readpages,
  568. .sync_page = block_sync_page,
  569. .prepare_write = gfs2_prepare_write,
  570. .commit_write = gfs2_commit_write,
  571. .bmap = gfs2_bmap,
  572. .invalidatepage = gfs2_invalidatepage,
  573. .direct_IO = gfs2_direct_IO,
  574. };