addr.c 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248
  1. #include <linux/ceph/ceph_debug.h>
  2. #include <linux/backing-dev.h>
  3. #include <linux/fs.h>
  4. #include <linux/mm.h>
  5. #include <linux/pagemap.h>
  6. #include <linux/writeback.h> /* generic_writepages */
  7. #include <linux/slab.h>
  8. #include <linux/pagevec.h>
  9. #include <linux/task_io_accounting_ops.h>
  10. #include "super.h"
  11. #include "mds_client.h"
  12. #include <linux/ceph/osd_client.h>
  13. /*
  14. * Ceph address space ops.
  15. *
  16. * There are a few funny things going on here.
  17. *
  18. * The page->private field is used to reference a struct
  19. * ceph_snap_context for _every_ dirty page. This indicates which
  20. * snapshot the page was logically dirtied in, and thus which snap
  21. * context needs to be associated with the osd write during writeback.
  22. *
  23. * Similarly, struct ceph_inode_info maintains a set of counters to
  24. * count dirty pages on the inode. In the absence of snapshots,
  25. * i_wrbuffer_ref == i_wrbuffer_ref_head == the dirty page count.
  26. *
  27. * When a snapshot is taken (that is, when the client receives
  28. * notification that a snapshot was taken), each inode with caps and
  29. * with dirty pages (dirty pages implies there is a cap) gets a new
  30. * ceph_cap_snap in the i_cap_snaps list (which is sorted in ascending
  31. * order, new snaps go to the tail). The i_wrbuffer_ref_head count is
  32. * moved to capsnap->dirty. (Unless a sync write is currently in
  33. * progress. In that case, the capsnap is said to be "pending", new
  34. * writes cannot start, and the capsnap isn't "finalized" until the
  35. * write completes (or fails) and a final size/mtime for the inode for
  36. * that snap can be settled upon.) i_wrbuffer_ref_head is reset to 0.
  37. *
  38. * On writeback, we must submit writes to the osd IN SNAP ORDER. So,
  39. * we look for the first capsnap in i_cap_snaps and write out pages in
  40. * that snap context _only_. Then we move on to the next capsnap,
  41. * eventually reaching the "live" or "head" context (i.e., pages that
  42. * are not yet snapped) and are writing the most recently dirtied
  43. * pages.
  44. *
  45. * Invalidate and so forth must take care to ensure the dirty page
  46. * accounting is preserved.
  47. */
  48. #define CONGESTION_ON_THRESH(congestion_kb) (congestion_kb >> (PAGE_SHIFT-10))
  49. #define CONGESTION_OFF_THRESH(congestion_kb) \
  50. (CONGESTION_ON_THRESH(congestion_kb) - \
  51. (CONGESTION_ON_THRESH(congestion_kb) >> 2))
  52. static inline struct ceph_snap_context *page_snap_context(struct page *page)
  53. {
  54. if (PagePrivate(page))
  55. return (void *)page->private;
  56. return NULL;
  57. }
  58. /*
  59. * Dirty a page. Optimistically adjust accounting, on the assumption
  60. * that we won't race with invalidate. If we do, readjust.
  61. */
  62. static int ceph_set_page_dirty(struct page *page)
  63. {
  64. struct address_space *mapping = page->mapping;
  65. struct inode *inode;
  66. struct ceph_inode_info *ci;
  67. int undo = 0;
  68. struct ceph_snap_context *snapc;
  69. if (unlikely(!mapping))
  70. return !TestSetPageDirty(page);
  71. if (TestSetPageDirty(page)) {
  72. dout("%p set_page_dirty %p idx %lu -- already dirty\n",
  73. mapping->host, page, page->index);
  74. return 0;
  75. }
  76. inode = mapping->host;
  77. ci = ceph_inode(inode);
  78. /*
  79. * Note that we're grabbing a snapc ref here without holding
  80. * any locks!
  81. */
  82. snapc = ceph_get_snap_context(ci->i_snap_realm->cached_context);
  83. /* dirty the head */
  84. spin_lock(&ci->i_ceph_lock);
  85. if (ci->i_head_snapc == NULL)
  86. ci->i_head_snapc = ceph_get_snap_context(snapc);
  87. ++ci->i_wrbuffer_ref_head;
  88. if (ci->i_wrbuffer_ref == 0)
  89. ihold(inode);
  90. ++ci->i_wrbuffer_ref;
  91. dout("%p set_page_dirty %p idx %lu head %d/%d -> %d/%d "
  92. "snapc %p seq %lld (%d snaps)\n",
  93. mapping->host, page, page->index,
  94. ci->i_wrbuffer_ref-1, ci->i_wrbuffer_ref_head-1,
  95. ci->i_wrbuffer_ref, ci->i_wrbuffer_ref_head,
  96. snapc, snapc->seq, snapc->num_snaps);
  97. spin_unlock(&ci->i_ceph_lock);
  98. /* now adjust page */
  99. spin_lock_irq(&mapping->tree_lock);
  100. if (page->mapping) { /* Race with truncate? */
  101. WARN_ON_ONCE(!PageUptodate(page));
  102. account_page_dirtied(page, page->mapping);
  103. radix_tree_tag_set(&mapping->page_tree,
  104. page_index(page), PAGECACHE_TAG_DIRTY);
  105. /*
  106. * Reference snap context in page->private. Also set
  107. * PagePrivate so that we get invalidatepage callback.
  108. */
  109. page->private = (unsigned long)snapc;
  110. SetPagePrivate(page);
  111. } else {
  112. dout("ANON set_page_dirty %p (raced truncate?)\n", page);
  113. undo = 1;
  114. }
  115. spin_unlock_irq(&mapping->tree_lock);
  116. if (undo)
  117. /* whoops, we failed to dirty the page */
  118. ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
  119. __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
  120. BUG_ON(!PageDirty(page));
  121. return 1;
  122. }
  123. /*
  124. * If we are truncating the full page (i.e. offset == 0), adjust the
  125. * dirty page counters appropriately. Only called if there is private
  126. * data on the page.
  127. */
  128. static void ceph_invalidatepage(struct page *page, unsigned long offset)
  129. {
  130. struct inode *inode;
  131. struct ceph_inode_info *ci;
  132. struct ceph_snap_context *snapc = page_snap_context(page);
  133. BUG_ON(!PageLocked(page));
  134. BUG_ON(!PagePrivate(page));
  135. BUG_ON(!page->mapping);
  136. inode = page->mapping->host;
  137. /*
  138. * We can get non-dirty pages here due to races between
  139. * set_page_dirty and truncate_complete_page; just spit out a
  140. * warning, in case we end up with accounting problems later.
  141. */
  142. if (!PageDirty(page))
  143. pr_err("%p invalidatepage %p page not dirty\n", inode, page);
  144. if (offset == 0)
  145. ClearPageChecked(page);
  146. ci = ceph_inode(inode);
  147. if (offset == 0) {
  148. dout("%p invalidatepage %p idx %lu full dirty page %lu\n",
  149. inode, page, page->index, offset);
  150. ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
  151. ceph_put_snap_context(snapc);
  152. page->private = 0;
  153. ClearPagePrivate(page);
  154. } else {
  155. dout("%p invalidatepage %p idx %lu partial dirty page\n",
  156. inode, page, page->index);
  157. }
  158. }
  159. /* just a sanity check */
  160. static int ceph_releasepage(struct page *page, gfp_t g)
  161. {
  162. struct inode *inode = page->mapping ? page->mapping->host : NULL;
  163. dout("%p releasepage %p idx %lu\n", inode, page, page->index);
  164. WARN_ON(PageDirty(page));
  165. WARN_ON(PagePrivate(page));
  166. return 0;
  167. }
  168. /*
  169. * read a single page, without unlocking it.
  170. */
  171. static int readpage_nounlock(struct file *filp, struct page *page)
  172. {
  173. struct inode *inode = file_inode(filp);
  174. struct ceph_inode_info *ci = ceph_inode(inode);
  175. struct ceph_osd_client *osdc =
  176. &ceph_inode_to_client(inode)->client->osdc;
  177. int err = 0;
  178. u64 len = PAGE_CACHE_SIZE;
  179. dout("readpage inode %p file %p page %p index %lu\n",
  180. inode, filp, page, page->index);
  181. err = ceph_osdc_readpages(osdc, ceph_vino(inode), &ci->i_layout,
  182. (u64) page_offset(page), &len,
  183. ci->i_truncate_seq, ci->i_truncate_size,
  184. &page, 1, 0);
  185. if (err == -ENOENT)
  186. err = 0;
  187. if (err < 0) {
  188. SetPageError(page);
  189. goto out;
  190. } else if (err < PAGE_CACHE_SIZE) {
  191. /* zero fill remainder of page */
  192. zero_user_segment(page, err, PAGE_CACHE_SIZE);
  193. }
  194. SetPageUptodate(page);
  195. out:
  196. return err < 0 ? err : 0;
  197. }
  198. static int ceph_readpage(struct file *filp, struct page *page)
  199. {
  200. int r = readpage_nounlock(filp, page);
  201. unlock_page(page);
  202. return r;
  203. }
  204. /*
  205. * Finish an async read(ahead) op.
  206. */
  207. static void finish_read(struct ceph_osd_request *req, struct ceph_msg *msg)
  208. {
  209. struct inode *inode = req->r_inode;
  210. int rc = req->r_result;
  211. int bytes = le32_to_cpu(msg->hdr.data_len);
  212. int num_pages;
  213. int i;
  214. dout("finish_read %p req %p rc %d bytes %d\n", inode, req, rc, bytes);
  215. /* unlock all pages, zeroing any data we didn't read */
  216. BUG_ON(req->r_data_in.type != CEPH_OSD_DATA_TYPE_PAGES);
  217. num_pages = calc_pages_for((u64)req->r_data_in.alignment,
  218. (u64)req->r_data_in.length);
  219. for (i = 0; i < num_pages; i++) {
  220. struct page *page = req->r_data_in.pages[i];
  221. if (bytes < (int)PAGE_CACHE_SIZE) {
  222. /* zero (remainder of) page */
  223. int s = bytes < 0 ? 0 : bytes;
  224. zero_user_segment(page, s, PAGE_CACHE_SIZE);
  225. }
  226. dout("finish_read %p uptodate %p idx %lu\n", inode, page,
  227. page->index);
  228. flush_dcache_page(page);
  229. SetPageUptodate(page);
  230. unlock_page(page);
  231. page_cache_release(page);
  232. bytes -= PAGE_CACHE_SIZE;
  233. }
  234. kfree(req->r_data_in.pages);
  235. }
  236. static void ceph_unlock_page_vector(struct page **pages, int num_pages)
  237. {
  238. int i;
  239. for (i = 0; i < num_pages; i++)
  240. unlock_page(pages[i]);
  241. }
  242. /*
  243. * start an async read(ahead) operation. return nr_pages we submitted
  244. * a read for on success, or negative error code.
  245. */
  246. static int start_read(struct inode *inode, struct list_head *page_list, int max)
  247. {
  248. struct ceph_osd_client *osdc =
  249. &ceph_inode_to_client(inode)->client->osdc;
  250. struct ceph_inode_info *ci = ceph_inode(inode);
  251. struct page *page = list_entry(page_list->prev, struct page, lru);
  252. struct ceph_osd_request *req;
  253. u64 off;
  254. u64 len;
  255. int i;
  256. struct page **pages;
  257. pgoff_t next_index;
  258. int nr_pages = 0;
  259. int ret;
  260. off = (u64) page_offset(page);
  261. /* count pages */
  262. next_index = page->index;
  263. list_for_each_entry_reverse(page, page_list, lru) {
  264. if (page->index != next_index)
  265. break;
  266. nr_pages++;
  267. next_index++;
  268. if (max && nr_pages == max)
  269. break;
  270. }
  271. len = nr_pages << PAGE_CACHE_SHIFT;
  272. dout("start_read %p nr_pages %d is %lld~%lld\n", inode, nr_pages,
  273. off, len);
  274. req = ceph_osdc_new_request(osdc, &ci->i_layout, ceph_vino(inode),
  275. off, &len,
  276. CEPH_OSD_OP_READ, CEPH_OSD_FLAG_READ,
  277. NULL, 0,
  278. ci->i_truncate_seq, ci->i_truncate_size,
  279. NULL, false);
  280. if (IS_ERR(req))
  281. return PTR_ERR(req);
  282. /* build page vector */
  283. nr_pages = calc_pages_for(0, len);
  284. pages = kmalloc(sizeof(*pages) * nr_pages, GFP_NOFS);
  285. ret = -ENOMEM;
  286. if (!pages)
  287. goto out;
  288. for (i = 0; i < nr_pages; ++i) {
  289. page = list_entry(page_list->prev, struct page, lru);
  290. BUG_ON(PageLocked(page));
  291. list_del(&page->lru);
  292. dout("start_read %p adding %p idx %lu\n", inode, page,
  293. page->index);
  294. if (add_to_page_cache_lru(page, &inode->i_data, page->index,
  295. GFP_NOFS)) {
  296. page_cache_release(page);
  297. dout("start_read %p add_to_page_cache failed %p\n",
  298. inode, page);
  299. nr_pages = i;
  300. goto out_pages;
  301. }
  302. pages[i] = page;
  303. }
  304. req->r_data_in.type = CEPH_OSD_DATA_TYPE_PAGES;
  305. req->r_data_in.pages = pages;
  306. req->r_data_in.length = len;
  307. req->r_data_in.alignment = 0;
  308. req->r_callback = finish_read;
  309. req->r_inode = inode;
  310. dout("start_read %p starting %p %lld~%lld\n", inode, req, off, len);
  311. ret = ceph_osdc_start_request(osdc, req, false);
  312. if (ret < 0)
  313. goto out_pages;
  314. ceph_osdc_put_request(req);
  315. return nr_pages;
  316. out_pages:
  317. ceph_unlock_page_vector(pages, nr_pages);
  318. ceph_release_page_vector(pages, nr_pages);
  319. out:
  320. ceph_osdc_put_request(req);
  321. return ret;
  322. }
  323. /*
  324. * Read multiple pages. Leave pages we don't read + unlock in page_list;
  325. * the caller (VM) cleans them up.
  326. */
  327. static int ceph_readpages(struct file *file, struct address_space *mapping,
  328. struct list_head *page_list, unsigned nr_pages)
  329. {
  330. struct inode *inode = file_inode(file);
  331. struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
  332. int rc = 0;
  333. int max = 0;
  334. if (fsc->mount_options->rsize >= PAGE_CACHE_SIZE)
  335. max = (fsc->mount_options->rsize + PAGE_CACHE_SIZE - 1)
  336. >> PAGE_SHIFT;
  337. dout("readpages %p file %p nr_pages %d max %d\n", inode,
  338. file, nr_pages,
  339. max);
  340. while (!list_empty(page_list)) {
  341. rc = start_read(inode, page_list, max);
  342. if (rc < 0)
  343. goto out;
  344. BUG_ON(rc == 0);
  345. }
  346. out:
  347. dout("readpages %p file %p ret %d\n", inode, file, rc);
  348. return rc;
  349. }
  350. /*
  351. * Get ref for the oldest snapc for an inode with dirty data... that is, the
  352. * only snap context we are allowed to write back.
  353. */
  354. static struct ceph_snap_context *get_oldest_context(struct inode *inode,
  355. u64 *snap_size)
  356. {
  357. struct ceph_inode_info *ci = ceph_inode(inode);
  358. struct ceph_snap_context *snapc = NULL;
  359. struct ceph_cap_snap *capsnap = NULL;
  360. spin_lock(&ci->i_ceph_lock);
  361. list_for_each_entry(capsnap, &ci->i_cap_snaps, ci_item) {
  362. dout(" cap_snap %p snapc %p has %d dirty pages\n", capsnap,
  363. capsnap->context, capsnap->dirty_pages);
  364. if (capsnap->dirty_pages) {
  365. snapc = ceph_get_snap_context(capsnap->context);
  366. if (snap_size)
  367. *snap_size = capsnap->size;
  368. break;
  369. }
  370. }
  371. if (!snapc && ci->i_wrbuffer_ref_head) {
  372. snapc = ceph_get_snap_context(ci->i_head_snapc);
  373. dout(" head snapc %p has %d dirty pages\n",
  374. snapc, ci->i_wrbuffer_ref_head);
  375. }
  376. spin_unlock(&ci->i_ceph_lock);
  377. return snapc;
  378. }
  379. /*
  380. * Write a single page, but leave the page locked.
  381. *
  382. * If we get a write error, set the page error bit, but still adjust the
  383. * dirty page accounting (i.e., page is no longer dirty).
  384. */
  385. static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
  386. {
  387. struct inode *inode;
  388. struct ceph_inode_info *ci;
  389. struct ceph_fs_client *fsc;
  390. struct ceph_osd_client *osdc;
  391. loff_t page_off = page_offset(page);
  392. int len = PAGE_CACHE_SIZE;
  393. loff_t i_size;
  394. int err = 0;
  395. struct ceph_snap_context *snapc, *oldest;
  396. u64 snap_size = 0;
  397. long writeback_stat;
  398. dout("writepage %p idx %lu\n", page, page->index);
  399. if (!page->mapping || !page->mapping->host) {
  400. dout("writepage %p - no mapping\n", page);
  401. return -EFAULT;
  402. }
  403. inode = page->mapping->host;
  404. ci = ceph_inode(inode);
  405. fsc = ceph_inode_to_client(inode);
  406. osdc = &fsc->client->osdc;
  407. /* verify this is a writeable snap context */
  408. snapc = page_snap_context(page);
  409. if (snapc == NULL) {
  410. dout("writepage %p page %p not dirty?\n", inode, page);
  411. goto out;
  412. }
  413. oldest = get_oldest_context(inode, &snap_size);
  414. if (snapc->seq > oldest->seq) {
  415. dout("writepage %p page %p snapc %p not writeable - noop\n",
  416. inode, page, snapc);
  417. /* we should only noop if called by kswapd */
  418. WARN_ON((current->flags & PF_MEMALLOC) == 0);
  419. ceph_put_snap_context(oldest);
  420. goto out;
  421. }
  422. ceph_put_snap_context(oldest);
  423. /* is this a partial page at end of file? */
  424. if (snap_size)
  425. i_size = snap_size;
  426. else
  427. i_size = i_size_read(inode);
  428. if (i_size < page_off + len)
  429. len = i_size - page_off;
  430. dout("writepage %p page %p index %lu on %llu~%u snapc %p\n",
  431. inode, page, page->index, page_off, len, snapc);
  432. writeback_stat = atomic_long_inc_return(&fsc->writeback_count);
  433. if (writeback_stat >
  434. CONGESTION_ON_THRESH(fsc->mount_options->congestion_kb))
  435. set_bdi_congested(&fsc->backing_dev_info, BLK_RW_ASYNC);
  436. set_page_writeback(page);
  437. err = ceph_osdc_writepages(osdc, ceph_vino(inode),
  438. &ci->i_layout, snapc,
  439. page_off, len,
  440. ci->i_truncate_seq, ci->i_truncate_size,
  441. &inode->i_mtime, &page, 1);
  442. if (err < 0) {
  443. dout("writepage setting page/mapping error %d %p\n", err, page);
  444. SetPageError(page);
  445. mapping_set_error(&inode->i_data, err);
  446. if (wbc)
  447. wbc->pages_skipped++;
  448. } else {
  449. dout("writepage cleaned page %p\n", page);
  450. err = 0; /* vfs expects us to return 0 */
  451. }
  452. page->private = 0;
  453. ClearPagePrivate(page);
  454. end_page_writeback(page);
  455. ceph_put_wrbuffer_cap_refs(ci, 1, snapc);
  456. ceph_put_snap_context(snapc); /* page's reference */
  457. out:
  458. return err;
  459. }
  460. static int ceph_writepage(struct page *page, struct writeback_control *wbc)
  461. {
  462. int err;
  463. struct inode *inode = page->mapping->host;
  464. BUG_ON(!inode);
  465. ihold(inode);
  466. err = writepage_nounlock(page, wbc);
  467. unlock_page(page);
  468. iput(inode);
  469. return err;
  470. }
  471. /*
  472. * lame release_pages helper. release_pages() isn't exported to
  473. * modules.
  474. */
  475. static void ceph_release_pages(struct page **pages, int num)
  476. {
  477. struct pagevec pvec;
  478. int i;
  479. pagevec_init(&pvec, 0);
  480. for (i = 0; i < num; i++) {
  481. if (pagevec_add(&pvec, pages[i]) == 0)
  482. pagevec_release(&pvec);
  483. }
  484. pagevec_release(&pvec);
  485. }
  486. /*
  487. * async writeback completion handler.
  488. *
  489. * If we get an error, set the mapping error bit, but not the individual
  490. * page error bits.
  491. */
  492. static void writepages_finish(struct ceph_osd_request *req,
  493. struct ceph_msg *msg)
  494. {
  495. struct inode *inode = req->r_inode;
  496. struct ceph_inode_info *ci = ceph_inode(inode);
  497. unsigned wrote;
  498. struct page *page;
  499. int num_pages;
  500. int i;
  501. struct ceph_snap_context *snapc = req->r_snapc;
  502. struct address_space *mapping = inode->i_mapping;
  503. int rc = req->r_result;
  504. u64 bytes = le64_to_cpu(req->r_request_ops[0].extent.length);
  505. struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
  506. long writeback_stat;
  507. unsigned issued = ceph_caps_issued(ci);
  508. BUG_ON(req->r_data_out.type != CEPH_OSD_DATA_TYPE_PAGES);
  509. num_pages = calc_pages_for((u64)req->r_data_out.alignment,
  510. (u64)req->r_data_out.length);
  511. if (rc >= 0) {
  512. /*
  513. * Assume we wrote the pages we originally sent. The
  514. * osd might reply with fewer pages if our writeback
  515. * raced with a truncation and was adjusted at the osd,
  516. * so don't believe the reply.
  517. */
  518. wrote = num_pages;
  519. } else {
  520. wrote = 0;
  521. mapping_set_error(mapping, rc);
  522. }
  523. dout("writepages_finish %p rc %d bytes %llu wrote %d (pages)\n",
  524. inode, rc, bytes, wrote);
  525. /* clean all pages */
  526. for (i = 0; i < num_pages; i++) {
  527. page = req->r_data_out.pages[i];
  528. BUG_ON(!page);
  529. WARN_ON(!PageUptodate(page));
  530. writeback_stat =
  531. atomic_long_dec_return(&fsc->writeback_count);
  532. if (writeback_stat <
  533. CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
  534. clear_bdi_congested(&fsc->backing_dev_info,
  535. BLK_RW_ASYNC);
  536. ceph_put_snap_context(page_snap_context(page));
  537. page->private = 0;
  538. ClearPagePrivate(page);
  539. dout("unlocking %d %p\n", i, page);
  540. end_page_writeback(page);
  541. /*
  542. * We lost the cache cap, need to truncate the page before
  543. * it is unlocked, otherwise we'd truncate it later in the
  544. * page truncation thread, possibly losing some data that
  545. * raced its way in
  546. */
  547. if ((issued & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0)
  548. generic_error_remove_page(inode->i_mapping, page);
  549. unlock_page(page);
  550. }
  551. dout("%p wrote+cleaned %d pages\n", inode, wrote);
  552. ceph_put_wrbuffer_cap_refs(ci, num_pages, snapc);
  553. ceph_release_pages(req->r_data_out.pages, num_pages);
  554. if (req->r_data_out.pages_from_pool)
  555. mempool_free(req->r_data_out.pages,
  556. ceph_sb_to_client(inode->i_sb)->wb_pagevec_pool);
  557. else
  558. kfree(req->r_data_out.pages);
  559. ceph_osdc_put_request(req);
  560. }
  561. /*
  562. * allocate a page vec, either directly, or if necessary, via a the
  563. * mempool. we avoid the mempool if we can because req->r_data_out.length
  564. * may be less than the maximum write size.
  565. */
  566. static void alloc_page_vec(struct ceph_fs_client *fsc,
  567. struct ceph_osd_request *req)
  568. {
  569. size_t size;
  570. int num_pages;
  571. num_pages = calc_pages_for((u64)req->r_data_out.alignment,
  572. (u64)req->r_data_out.length);
  573. size = sizeof (struct page *) * num_pages;
  574. req->r_data_out.pages = kmalloc(size, GFP_NOFS);
  575. if (!req->r_data_out.pages) {
  576. req->r_data_out.pages = mempool_alloc(fsc->wb_pagevec_pool,
  577. GFP_NOFS);
  578. req->r_data_out.pages_from_pool = 1;
  579. WARN_ON(!req->r_data_out.pages);
  580. }
  581. }
  582. /*
  583. * initiate async writeback
  584. */
  585. static int ceph_writepages_start(struct address_space *mapping,
  586. struct writeback_control *wbc)
  587. {
  588. struct inode *inode = mapping->host;
  589. struct ceph_inode_info *ci = ceph_inode(inode);
  590. struct ceph_fs_client *fsc;
  591. pgoff_t index, start, end;
  592. int range_whole = 0;
  593. int should_loop = 1;
  594. pgoff_t max_pages = 0, max_pages_ever = 0;
  595. struct ceph_snap_context *snapc = NULL, *last_snapc = NULL, *pgsnapc;
  596. struct pagevec pvec;
  597. int done = 0;
  598. int rc = 0;
  599. unsigned wsize = 1 << inode->i_blkbits;
  600. struct ceph_osd_request *req = NULL;
  601. int do_sync;
  602. u64 snap_size = 0;
  603. /*
  604. * Include a 'sync' in the OSD request if this is a data
  605. * integrity write (e.g., O_SYNC write or fsync()), or if our
  606. * cap is being revoked.
  607. */
  608. do_sync = wbc->sync_mode == WB_SYNC_ALL;
  609. if (ceph_caps_revoking(ci, CEPH_CAP_FILE_BUFFER))
  610. do_sync = 1;
  611. dout("writepages_start %p dosync=%d (mode=%s)\n",
  612. inode, do_sync,
  613. wbc->sync_mode == WB_SYNC_NONE ? "NONE" :
  614. (wbc->sync_mode == WB_SYNC_ALL ? "ALL" : "HOLD"));
  615. fsc = ceph_inode_to_client(inode);
  616. if (fsc->mount_state == CEPH_MOUNT_SHUTDOWN) {
  617. pr_warning("writepage_start %p on forced umount\n", inode);
  618. return -EIO; /* we're in a forced umount, don't write! */
  619. }
  620. if (fsc->mount_options->wsize && fsc->mount_options->wsize < wsize)
  621. wsize = fsc->mount_options->wsize;
  622. if (wsize < PAGE_CACHE_SIZE)
  623. wsize = PAGE_CACHE_SIZE;
  624. max_pages_ever = wsize >> PAGE_CACHE_SHIFT;
  625. pagevec_init(&pvec, 0);
  626. /* where to start/end? */
  627. if (wbc->range_cyclic) {
  628. start = mapping->writeback_index; /* Start from prev offset */
  629. end = -1;
  630. dout(" cyclic, start at %lu\n", start);
  631. } else {
  632. start = wbc->range_start >> PAGE_CACHE_SHIFT;
  633. end = wbc->range_end >> PAGE_CACHE_SHIFT;
  634. if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
  635. range_whole = 1;
  636. should_loop = 0;
  637. dout(" not cyclic, %lu to %lu\n", start, end);
  638. }
  639. index = start;
  640. retry:
  641. /* find oldest snap context with dirty data */
  642. ceph_put_snap_context(snapc);
  643. snapc = get_oldest_context(inode, &snap_size);
  644. if (!snapc) {
  645. /* hmm, why does writepages get called when there
  646. is no dirty data? */
  647. dout(" no snap context with dirty data?\n");
  648. goto out;
  649. }
  650. dout(" oldest snapc is %p seq %lld (%d snaps)\n",
  651. snapc, snapc->seq, snapc->num_snaps);
  652. if (last_snapc && snapc != last_snapc) {
  653. /* if we switched to a newer snapc, restart our scan at the
  654. * start of the original file range. */
  655. dout(" snapc differs from last pass, restarting at %lu\n",
  656. index);
  657. index = start;
  658. }
  659. last_snapc = snapc;
  660. while (!done && index <= end) {
  661. unsigned i;
  662. int first;
  663. pgoff_t next;
  664. int pvec_pages, locked_pages;
  665. struct page *page;
  666. int want;
  667. u64 offset, len;
  668. long writeback_stat;
  669. next = 0;
  670. locked_pages = 0;
  671. max_pages = max_pages_ever;
  672. get_more_pages:
  673. first = -1;
  674. want = min(end - index,
  675. min((pgoff_t)PAGEVEC_SIZE,
  676. max_pages - (pgoff_t)locked_pages) - 1)
  677. + 1;
  678. pvec_pages = pagevec_lookup_tag(&pvec, mapping, &index,
  679. PAGECACHE_TAG_DIRTY,
  680. want);
  681. dout("pagevec_lookup_tag got %d\n", pvec_pages);
  682. if (!pvec_pages && !locked_pages)
  683. break;
  684. for (i = 0; i < pvec_pages && locked_pages < max_pages; i++) {
  685. page = pvec.pages[i];
  686. dout("? %p idx %lu\n", page, page->index);
  687. if (locked_pages == 0)
  688. lock_page(page); /* first page */
  689. else if (!trylock_page(page))
  690. break;
  691. /* only dirty pages, or our accounting breaks */
  692. if (unlikely(!PageDirty(page)) ||
  693. unlikely(page->mapping != mapping)) {
  694. dout("!dirty or !mapping %p\n", page);
  695. unlock_page(page);
  696. break;
  697. }
  698. if (!wbc->range_cyclic && page->index > end) {
  699. dout("end of range %p\n", page);
  700. done = 1;
  701. unlock_page(page);
  702. break;
  703. }
  704. if (next && (page->index != next)) {
  705. dout("not consecutive %p\n", page);
  706. unlock_page(page);
  707. break;
  708. }
  709. if (wbc->sync_mode != WB_SYNC_NONE) {
  710. dout("waiting on writeback %p\n", page);
  711. wait_on_page_writeback(page);
  712. }
  713. if ((snap_size && page_offset(page) > snap_size) ||
  714. (!snap_size &&
  715. page_offset(page) > i_size_read(inode))) {
  716. dout("%p page eof %llu\n", page, snap_size ?
  717. snap_size : i_size_read(inode));
  718. done = 1;
  719. unlock_page(page);
  720. break;
  721. }
  722. if (PageWriteback(page)) {
  723. dout("%p under writeback\n", page);
  724. unlock_page(page);
  725. break;
  726. }
  727. /* only if matching snap context */
  728. pgsnapc = page_snap_context(page);
  729. if (pgsnapc->seq > snapc->seq) {
  730. dout("page snapc %p %lld > oldest %p %lld\n",
  731. pgsnapc, pgsnapc->seq, snapc, snapc->seq);
  732. unlock_page(page);
  733. if (!locked_pages)
  734. continue; /* keep looking for snap */
  735. break;
  736. }
  737. if (!clear_page_dirty_for_io(page)) {
  738. dout("%p !clear_page_dirty_for_io\n", page);
  739. unlock_page(page);
  740. break;
  741. }
  742. /* ok */
  743. if (locked_pages == 0) {
  744. /* prepare async write request */
  745. offset = (u64) page_offset(page);
  746. len = wsize;
  747. req = ceph_osdc_new_request(&fsc->client->osdc,
  748. &ci->i_layout,
  749. ceph_vino(inode),
  750. offset, &len,
  751. CEPH_OSD_OP_WRITE,
  752. CEPH_OSD_FLAG_WRITE |
  753. CEPH_OSD_FLAG_ONDISK,
  754. snapc, do_sync,
  755. ci->i_truncate_seq,
  756. ci->i_truncate_size,
  757. &inode->i_mtime, true);
  758. if (IS_ERR(req)) {
  759. rc = PTR_ERR(req);
  760. unlock_page(page);
  761. break;
  762. }
  763. req->r_data_out.type = CEPH_OSD_DATA_TYPE_PAGES;
  764. req->r_data_out.length = len;
  765. req->r_data_out.alignment = 0;
  766. max_pages = calc_pages_for(0, (u64)len);
  767. alloc_page_vec(fsc, req);
  768. req->r_callback = writepages_finish;
  769. req->r_inode = inode;
  770. }
  771. /* note position of first page in pvec */
  772. if (first < 0)
  773. first = i;
  774. dout("%p will write page %p idx %lu\n",
  775. inode, page, page->index);
  776. writeback_stat =
  777. atomic_long_inc_return(&fsc->writeback_count);
  778. if (writeback_stat > CONGESTION_ON_THRESH(
  779. fsc->mount_options->congestion_kb)) {
  780. set_bdi_congested(&fsc->backing_dev_info,
  781. BLK_RW_ASYNC);
  782. }
  783. set_page_writeback(page);
  784. req->r_data_out.pages[locked_pages] = page;
  785. locked_pages++;
  786. next = page->index + 1;
  787. }
  788. /* did we get anything? */
  789. if (!locked_pages)
  790. goto release_pvec_pages;
  791. if (i) {
  792. int j;
  793. BUG_ON(!locked_pages || first < 0);
  794. if (pvec_pages && i == pvec_pages &&
  795. locked_pages < max_pages) {
  796. dout("reached end pvec, trying for more\n");
  797. pagevec_reinit(&pvec);
  798. goto get_more_pages;
  799. }
  800. /* shift unused pages over in the pvec... we
  801. * will need to release them below. */
  802. for (j = i; j < pvec_pages; j++) {
  803. dout(" pvec leftover page %p\n",
  804. pvec.pages[j]);
  805. pvec.pages[j-i+first] = pvec.pages[j];
  806. }
  807. pvec.nr -= i-first;
  808. }
  809. /* submit the write */
  810. offset = req->r_data_out.pages[0]->index << PAGE_CACHE_SHIFT;
  811. len = min((snap_size ? snap_size : i_size_read(inode)) - offset,
  812. (u64)locked_pages << PAGE_CACHE_SHIFT);
  813. dout("writepages got %d pages at %llu~%llu\n",
  814. locked_pages, offset, len);
  815. /* revise final length, page count */
  816. req->r_data_out.length = len;
  817. req->r_request_ops[0].extent.length = cpu_to_le64(len);
  818. req->r_request_ops[0].payload_len = cpu_to_le32(len);
  819. req->r_request->hdr.data_len = cpu_to_le32(len);
  820. rc = ceph_osdc_start_request(&fsc->client->osdc, req, true);
  821. BUG_ON(rc);
  822. req = NULL;
  823. /* continue? */
  824. index = next;
  825. wbc->nr_to_write -= locked_pages;
  826. if (wbc->nr_to_write <= 0)
  827. done = 1;
  828. release_pvec_pages:
  829. dout("pagevec_release on %d pages (%p)\n", (int)pvec.nr,
  830. pvec.nr ? pvec.pages[0] : NULL);
  831. pagevec_release(&pvec);
  832. if (locked_pages && !done)
  833. goto retry;
  834. }
  835. if (should_loop && !done) {
  836. /* more to do; loop back to beginning of file */
  837. dout("writepages looping back to beginning of file\n");
  838. should_loop = 0;
  839. index = 0;
  840. goto retry;
  841. }
  842. if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
  843. mapping->writeback_index = index;
  844. out:
  845. if (req)
  846. ceph_osdc_put_request(req);
  847. ceph_put_snap_context(snapc);
  848. dout("writepages done, rc = %d\n", rc);
  849. return rc;
  850. }
  851. /*
  852. * See if a given @snapc is either writeable, or already written.
  853. */
  854. static int context_is_writeable_or_written(struct inode *inode,
  855. struct ceph_snap_context *snapc)
  856. {
  857. struct ceph_snap_context *oldest = get_oldest_context(inode, NULL);
  858. int ret = !oldest || snapc->seq <= oldest->seq;
  859. ceph_put_snap_context(oldest);
  860. return ret;
  861. }
  862. /*
  863. * We are only allowed to write into/dirty the page if the page is
  864. * clean, or already dirty within the same snap context.
  865. *
  866. * called with page locked.
  867. * return success with page locked,
  868. * or any failure (incl -EAGAIN) with page unlocked.
  869. */
  870. static int ceph_update_writeable_page(struct file *file,
  871. loff_t pos, unsigned len,
  872. struct page *page)
  873. {
  874. struct inode *inode = file_inode(file);
  875. struct ceph_inode_info *ci = ceph_inode(inode);
  876. struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
  877. loff_t page_off = pos & PAGE_CACHE_MASK;
  878. int pos_in_page = pos & ~PAGE_CACHE_MASK;
  879. int end_in_page = pos_in_page + len;
  880. loff_t i_size;
  881. int r;
  882. struct ceph_snap_context *snapc, *oldest;
  883. retry_locked:
  884. /* writepages currently holds page lock, but if we change that later, */
  885. wait_on_page_writeback(page);
  886. /* check snap context */
  887. BUG_ON(!ci->i_snap_realm);
  888. down_read(&mdsc->snap_rwsem);
  889. BUG_ON(!ci->i_snap_realm->cached_context);
  890. snapc = page_snap_context(page);
  891. if (snapc && snapc != ci->i_head_snapc) {
  892. /*
  893. * this page is already dirty in another (older) snap
  894. * context! is it writeable now?
  895. */
  896. oldest = get_oldest_context(inode, NULL);
  897. up_read(&mdsc->snap_rwsem);
  898. if (snapc->seq > oldest->seq) {
  899. ceph_put_snap_context(oldest);
  900. dout(" page %p snapc %p not current or oldest\n",
  901. page, snapc);
  902. /*
  903. * queue for writeback, and wait for snapc to
  904. * be writeable or written
  905. */
  906. snapc = ceph_get_snap_context(snapc);
  907. unlock_page(page);
  908. ceph_queue_writeback(inode);
  909. r = wait_event_interruptible(ci->i_cap_wq,
  910. context_is_writeable_or_written(inode, snapc));
  911. ceph_put_snap_context(snapc);
  912. if (r == -ERESTARTSYS)
  913. return r;
  914. return -EAGAIN;
  915. }
  916. ceph_put_snap_context(oldest);
  917. /* yay, writeable, do it now (without dropping page lock) */
  918. dout(" page %p snapc %p not current, but oldest\n",
  919. page, snapc);
  920. if (!clear_page_dirty_for_io(page))
  921. goto retry_locked;
  922. r = writepage_nounlock(page, NULL);
  923. if (r < 0)
  924. goto fail_nosnap;
  925. goto retry_locked;
  926. }
  927. if (PageUptodate(page)) {
  928. dout(" page %p already uptodate\n", page);
  929. return 0;
  930. }
  931. /* full page? */
  932. if (pos_in_page == 0 && len == PAGE_CACHE_SIZE)
  933. return 0;
  934. /* past end of file? */
  935. i_size = inode->i_size; /* caller holds i_mutex */
  936. if (i_size + len > inode->i_sb->s_maxbytes) {
  937. /* file is too big */
  938. r = -EINVAL;
  939. goto fail;
  940. }
  941. if (page_off >= i_size ||
  942. (pos_in_page == 0 && (pos+len) >= i_size &&
  943. end_in_page - pos_in_page != PAGE_CACHE_SIZE)) {
  944. dout(" zeroing %p 0 - %d and %d - %d\n",
  945. page, pos_in_page, end_in_page, (int)PAGE_CACHE_SIZE);
  946. zero_user_segments(page,
  947. 0, pos_in_page,
  948. end_in_page, PAGE_CACHE_SIZE);
  949. return 0;
  950. }
  951. /* we need to read it. */
  952. up_read(&mdsc->snap_rwsem);
  953. r = readpage_nounlock(file, page);
  954. if (r < 0)
  955. goto fail_nosnap;
  956. goto retry_locked;
  957. fail:
  958. up_read(&mdsc->snap_rwsem);
  959. fail_nosnap:
  960. unlock_page(page);
  961. return r;
  962. }
  963. /*
  964. * We are only allowed to write into/dirty the page if the page is
  965. * clean, or already dirty within the same snap context.
  966. */
  967. static int ceph_write_begin(struct file *file, struct address_space *mapping,
  968. loff_t pos, unsigned len, unsigned flags,
  969. struct page **pagep, void **fsdata)
  970. {
  971. struct inode *inode = file_inode(file);
  972. struct page *page;
  973. pgoff_t index = pos >> PAGE_CACHE_SHIFT;
  974. int r;
  975. do {
  976. /* get a page */
  977. page = grab_cache_page_write_begin(mapping, index, 0);
  978. if (!page)
  979. return -ENOMEM;
  980. *pagep = page;
  981. dout("write_begin file %p inode %p page %p %d~%d\n", file,
  982. inode, page, (int)pos, (int)len);
  983. r = ceph_update_writeable_page(file, pos, len, page);
  984. } while (r == -EAGAIN);
  985. return r;
  986. }
  987. /*
  988. * we don't do anything in here that simple_write_end doesn't do
  989. * except adjust dirty page accounting and drop read lock on
  990. * mdsc->snap_rwsem.
  991. */
  992. static int ceph_write_end(struct file *file, struct address_space *mapping,
  993. loff_t pos, unsigned len, unsigned copied,
  994. struct page *page, void *fsdata)
  995. {
  996. struct inode *inode = file_inode(file);
  997. struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
  998. struct ceph_mds_client *mdsc = fsc->mdsc;
  999. unsigned from = pos & (PAGE_CACHE_SIZE - 1);
  1000. int check_cap = 0;
  1001. dout("write_end file %p inode %p page %p %d~%d (%d)\n", file,
  1002. inode, page, (int)pos, (int)copied, (int)len);
  1003. /* zero the stale part of the page if we did a short copy */
  1004. if (copied < len)
  1005. zero_user_segment(page, from+copied, len);
  1006. /* did file size increase? */
  1007. /* (no need for i_size_read(); we caller holds i_mutex */
  1008. if (pos+copied > inode->i_size)
  1009. check_cap = ceph_inode_set_size(inode, pos+copied);
  1010. if (!PageUptodate(page))
  1011. SetPageUptodate(page);
  1012. set_page_dirty(page);
  1013. unlock_page(page);
  1014. up_read(&mdsc->snap_rwsem);
  1015. page_cache_release(page);
  1016. if (check_cap)
  1017. ceph_check_caps(ceph_inode(inode), CHECK_CAPS_AUTHONLY, NULL);
  1018. return copied;
  1019. }
  1020. /*
  1021. * we set .direct_IO to indicate direct io is supported, but since we
  1022. * intercept O_DIRECT reads and writes early, this function should
  1023. * never get called.
  1024. */
  1025. static ssize_t ceph_direct_io(int rw, struct kiocb *iocb,
  1026. const struct iovec *iov,
  1027. loff_t pos, unsigned long nr_segs)
  1028. {
  1029. WARN_ON(1);
  1030. return -EINVAL;
  1031. }
  1032. const struct address_space_operations ceph_aops = {
  1033. .readpage = ceph_readpage,
  1034. .readpages = ceph_readpages,
  1035. .writepage = ceph_writepage,
  1036. .writepages = ceph_writepages_start,
  1037. .write_begin = ceph_write_begin,
  1038. .write_end = ceph_write_end,
  1039. .set_page_dirty = ceph_set_page_dirty,
  1040. .invalidatepage = ceph_invalidatepage,
  1041. .releasepage = ceph_releasepage,
  1042. .direct_IO = ceph_direct_io,
  1043. };
  1044. /*
  1045. * vm ops
  1046. */
  1047. /*
  1048. * Reuse write_begin here for simplicity.
  1049. */
  1050. static int ceph_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
  1051. {
  1052. struct inode *inode = file_inode(vma->vm_file);
  1053. struct page *page = vmf->page;
  1054. struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
  1055. loff_t off = page_offset(page);
  1056. loff_t size, len;
  1057. int ret;
  1058. /* Update time before taking page lock */
  1059. file_update_time(vma->vm_file);
  1060. size = i_size_read(inode);
  1061. if (off + PAGE_CACHE_SIZE <= size)
  1062. len = PAGE_CACHE_SIZE;
  1063. else
  1064. len = size & ~PAGE_CACHE_MASK;
  1065. dout("page_mkwrite %p %llu~%llu page %p idx %lu\n", inode,
  1066. off, len, page, page->index);
  1067. lock_page(page);
  1068. ret = VM_FAULT_NOPAGE;
  1069. if ((off > size) ||
  1070. (page->mapping != inode->i_mapping))
  1071. goto out;
  1072. ret = ceph_update_writeable_page(vma->vm_file, off, len, page);
  1073. if (ret == 0) {
  1074. /* success. we'll keep the page locked. */
  1075. set_page_dirty(page);
  1076. up_read(&mdsc->snap_rwsem);
  1077. ret = VM_FAULT_LOCKED;
  1078. } else {
  1079. if (ret == -ENOMEM)
  1080. ret = VM_FAULT_OOM;
  1081. else
  1082. ret = VM_FAULT_SIGBUS;
  1083. }
  1084. out:
  1085. dout("page_mkwrite %p %llu~%llu = %d\n", inode, off, len, ret);
  1086. if (ret != VM_FAULT_LOCKED)
  1087. unlock_page(page);
  1088. return ret;
  1089. }
  1090. static struct vm_operations_struct ceph_vmops = {
  1091. .fault = filemap_fault,
  1092. .page_mkwrite = ceph_page_mkwrite,
  1093. .remap_pages = generic_file_remap_pages,
  1094. };
  1095. int ceph_mmap(struct file *file, struct vm_area_struct *vma)
  1096. {
  1097. struct address_space *mapping = file->f_mapping;
  1098. if (!mapping->a_ops->readpage)
  1099. return -ENOEXEC;
  1100. file_accessed(file);
  1101. vma->vm_ops = &ceph_vmops;
  1102. return 0;
  1103. }