inline.c (c7d77a7980e434c3af17de19e3348157f9b9ccce) | inline.c (67f8cf3cee6f398d05de8333c04fea2ddb59c805) |
---|---|
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 11#include <linux/fs.h> 12#include <linux/f2fs_fs.h> 13 14#include "f2fs.h" | 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 11#include <linux/fs.h> 12#include <linux/f2fs_fs.h> 13 14#include "f2fs.h" |
15#include "node.h" |
|
15 16bool f2fs_may_inline_data(struct inode *inode) 17{ 18 if (!test_opt(F2FS_I_SB(inode), INLINE_DATA)) 19 return false; 20 21 if (f2fs_is_atomic_file(inode)) 22 return false; --- 246 unchanged lines hidden (view full) --- 269 update_inode(inode, ipage); 270 f2fs_put_page(ipage, 1); 271 return true; 272 } 273 274 if (f2fs_has_inline_data(inode)) { 275 ipage = get_node_page(sbi, inode->i_ino); 276 f2fs_bug_on(sbi, IS_ERR(ipage)); | 16 17bool f2fs_may_inline_data(struct inode *inode) 18{ 19 if (!test_opt(F2FS_I_SB(inode), INLINE_DATA)) 20 return false; 21 22 if (f2fs_is_atomic_file(inode)) 23 return false; --- 246 unchanged lines hidden (view full) --- 270 update_inode(inode, ipage); 271 f2fs_put_page(ipage, 1); 272 return true; 273 } 274 275 if (f2fs_has_inline_data(inode)) { 276 ipage = get_node_page(sbi, inode->i_ino); 277 f2fs_bug_on(sbi, IS_ERR(ipage)); |
277 truncate_inline_inode(ipage, 0); | 278 if (!truncate_inline_inode(ipage, 0)) 279 return false; |
278 f2fs_clear_inline_inode(inode); 279 update_inode(inode, ipage); 280 f2fs_put_page(ipage, 1); 281 } else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) { | 280 f2fs_clear_inline_inode(inode); 281 update_inode(inode, ipage); 282 f2fs_put_page(ipage, 1); 283 } else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) { |
282 truncate_blocks(inode, 0, false); | 284 if (truncate_blocks(inode, 0, false)) 285 return false; |
283 goto process_inline; 284 } 285 return false; 286} 287 288struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir, 289 struct f2fs_filename *fname, struct page **res_page) 290{ --- 272 unchanged lines hidden (view full) --- 563 make_dentry_ptr(inode, &d, (void *)inline_dentry, 2); 564 565 if (!f2fs_fill_dentries(ctx, &d, 0, fstr)) 566 ctx->pos = NR_INLINE_DENTRY; 567 568 f2fs_put_page(ipage, 1); 569 return 0; 570} | 286 goto process_inline; 287 } 288 return false; 289} 290 291struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir, 292 struct f2fs_filename *fname, struct page **res_page) 293{ --- 272 unchanged lines hidden (view full) --- 566 make_dentry_ptr(inode, &d, (void *)inline_dentry, 2); 567 568 if (!f2fs_fill_dentries(ctx, &d, 0, fstr)) 569 ctx->pos = NR_INLINE_DENTRY; 570 571 f2fs_put_page(ipage, 1); 572 return 0; 573} |
574 575int f2fs_inline_data_fiemap(struct inode *inode, 576 struct fiemap_extent_info *fieinfo, __u64 start, __u64 len) 577{ 578 __u64 byteaddr, ilen; 579 __u32 flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED | 580 FIEMAP_EXTENT_LAST; 581 struct node_info ni; 582 struct page *ipage; 583 int err = 0; 584 585 ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino); 586 if (IS_ERR(ipage)) 587 return PTR_ERR(ipage); 588 589 if (!f2fs_has_inline_data(inode)) { 590 err = -EAGAIN; 591 goto out; 592 } 593 594 ilen = min_t(size_t, MAX_INLINE_DATA, i_size_read(inode)); 595 if (start >= ilen) 596 goto out; 597 if (start + len < ilen) 598 ilen = start + len; 599 ilen -= start; 600 601 get_node_info(F2FS_I_SB(inode), inode->i_ino, &ni); 602 byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits; 603 byteaddr += (char *)inline_data_addr(ipage) - (char *)F2FS_INODE(ipage); 604 err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags); 605out: 606 f2fs_put_page(ipage, 1); 607 return err; 608} |
|