inline.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /*
  2. * fs/f2fs/inline.c
  3. * Copyright (c) 2013, Intel Corporation
  4. * Authors: Huajun Li <huajun.li@intel.com>
  5. * Haicheng Li <haicheng.li@intel.com>
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/fs.h>
  11. #include <linux/f2fs_fs.h>
  12. #include "f2fs.h"
  13. #include "node.h"
  14. bool f2fs_may_inline_data(struct inode *inode)
  15. {
  16. if (f2fs_is_atomic_file(inode))
  17. return false;
  18. if (!S_ISREG(inode->i_mode) && !S_ISLNK(inode->i_mode))
  19. return false;
  20. if (i_size_read(inode) > MAX_INLINE_DATA)
  21. return false;
  22. if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
  23. return false;
  24. return true;
  25. }
  26. bool f2fs_may_inline_dentry(struct inode *inode)
  27. {
  28. if (!test_opt(F2FS_I_SB(inode), INLINE_DENTRY))
  29. return false;
  30. if (!S_ISDIR(inode->i_mode))
  31. return false;
  32. return true;
  33. }
  34. void read_inline_data(struct page *page, struct page *ipage)
  35. {
  36. void *src_addr, *dst_addr;
  37. if (PageUptodate(page))
  38. return;
  39. f2fs_bug_on(F2FS_P_SB(page), page->index);
  40. zero_user_segment(page, MAX_INLINE_DATA, PAGE_SIZE);
  41. /* Copy the whole inline data block */
  42. src_addr = inline_data_addr(ipage);
  43. dst_addr = kmap_atomic(page);
  44. memcpy(dst_addr, src_addr, MAX_INLINE_DATA);
  45. flush_dcache_page(page);
  46. kunmap_atomic(dst_addr);
  47. if (!PageUptodate(page))
  48. SetPageUptodate(page);
  49. }
  50. bool truncate_inline_inode(struct page *ipage, u64 from)
  51. {
  52. void *addr;
  53. if (from >= MAX_INLINE_DATA)
  54. return false;
  55. addr = inline_data_addr(ipage);
  56. f2fs_wait_on_page_writeback(ipage, NODE, true);
  57. memset(addr + from, 0, MAX_INLINE_DATA - from);
  58. set_page_dirty(ipage);
  59. return true;
  60. }
  61. int f2fs_read_inline_data(struct inode *inode, struct page *page)
  62. {
  63. struct page *ipage;
  64. ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
  65. if (IS_ERR(ipage)) {
  66. unlock_page(page);
  67. return PTR_ERR(ipage);
  68. }
  69. if (!f2fs_has_inline_data(inode)) {
  70. f2fs_put_page(ipage, 1);
  71. return -EAGAIN;
  72. }
  73. if (page->index)
  74. zero_user_segment(page, 0, PAGE_SIZE);
  75. else
  76. read_inline_data(page, ipage);
  77. if (!PageUptodate(page))
  78. SetPageUptodate(page);
  79. f2fs_put_page(ipage, 1);
  80. unlock_page(page);
  81. return 0;
  82. }
  83. int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
  84. {
  85. struct f2fs_io_info fio = {
  86. .sbi = F2FS_I_SB(dn->inode),
  87. .type = DATA,
  88. .op = REQ_OP_WRITE,
  89. .op_flags = WRITE_SYNC | REQ_PRIO,
  90. .page = page,
  91. .encrypted_page = NULL,
  92. };
  93. int dirty, err;
  94. if (!f2fs_exist_data(dn->inode))
  95. goto clear_out;
  96. err = f2fs_reserve_block(dn, 0);
  97. if (err)
  98. return err;
  99. f2fs_bug_on(F2FS_P_SB(page), PageWriteback(page));
  100. read_inline_data(page, dn->inode_page);
  101. set_page_dirty(page);
  102. /* clear dirty state */
  103. dirty = clear_page_dirty_for_io(page);
  104. /* write data page to try to make data consistent */
  105. set_page_writeback(page);
  106. fio.old_blkaddr = dn->data_blkaddr;
  107. write_data_page(dn, &fio);
  108. f2fs_wait_on_page_writeback(page, DATA, true);
  109. if (dirty)
  110. inode_dec_dirty_pages(dn->inode);
  111. /* this converted inline_data should be recovered. */
  112. set_inode_flag(dn->inode, FI_APPEND_WRITE);
  113. /* clear inline data and flag after data writeback */
  114. truncate_inline_inode(dn->inode_page, 0);
  115. clear_inline_node(dn->inode_page);
  116. clear_out:
  117. stat_dec_inline_inode(dn->inode);
  118. f2fs_clear_inline_inode(dn->inode);
  119. f2fs_put_dnode(dn);
  120. return 0;
  121. }
  122. int f2fs_convert_inline_inode(struct inode *inode)
  123. {
  124. struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
  125. struct dnode_of_data dn;
  126. struct page *ipage, *page;
  127. int err = 0;
  128. if (!f2fs_has_inline_data(inode))
  129. return 0;
  130. page = f2fs_grab_cache_page(inode->i_mapping, 0, false);
  131. if (!page)
  132. return -ENOMEM;
  133. f2fs_lock_op(sbi);
  134. ipage = get_node_page(sbi, inode->i_ino);
  135. if (IS_ERR(ipage)) {
  136. err = PTR_ERR(ipage);
  137. goto out;
  138. }
  139. set_new_dnode(&dn, inode, ipage, ipage, 0);
  140. if (f2fs_has_inline_data(inode))
  141. err = f2fs_convert_inline_page(&dn, page);
  142. f2fs_put_dnode(&dn);
  143. out:
  144. f2fs_unlock_op(sbi);
  145. f2fs_put_page(page, 1);
  146. f2fs_balance_fs(sbi, dn.node_changed);
  147. return err;
  148. }
  149. int f2fs_write_inline_data(struct inode *inode, struct page *page)
  150. {
  151. void *src_addr, *dst_addr;
  152. struct dnode_of_data dn;
  153. int err;
  154. set_new_dnode(&dn, inode, NULL, NULL, 0);
  155. err = get_dnode_of_data(&dn, 0, LOOKUP_NODE);
  156. if (err)
  157. return err;
  158. if (!f2fs_has_inline_data(inode)) {
  159. f2fs_put_dnode(&dn);
  160. return -EAGAIN;
  161. }
  162. f2fs_bug_on(F2FS_I_SB(inode), page->index);
  163. f2fs_wait_on_page_writeback(dn.inode_page, NODE, true);
  164. src_addr = kmap_atomic(page);
  165. dst_addr = inline_data_addr(dn.inode_page);
  166. memcpy(dst_addr, src_addr, MAX_INLINE_DATA);
  167. kunmap_atomic(src_addr);
  168. set_page_dirty(dn.inode_page);
  169. set_inode_flag(inode, FI_APPEND_WRITE);
  170. set_inode_flag(inode, FI_DATA_EXIST);
  171. clear_inline_node(dn.inode_page);
  172. f2fs_put_dnode(&dn);
  173. return 0;
  174. }
  175. bool recover_inline_data(struct inode *inode, struct page *npage)
  176. {
  177. struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
  178. struct f2fs_inode *ri = NULL;
  179. void *src_addr, *dst_addr;
  180. struct page *ipage;
  181. /*
  182. * The inline_data recovery policy is as follows.
  183. * [prev.] [next] of inline_data flag
  184. * o o -> recover inline_data
  185. * o x -> remove inline_data, and then recover data blocks
  186. * x o -> remove inline_data, and then recover inline_data
  187. * x x -> recover data blocks
  188. */
  189. if (IS_INODE(npage))
  190. ri = F2FS_INODE(npage);
  191. if (f2fs_has_inline_data(inode) &&
  192. ri && (ri->i_inline & F2FS_INLINE_DATA)) {
  193. process_inline:
  194. ipage = get_node_page(sbi, inode->i_ino);
  195. f2fs_bug_on(sbi, IS_ERR(ipage));
  196. f2fs_wait_on_page_writeback(ipage, NODE, true);
  197. src_addr = inline_data_addr(npage);
  198. dst_addr = inline_data_addr(ipage);
  199. memcpy(dst_addr, src_addr, MAX_INLINE_DATA);
  200. set_inode_flag(inode, FI_INLINE_DATA);
  201. set_inode_flag(inode, FI_DATA_EXIST);
  202. set_page_dirty(ipage);
  203. f2fs_put_page(ipage, 1);
  204. return true;
  205. }
  206. if (f2fs_has_inline_data(inode)) {
  207. ipage = get_node_page(sbi, inode->i_ino);
  208. f2fs_bug_on(sbi, IS_ERR(ipage));
  209. if (!truncate_inline_inode(ipage, 0))
  210. return false;
  211. f2fs_clear_inline_inode(inode);
  212. f2fs_put_page(ipage, 1);
  213. } else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) {
  214. if (truncate_blocks(inode, 0, false))
  215. return false;
  216. goto process_inline;
  217. }
  218. return false;
  219. }
  220. struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
  221. struct fscrypt_name *fname, struct page **res_page)
  222. {
  223. struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
  224. struct f2fs_inline_dentry *inline_dentry;
  225. struct qstr name = FSTR_TO_QSTR(&fname->disk_name);
  226. struct f2fs_dir_entry *de;
  227. struct f2fs_dentry_ptr d;
  228. struct page *ipage;
  229. f2fs_hash_t namehash;
  230. ipage = get_node_page(sbi, dir->i_ino);
  231. if (IS_ERR(ipage)) {
  232. *res_page = ipage;
  233. return NULL;
  234. }
  235. namehash = f2fs_dentry_hash(&name, fname);
  236. inline_dentry = inline_data_addr(ipage);
  237. make_dentry_ptr(NULL, &d, (void *)inline_dentry, 2);
  238. de = find_target_dentry(fname, namehash, NULL, &d);
  239. unlock_page(ipage);
  240. if (de)
  241. *res_page = ipage;
  242. else
  243. f2fs_put_page(ipage, 0);
  244. return de;
  245. }
  246. int make_empty_inline_dir(struct inode *inode, struct inode *parent,
  247. struct page *ipage)
  248. {
  249. struct f2fs_inline_dentry *dentry_blk;
  250. struct f2fs_dentry_ptr d;
  251. dentry_blk = inline_data_addr(ipage);
  252. make_dentry_ptr(NULL, &d, (void *)dentry_blk, 2);
  253. do_make_empty_dir(inode, parent, &d);
  254. set_page_dirty(ipage);
  255. /* update i_size to MAX_INLINE_DATA */
  256. if (i_size_read(inode) < MAX_INLINE_DATA)
  257. f2fs_i_size_write(inode, MAX_INLINE_DATA);
  258. return 0;
  259. }
  260. /*
  261. * NOTE: ipage is grabbed by caller, but if any error occurs, we should
  262. * release ipage in this function.
  263. */
  264. static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
  265. struct f2fs_inline_dentry *inline_dentry)
  266. {
  267. struct page *page;
  268. struct dnode_of_data dn;
  269. struct f2fs_dentry_block *dentry_blk;
  270. int err;
  271. page = f2fs_grab_cache_page(dir->i_mapping, 0, false);
  272. if (!page) {
  273. f2fs_put_page(ipage, 1);
  274. return -ENOMEM;
  275. }
  276. set_new_dnode(&dn, dir, ipage, NULL, 0);
  277. err = f2fs_reserve_block(&dn, 0);
  278. if (err)
  279. goto out;
  280. f2fs_wait_on_page_writeback(page, DATA, true);
  281. zero_user_segment(page, MAX_INLINE_DATA, PAGE_SIZE);
  282. dentry_blk = kmap_atomic(page);
  283. /* copy data from inline dentry block to new dentry block */
  284. memcpy(dentry_blk->dentry_bitmap, inline_dentry->dentry_bitmap,
  285. INLINE_DENTRY_BITMAP_SIZE);
  286. memset(dentry_blk->dentry_bitmap + INLINE_DENTRY_BITMAP_SIZE, 0,
  287. SIZE_OF_DENTRY_BITMAP - INLINE_DENTRY_BITMAP_SIZE);
  288. /*
  289. * we do not need to zero out remainder part of dentry and filename
  290. * field, since we have used bitmap for marking the usage status of
  291. * them, besides, we can also ignore copying/zeroing reserved space
  292. * of dentry block, because them haven't been used so far.
  293. */
  294. memcpy(dentry_blk->dentry, inline_dentry->dentry,
  295. sizeof(struct f2fs_dir_entry) * NR_INLINE_DENTRY);
  296. memcpy(dentry_blk->filename, inline_dentry->filename,
  297. NR_INLINE_DENTRY * F2FS_SLOT_LEN);
  298. kunmap_atomic(dentry_blk);
  299. if (!PageUptodate(page))
  300. SetPageUptodate(page);
  301. set_page_dirty(page);
  302. /* clear inline dir and flag after data writeback */
  303. truncate_inline_inode(ipage, 0);
  304. stat_dec_inline_dir(dir);
  305. clear_inode_flag(dir, FI_INLINE_DENTRY);
  306. f2fs_i_depth_write(dir, 1);
  307. if (i_size_read(dir) < PAGE_SIZE)
  308. f2fs_i_size_write(dir, PAGE_SIZE);
  309. out:
  310. f2fs_put_page(page, 1);
  311. return err;
  312. }
  313. static int f2fs_add_inline_entries(struct inode *dir,
  314. struct f2fs_inline_dentry *inline_dentry)
  315. {
  316. struct f2fs_dentry_ptr d;
  317. unsigned long bit_pos = 0;
  318. int err = 0;
  319. make_dentry_ptr(NULL, &d, (void *)inline_dentry, 2);
  320. while (bit_pos < d.max) {
  321. struct f2fs_dir_entry *de;
  322. struct qstr new_name;
  323. nid_t ino;
  324. umode_t fake_mode;
  325. if (!test_bit_le(bit_pos, d.bitmap)) {
  326. bit_pos++;
  327. continue;
  328. }
  329. de = &d.dentry[bit_pos];
  330. if (unlikely(!de->name_len)) {
  331. bit_pos++;
  332. continue;
  333. }
  334. new_name.name = d.filename[bit_pos];
  335. new_name.len = de->name_len;
  336. ino = le32_to_cpu(de->ino);
  337. fake_mode = get_de_type(de) << S_SHIFT;
  338. err = f2fs_add_regular_entry(dir, &new_name, NULL, NULL,
  339. ino, fake_mode);
  340. if (err)
  341. goto punch_dentry_pages;
  342. bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
  343. }
  344. return 0;
  345. punch_dentry_pages:
  346. truncate_inode_pages(&dir->i_data, 0);
  347. truncate_blocks(dir, 0, false);
  348. remove_dirty_inode(dir);
  349. return err;
  350. }
  351. static int f2fs_move_rehashed_dirents(struct inode *dir, struct page *ipage,
  352. struct f2fs_inline_dentry *inline_dentry)
  353. {
  354. struct f2fs_inline_dentry *backup_dentry;
  355. int err;
  356. backup_dentry = f2fs_kmalloc(F2FS_I_SB(dir),
  357. sizeof(struct f2fs_inline_dentry), GFP_F2FS_ZERO);
  358. if (!backup_dentry) {
  359. f2fs_put_page(ipage, 1);
  360. return -ENOMEM;
  361. }
  362. memcpy(backup_dentry, inline_dentry, MAX_INLINE_DATA);
  363. truncate_inline_inode(ipage, 0);
  364. unlock_page(ipage);
  365. err = f2fs_add_inline_entries(dir, backup_dentry);
  366. if (err)
  367. goto recover;
  368. lock_page(ipage);
  369. stat_dec_inline_dir(dir);
  370. clear_inode_flag(dir, FI_INLINE_DENTRY);
  371. kfree(backup_dentry);
  372. return 0;
  373. recover:
  374. lock_page(ipage);
  375. memcpy(inline_dentry, backup_dentry, MAX_INLINE_DATA);
  376. f2fs_i_depth_write(dir, 0);
  377. f2fs_i_size_write(dir, MAX_INLINE_DATA);
  378. set_page_dirty(ipage);
  379. f2fs_put_page(ipage, 1);
  380. kfree(backup_dentry);
  381. return err;
  382. }
  383. static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
  384. struct f2fs_inline_dentry *inline_dentry)
  385. {
  386. if (!F2FS_I(dir)->i_dir_level)
  387. return f2fs_move_inline_dirents(dir, ipage, inline_dentry);
  388. else
  389. return f2fs_move_rehashed_dirents(dir, ipage, inline_dentry);
  390. }
  391. int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
  392. const struct qstr *orig_name,
  393. struct inode *inode, nid_t ino, umode_t mode)
  394. {
  395. struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
  396. struct page *ipage;
  397. unsigned int bit_pos;
  398. f2fs_hash_t name_hash;
  399. struct f2fs_inline_dentry *dentry_blk = NULL;
  400. struct f2fs_dentry_ptr d;
  401. int slots = GET_DENTRY_SLOTS(new_name->len);
  402. struct page *page = NULL;
  403. int err = 0;
  404. ipage = get_node_page(sbi, dir->i_ino);
  405. if (IS_ERR(ipage))
  406. return PTR_ERR(ipage);
  407. dentry_blk = inline_data_addr(ipage);
  408. bit_pos = room_for_filename(&dentry_blk->dentry_bitmap,
  409. slots, NR_INLINE_DENTRY);
  410. if (bit_pos >= NR_INLINE_DENTRY) {
  411. err = f2fs_convert_inline_dir(dir, ipage, dentry_blk);
  412. if (err)
  413. return err;
  414. err = -EAGAIN;
  415. goto out;
  416. }
  417. if (inode) {
  418. down_write(&F2FS_I(inode)->i_sem);
  419. page = init_inode_metadata(inode, dir, new_name,
  420. orig_name, ipage);
  421. if (IS_ERR(page)) {
  422. err = PTR_ERR(page);
  423. goto fail;
  424. }
  425. if (f2fs_encrypted_inode(dir))
  426. file_set_enc_name(inode);
  427. }
  428. f2fs_wait_on_page_writeback(ipage, NODE, true);
  429. name_hash = f2fs_dentry_hash(new_name, NULL);
  430. make_dentry_ptr(NULL, &d, (void *)dentry_blk, 2);
  431. f2fs_update_dentry(ino, mode, &d, new_name, name_hash, bit_pos);
  432. set_page_dirty(ipage);
  433. /* we don't need to mark_inode_dirty now */
  434. if (inode) {
  435. f2fs_i_pino_write(inode, dir->i_ino);
  436. f2fs_put_page(page, 1);
  437. }
  438. update_parent_metadata(dir, inode, 0);
  439. fail:
  440. if (inode)
  441. up_write(&F2FS_I(inode)->i_sem);
  442. out:
  443. f2fs_put_page(ipage, 1);
  444. return err;
  445. }
  446. void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
  447. struct inode *dir, struct inode *inode)
  448. {
  449. struct f2fs_inline_dentry *inline_dentry;
  450. int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
  451. unsigned int bit_pos;
  452. int i;
  453. lock_page(page);
  454. f2fs_wait_on_page_writeback(page, NODE, true);
  455. inline_dentry = inline_data_addr(page);
  456. bit_pos = dentry - inline_dentry->dentry;
  457. for (i = 0; i < slots; i++)
  458. __clear_bit_le(bit_pos + i,
  459. &inline_dentry->dentry_bitmap);
  460. set_page_dirty(page);
  461. f2fs_put_page(page, 1);
  462. dir->i_ctime = dir->i_mtime = current_time(dir);
  463. f2fs_mark_inode_dirty_sync(dir);
  464. if (inode)
  465. f2fs_drop_nlink(dir, inode);
  466. }
  467. bool f2fs_empty_inline_dir(struct inode *dir)
  468. {
  469. struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
  470. struct page *ipage;
  471. unsigned int bit_pos = 2;
  472. struct f2fs_inline_dentry *dentry_blk;
  473. ipage = get_node_page(sbi, dir->i_ino);
  474. if (IS_ERR(ipage))
  475. return false;
  476. dentry_blk = inline_data_addr(ipage);
  477. bit_pos = find_next_bit_le(&dentry_blk->dentry_bitmap,
  478. NR_INLINE_DENTRY,
  479. bit_pos);
  480. f2fs_put_page(ipage, 1);
  481. if (bit_pos < NR_INLINE_DENTRY)
  482. return false;
  483. return true;
  484. }
  485. int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
  486. struct fscrypt_str *fstr)
  487. {
  488. struct inode *inode = file_inode(file);
  489. struct f2fs_inline_dentry *inline_dentry = NULL;
  490. struct page *ipage = NULL;
  491. struct f2fs_dentry_ptr d;
  492. if (ctx->pos == NR_INLINE_DENTRY)
  493. return 0;
  494. ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
  495. if (IS_ERR(ipage))
  496. return PTR_ERR(ipage);
  497. inline_dentry = inline_data_addr(ipage);
  498. make_dentry_ptr(inode, &d, (void *)inline_dentry, 2);
  499. if (!f2fs_fill_dentries(ctx, &d, 0, fstr))
  500. ctx->pos = NR_INLINE_DENTRY;
  501. f2fs_put_page(ipage, 1);
  502. return 0;
  503. }
  504. int f2fs_inline_data_fiemap(struct inode *inode,
  505. struct fiemap_extent_info *fieinfo, __u64 start, __u64 len)
  506. {
  507. __u64 byteaddr, ilen;
  508. __u32 flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED |
  509. FIEMAP_EXTENT_LAST;
  510. struct node_info ni;
  511. struct page *ipage;
  512. int err = 0;
  513. ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
  514. if (IS_ERR(ipage))
  515. return PTR_ERR(ipage);
  516. if (!f2fs_has_inline_data(inode)) {
  517. err = -EAGAIN;
  518. goto out;
  519. }
  520. ilen = min_t(size_t, MAX_INLINE_DATA, i_size_read(inode));
  521. if (start >= ilen)
  522. goto out;
  523. if (start + len < ilen)
  524. ilen = start + len;
  525. ilen -= start;
  526. get_node_info(F2FS_I_SB(inode), inode->i_ino, &ni);
  527. byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits;
  528. byteaddr += (char *)inline_data_addr(ipage) - (char *)F2FS_INODE(ipage);
  529. err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags);
  530. out:
  531. f2fs_put_page(ipage, 1);
  532. return err;
  533. }