aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2014-09-02 18:31:18 -0400
committerJaegeuk Kim <jaegeuk@kernel.org>2014-09-03 20:37:13 -0400
commit4081363fbe84a7ebac6d3339dd2775df45d856d0 (patch)
tree1484b33d753ff03255077b77c3d8f1c45c67e6af /fs
parent70c8038dd698b44daf7c8fc7e2eca142bec694c4 (diff)
f2fs: introduce F2FS_I_SB, F2FS_M_SB, and F2FS_P_SB
This patch adds three inline functions to clean up dirty casting codes. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/checkpoint.c18
-rw-r--r--fs/f2fs/data.c31
-rw-r--r--fs/f2fs/dir.c13
-rw-r--r--fs/f2fs/f2fs.h23
-rw-r--r--fs/f2fs/file.c20
-rw-r--r--fs/f2fs/inline.c13
-rw-r--r--fs/f2fs/inode.c8
-rw-r--r--fs/f2fs/namei.c21
-rw-r--r--fs/f2fs/node.c43
-rw-r--r--fs/f2fs/node.h3
-rw-r--r--fs/f2fs/recovery.c2
-rw-r--r--fs/f2fs/segment.c14
-rw-r--r--fs/f2fs/segment.h2
-rw-r--r--fs/f2fs/xattr.c6
14 files changed, 103 insertions, 114 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index ec3b7a5381fa..cb5cb4ca1814 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -151,8 +151,7 @@ out:
151static int f2fs_write_meta_page(struct page *page, 151static int f2fs_write_meta_page(struct page *page,
152 struct writeback_control *wbc) 152 struct writeback_control *wbc)
153{ 153{
154 struct inode *inode = page->mapping->host; 154 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
155 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
156 155
157 trace_f2fs_writepage(page, META); 156 trace_f2fs_writepage(page, META);
158 157
@@ -177,7 +176,7 @@ redirty_out:
177static int f2fs_write_meta_pages(struct address_space *mapping, 176static int f2fs_write_meta_pages(struct address_space *mapping,
178 struct writeback_control *wbc) 177 struct writeback_control *wbc)
179{ 178{
180 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb); 179 struct f2fs_sb_info *sbi = F2FS_M_SB(mapping);
181 long diff, written; 180 long diff, written;
182 181
183 trace_f2fs_writepages(mapping->host, wbc, META); 182 trace_f2fs_writepages(mapping->host, wbc, META);
@@ -259,15 +258,12 @@ continue_unlock:
259 258
260static int f2fs_set_meta_page_dirty(struct page *page) 259static int f2fs_set_meta_page_dirty(struct page *page)
261{ 260{
262 struct address_space *mapping = page->mapping;
263 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb);
264
265 trace_f2fs_set_page_dirty(page, META); 261 trace_f2fs_set_page_dirty(page, META);
266 262
267 SetPageUptodate(page); 263 SetPageUptodate(page);
268 if (!PageDirty(page)) { 264 if (!PageDirty(page)) {
269 __set_page_dirty_nobuffers(page); 265 __set_page_dirty_nobuffers(page);
270 inc_page_count(sbi, F2FS_DIRTY_META); 266 inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_META);
271 return 1; 267 return 1;
272 } 268 }
273 return 0; 269 return 0;
@@ -619,7 +615,7 @@ fail_no_cp:
619 615
620static int __add_dirty_inode(struct inode *inode, struct dir_inode_entry *new) 616static int __add_dirty_inode(struct inode *inode, struct dir_inode_entry *new)
621{ 617{
622 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 618 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
623 619
624 if (is_inode_flag_set(F2FS_I(inode), FI_DIRTY_DIR)) 620 if (is_inode_flag_set(F2FS_I(inode), FI_DIRTY_DIR))
625 return -EEXIST; 621 return -EEXIST;
@@ -633,7 +629,7 @@ static int __add_dirty_inode(struct inode *inode, struct dir_inode_entry *new)
633 629
634void set_dirty_dir_page(struct inode *inode, struct page *page) 630void set_dirty_dir_page(struct inode *inode, struct page *page)
635{ 631{
636 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 632 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
637 struct dir_inode_entry *new; 633 struct dir_inode_entry *new;
638 int ret = 0; 634 int ret = 0;
639 635
@@ -656,7 +652,7 @@ void set_dirty_dir_page(struct inode *inode, struct page *page)
656 652
657void add_dirty_dir_inode(struct inode *inode) 653void add_dirty_dir_inode(struct inode *inode)
658{ 654{
659 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 655 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
660 struct dir_inode_entry *new = 656 struct dir_inode_entry *new =
661 f2fs_kmem_cache_alloc(inode_entry_slab, GFP_NOFS); 657 f2fs_kmem_cache_alloc(inode_entry_slab, GFP_NOFS);
662 int ret = 0; 658 int ret = 0;
@@ -674,7 +670,7 @@ void add_dirty_dir_inode(struct inode *inode)
674 670
675void remove_dirty_dir_inode(struct inode *inode) 671void remove_dirty_dir_inode(struct inode *inode)
676{ 672{
677 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 673 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
678 struct dir_inode_entry *entry; 674 struct dir_inode_entry *entry;
679 675
680 if (!S_ISDIR(inode->i_mode)) 676 if (!S_ISDIR(inode->i_mode))
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 76de83e25a89..8eb6fcaa0a6b 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -236,7 +236,7 @@ static void __set_data_blkaddr(struct dnode_of_data *dn, block_t new_addr)
236 236
237int reserve_new_block(struct dnode_of_data *dn) 237int reserve_new_block(struct dnode_of_data *dn)
238{ 238{
239 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 239 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
240 240
241 if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC))) 241 if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC)))
242 return -EPERM; 242 return -EPERM;
@@ -396,7 +396,6 @@ end_update:
396 396
397struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync) 397struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync)
398{ 398{
399 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
400 struct address_space *mapping = inode->i_mapping; 399 struct address_space *mapping = inode->i_mapping;
401 struct dnode_of_data dn; 400 struct dnode_of_data dn;
402 struct page *page; 401 struct page *page;
@@ -429,7 +428,7 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync)
429 return page; 428 return page;
430 } 429 }
431 430
432 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr, 431 err = f2fs_submit_page_bio(F2FS_I_SB(inode), page, dn.data_blkaddr,
433 sync ? READ_SYNC : READA); 432 sync ? READ_SYNC : READA);
434 if (err) 433 if (err)
435 return ERR_PTR(err); 434 return ERR_PTR(err);
@@ -451,7 +450,6 @@ struct page *find_data_page(struct inode *inode, pgoff_t index, bool sync)
451 */ 450 */
452struct page *get_lock_data_page(struct inode *inode, pgoff_t index) 451struct page *get_lock_data_page(struct inode *inode, pgoff_t index)
453{ 452{
454 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
455 struct address_space *mapping = inode->i_mapping; 453 struct address_space *mapping = inode->i_mapping;
456 struct dnode_of_data dn; 454 struct dnode_of_data dn;
457 struct page *page; 455 struct page *page;
@@ -490,7 +488,8 @@ repeat:
490 return page; 488 return page;
491 } 489 }
492 490
493 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr, READ_SYNC); 491 err = f2fs_submit_page_bio(F2FS_I_SB(inode), page,
492 dn.data_blkaddr, READ_SYNC);
494 if (err) 493 if (err)
495 return ERR_PTR(err); 494 return ERR_PTR(err);
496 495
@@ -517,7 +516,6 @@ repeat:
517struct page *get_new_data_page(struct inode *inode, 516struct page *get_new_data_page(struct inode *inode,
518 struct page *ipage, pgoff_t index, bool new_i_size) 517 struct page *ipage, pgoff_t index, bool new_i_size)
519{ 518{
520 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
521 struct address_space *mapping = inode->i_mapping; 519 struct address_space *mapping = inode->i_mapping;
522 struct page *page; 520 struct page *page;
523 struct dnode_of_data dn; 521 struct dnode_of_data dn;
@@ -541,8 +539,8 @@ repeat:
541 zero_user_segment(page, 0, PAGE_CACHE_SIZE); 539 zero_user_segment(page, 0, PAGE_CACHE_SIZE);
542 SetPageUptodate(page); 540 SetPageUptodate(page);
543 } else { 541 } else {
544 err = f2fs_submit_page_bio(sbi, page, dn.data_blkaddr, 542 err = f2fs_submit_page_bio(F2FS_I_SB(inode), page,
545 READ_SYNC); 543 dn.data_blkaddr, READ_SYNC);
546 if (err) 544 if (err)
547 goto put_err; 545 goto put_err;
548 546
@@ -573,7 +571,7 @@ put_err:
573 571
574static int __allocate_data_block(struct dnode_of_data *dn) 572static int __allocate_data_block(struct dnode_of_data *dn)
575{ 573{
576 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 574 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
577 struct f2fs_summary sum; 575 struct f2fs_summary sum;
578 block_t new_blkaddr; 576 block_t new_blkaddr;
579 struct node_info ni; 577 struct node_info ni;
@@ -614,7 +612,6 @@ static int __allocate_data_block(struct dnode_of_data *dn)
614static int __get_data_block(struct inode *inode, sector_t iblock, 612static int __get_data_block(struct inode *inode, sector_t iblock,
615 struct buffer_head *bh_result, int create, bool fiemap) 613 struct buffer_head *bh_result, int create, bool fiemap)
616{ 614{
617 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
618 unsigned int blkbits = inode->i_sb->s_blocksize_bits; 615 unsigned int blkbits = inode->i_sb->s_blocksize_bits;
619 unsigned maxblocks = bh_result->b_size >> blkbits; 616 unsigned maxblocks = bh_result->b_size >> blkbits;
620 struct dnode_of_data dn; 617 struct dnode_of_data dn;
@@ -630,8 +627,8 @@ static int __get_data_block(struct inode *inode, sector_t iblock,
630 goto out; 627 goto out;
631 628
632 if (create) { 629 if (create) {
633 f2fs_balance_fs(sbi); 630 f2fs_balance_fs(F2FS_I_SB(inode));
634 f2fs_lock_op(sbi); 631 f2fs_lock_op(F2FS_I_SB(inode));
635 } 632 }
636 633
637 /* When reading holes, we need its node page */ 634 /* When reading holes, we need its node page */
@@ -707,7 +704,7 @@ put_out:
707 f2fs_put_dnode(&dn); 704 f2fs_put_dnode(&dn);
708unlock_out: 705unlock_out:
709 if (create) 706 if (create)
710 f2fs_unlock_op(sbi); 707 f2fs_unlock_op(F2FS_I_SB(inode));
711out: 708out:
712 trace_f2fs_get_data_block(inode, iblock, bh_result, err); 709 trace_f2fs_get_data_block(inode, iblock, bh_result, err);
713 return err; 710 return err;
@@ -804,7 +801,7 @@ static int f2fs_write_data_page(struct page *page,
804 struct writeback_control *wbc) 801 struct writeback_control *wbc)
805{ 802{
806 struct inode *inode = page->mapping->host; 803 struct inode *inode = page->mapping->host;
807 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 804 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
808 loff_t i_size = i_size_read(inode); 805 loff_t i_size = i_size_read(inode);
809 const pgoff_t end_index = ((unsigned long long) i_size) 806 const pgoff_t end_index = ((unsigned long long) i_size)
810 >> PAGE_CACHE_SHIFT; 807 >> PAGE_CACHE_SHIFT;
@@ -892,7 +889,7 @@ static int f2fs_write_data_pages(struct address_space *mapping,
892 struct writeback_control *wbc) 889 struct writeback_control *wbc)
893{ 890{
894 struct inode *inode = mapping->host; 891 struct inode *inode = mapping->host;
895 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 892 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
896 bool locked = false; 893 bool locked = false;
897 int ret; 894 int ret;
898 long diff; 895 long diff;
@@ -945,7 +942,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
945 struct page **pagep, void **fsdata) 942 struct page **pagep, void **fsdata)
946{ 943{
947 struct inode *inode = mapping->host; 944 struct inode *inode = mapping->host;
948 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 945 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
949 struct page *page; 946 struct page *page;
950 pgoff_t index = ((unsigned long long) pos) >> PAGE_CACHE_SHIFT; 947 pgoff_t index = ((unsigned long long) pos) >> PAGE_CACHE_SHIFT;
951 struct dnode_of_data dn; 948 struct dnode_of_data dn;
@@ -1093,7 +1090,7 @@ static ssize_t f2fs_direct_IO(int rw, struct kiocb *iocb,
1093 return 0; 1090 return 0;
1094 1091
1095 /* clear fsync mark to recover these blocks */ 1092 /* clear fsync mark to recover these blocks */
1096 fsync_mark_clear(F2FS_SB(inode->i_sb), inode->i_ino); 1093 fsync_mark_clear(F2FS_I_SB(inode), inode->i_ino);
1097 1094
1098 trace_f2fs_direct_IO_enter(inode, offset, count, rw); 1095 trace_f2fs_direct_IO_enter(inode, offset, count, rw);
1099 1096
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 155fb056b7f1..c242904d9724 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -284,10 +284,9 @@ static void init_dent_inode(const struct qstr *name, struct page *ipage)
284 284
285int update_dent_inode(struct inode *inode, const struct qstr *name) 285int update_dent_inode(struct inode *inode, const struct qstr *name)
286{ 286{
287 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
288 struct page *page; 287 struct page *page;
289 288
290 page = get_node_page(sbi, inode->i_ino); 289 page = get_node_page(F2FS_I_SB(inode), inode->i_ino);
291 if (IS_ERR(page)) 290 if (IS_ERR(page))
292 return PTR_ERR(page); 291 return PTR_ERR(page);
293 292
@@ -337,7 +336,6 @@ static int make_empty_dir(struct inode *inode,
337static struct page *init_inode_metadata(struct inode *inode, 336static struct page *init_inode_metadata(struct inode *inode,
338 struct inode *dir, const struct qstr *name) 337 struct inode *dir, const struct qstr *name)
339{ 338{
340 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
341 struct page *page; 339 struct page *page;
342 int err; 340 int err;
343 341
@@ -360,7 +358,7 @@ static struct page *init_inode_metadata(struct inode *inode,
360 if (err) 358 if (err)
361 goto put_error; 359 goto put_error;
362 } else { 360 } else {
363 page = get_node_page(F2FS_SB(dir->i_sb), inode->i_ino); 361 page = get_node_page(F2FS_I_SB(dir), inode->i_ino);
364 if (IS_ERR(page)) 362 if (IS_ERR(page))
365 return page; 363 return page;
366 364
@@ -381,7 +379,7 @@ static struct page *init_inode_metadata(struct inode *inode,
381 * we should remove this inode from orphan list. 379 * we should remove this inode from orphan list.
382 */ 380 */
383 if (inode->i_nlink == 0) 381 if (inode->i_nlink == 0)
384 remove_orphan_inode(sbi, inode->i_ino); 382 remove_orphan_inode(F2FS_I_SB(dir), inode->i_ino);
385 inc_nlink(inode); 383 inc_nlink(inode);
386 } 384 }
387 return page; 385 return page;
@@ -571,8 +569,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
571{ 569{
572 struct f2fs_dentry_block *dentry_blk; 570 struct f2fs_dentry_block *dentry_blk;
573 unsigned int bit_pos; 571 unsigned int bit_pos;
574 struct address_space *mapping = page->mapping; 572 struct inode *dir = page->mapping->host;
575 struct inode *dir = mapping->host;
576 int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len)); 573 int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
577 int i; 574 int i;
578 575
@@ -594,7 +591,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
594 dir->i_ctime = dir->i_mtime = CURRENT_TIME; 591 dir->i_ctime = dir->i_mtime = CURRENT_TIME;
595 592
596 if (inode) { 593 if (inode) {
597 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 594 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
598 595
599 down_write(&F2FS_I(inode)->i_sem); 596 down_write(&F2FS_I(inode)->i_sem);
600 597
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e921242186f6..222ff5b4d1e1 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -539,6 +539,21 @@ static inline struct f2fs_sb_info *F2FS_SB(struct super_block *sb)
539 return sb->s_fs_info; 539 return sb->s_fs_info;
540} 540}
541 541
542static inline struct f2fs_sb_info *F2FS_I_SB(struct inode *inode)
543{
544 return F2FS_SB(inode->i_sb);
545}
546
547static inline struct f2fs_sb_info *F2FS_M_SB(struct address_space *mapping)
548{
549 return F2FS_I_SB(mapping->host);
550}
551
552static inline struct f2fs_sb_info *F2FS_P_SB(struct page *page)
553{
554 return F2FS_M_SB(page->mapping);
555}
556
542static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi) 557static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
543{ 558{
544 return (struct f2fs_super_block *)(sbi->raw_super); 559 return (struct f2fs_super_block *)(sbi->raw_super);
@@ -718,7 +733,7 @@ static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
718 733
719static inline void inode_inc_dirty_dents(struct inode *inode) 734static inline void inode_inc_dirty_dents(struct inode *inode)
720{ 735{
721 inc_page_count(F2FS_SB(inode->i_sb), F2FS_DIRTY_DENTS); 736 inc_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS);
722 atomic_inc(&F2FS_I(inode)->dirty_dents); 737 atomic_inc(&F2FS_I(inode)->dirty_dents);
723} 738}
724 739
@@ -732,7 +747,7 @@ static inline void inode_dec_dirty_dents(struct inode *inode)
732 if (!S_ISDIR(inode->i_mode)) 747 if (!S_ISDIR(inode->i_mode))
733 return; 748 return;
734 749
735 dec_page_count(F2FS_SB(inode->i_sb), F2FS_DIRTY_DENTS); 750 dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_DENTS);
736 atomic_dec(&F2FS_I(inode)->dirty_dents); 751 atomic_dec(&F2FS_I(inode)->dirty_dents);
737} 752}
738 753
@@ -1359,12 +1374,12 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
1359#define stat_inc_inline_inode(inode) \ 1374#define stat_inc_inline_inode(inode) \
1360 do { \ 1375 do { \
1361 if (f2fs_has_inline_data(inode)) \ 1376 if (f2fs_has_inline_data(inode)) \
1362 ((F2FS_SB(inode->i_sb))->inline_inode++); \ 1377 ((F2FS_I_SB(inode))->inline_inode++); \
1363 } while (0) 1378 } while (0)
1364#define stat_dec_inline_inode(inode) \ 1379#define stat_dec_inline_inode(inode) \
1365 do { \ 1380 do { \
1366 if (f2fs_has_inline_data(inode)) \ 1381 if (f2fs_has_inline_data(inode)) \
1367 ((F2FS_SB(inode->i_sb))->inline_inode--); \ 1382 ((F2FS_I_SB(inode))->inline_inode--); \
1368 } while (0) 1383 } while (0)
1369 1384
1370#define stat_inc_seg_type(sbi, curseg) \ 1385#define stat_inc_seg_type(sbi, curseg) \
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 060aee65aee8..411f053720c2 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -33,7 +33,7 @@ static int f2fs_vm_page_mkwrite(struct vm_area_struct *vma,
33{ 33{
34 struct page *page = vmf->page; 34 struct page *page = vmf->page;
35 struct inode *inode = file_inode(vma->vm_file); 35 struct inode *inode = file_inode(vma->vm_file);
36 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 36 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
37 struct dnode_of_data dn; 37 struct dnode_of_data dn;
38 int err; 38 int err;
39 39
@@ -117,7 +117,7 @@ static int get_parent_ino(struct inode *inode, nid_t *pino)
117 117
118static inline bool need_do_checkpoint(struct inode *inode) 118static inline bool need_do_checkpoint(struct inode *inode)
119{ 119{
120 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 120 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
121 bool need_cp = false; 121 bool need_cp = false;
122 122
123 if (!S_ISREG(inode->i_mode) || inode->i_nlink != 1) 123 if (!S_ISREG(inode->i_mode) || inode->i_nlink != 1)
@@ -138,7 +138,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
138{ 138{
139 struct inode *inode = file->f_mapping->host; 139 struct inode *inode = file->f_mapping->host;
140 struct f2fs_inode_info *fi = F2FS_I(inode); 140 struct f2fs_inode_info *fi = F2FS_I(inode);
141 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 141 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
142 int ret = 0; 142 int ret = 0;
143 bool need_cp = false; 143 bool need_cp = false;
144 struct writeback_control wbc = { 144 struct writeback_control wbc = {
@@ -226,7 +226,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
226flush_out: 226flush_out:
227 remove_dirty_inode(sbi, inode->i_ino, UPDATE_INO); 227 remove_dirty_inode(sbi, inode->i_ino, UPDATE_INO);
228 clear_inode_flag(fi, FI_UPDATE_WRITE); 228 clear_inode_flag(fi, FI_UPDATE_WRITE);
229 ret = f2fs_issue_flush(F2FS_SB(inode->i_sb)); 229 ret = f2fs_issue_flush(F2FS_I_SB(inode));
230 } 230 }
231out: 231out:
232 trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret); 232 trace_f2fs_sync_file_exit(inode, need_cp, datasync, ret);
@@ -369,7 +369,7 @@ static int f2fs_file_mmap(struct file *file, struct vm_area_struct *vma)
369int truncate_data_blocks_range(struct dnode_of_data *dn, int count) 369int truncate_data_blocks_range(struct dnode_of_data *dn, int count)
370{ 370{
371 int nr_free = 0, ofs = dn->ofs_in_node; 371 int nr_free = 0, ofs = dn->ofs_in_node;
372 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 372 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
373 struct f2fs_node *raw_node; 373 struct f2fs_node *raw_node;
374 __le32 *addr; 374 __le32 *addr;
375 375
@@ -432,7 +432,7 @@ out:
432 432
433int truncate_blocks(struct inode *inode, u64 from, bool lock) 433int truncate_blocks(struct inode *inode, u64 from, bool lock)
434{ 434{
435 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 435 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
436 unsigned int blocksize = inode->i_sb->s_blocksize; 436 unsigned int blocksize = inode->i_sb->s_blocksize;
437 struct dnode_of_data dn; 437 struct dnode_of_data dn;
438 pgoff_t free_from; 438 pgoff_t free_from;
@@ -555,7 +555,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
555 555
556 truncate_setsize(inode, attr->ia_size); 556 truncate_setsize(inode, attr->ia_size);
557 f2fs_truncate(inode); 557 f2fs_truncate(inode);
558 f2fs_balance_fs(F2FS_SB(inode->i_sb)); 558 f2fs_balance_fs(F2FS_I_SB(inode));
559 } 559 }
560 560
561 __setattr_copy(inode, attr); 561 __setattr_copy(inode, attr);
@@ -589,7 +589,7 @@ const struct inode_operations f2fs_file_inode_operations = {
589static void fill_zero(struct inode *inode, pgoff_t index, 589static void fill_zero(struct inode *inode, pgoff_t index,
590 loff_t start, loff_t len) 590 loff_t start, loff_t len)
591{ 591{
592 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 592 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
593 struct page *page; 593 struct page *page;
594 594
595 if (!len) 595 if (!len)
@@ -661,7 +661,7 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
661 if (pg_start < pg_end) { 661 if (pg_start < pg_end) {
662 struct address_space *mapping = inode->i_mapping; 662 struct address_space *mapping = inode->i_mapping;
663 loff_t blk_start, blk_end; 663 loff_t blk_start, blk_end;
664 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 664 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
665 665
666 f2fs_balance_fs(sbi); 666 f2fs_balance_fs(sbi);
667 667
@@ -682,7 +682,7 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
682static int expand_inode_data(struct inode *inode, loff_t offset, 682static int expand_inode_data(struct inode *inode, loff_t offset,
683 loff_t len, int mode) 683 loff_t len, int mode)
684{ 684{
685 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 685 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
686 pgoff_t index, pg_start, pg_end; 686 pgoff_t index, pg_start, pg_end;
687 loff_t new_size = i_size_read(inode); 687 loff_t new_size = i_size_read(inode);
688 loff_t off_start, off_end; 688 loff_t off_start, off_end;
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 3e8ecdf3742b..289f99e9a339 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -15,11 +15,10 @@
15 15
16bool f2fs_may_inline(struct inode *inode) 16bool f2fs_may_inline(struct inode *inode)
17{ 17{
18 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
19 block_t nr_blocks; 18 block_t nr_blocks;
20 loff_t i_size; 19 loff_t i_size;
21 20
22 if (!test_opt(sbi, INLINE_DATA)) 21 if (!test_opt(F2FS_I_SB(inode), INLINE_DATA))
23 return false; 22 return false;
24 23
25 nr_blocks = F2FS_I(inode)->i_xattr_nid ? 3 : 2; 24 nr_blocks = F2FS_I(inode)->i_xattr_nid ? 3 : 2;
@@ -35,7 +34,6 @@ bool f2fs_may_inline(struct inode *inode)
35 34
36int f2fs_read_inline_data(struct inode *inode, struct page *page) 35int f2fs_read_inline_data(struct inode *inode, struct page *page)
37{ 36{
38 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
39 struct page *ipage; 37 struct page *ipage;
40 void *src_addr, *dst_addr; 38 void *src_addr, *dst_addr;
41 39
@@ -44,7 +42,7 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page)
44 goto out; 42 goto out;
45 } 43 }
46 44
47 ipage = get_node_page(sbi, inode->i_ino); 45 ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
48 if (IS_ERR(ipage)) { 46 if (IS_ERR(ipage)) {
49 unlock_page(page); 47 unlock_page(page);
50 return PTR_ERR(ipage); 48 return PTR_ERR(ipage);
@@ -73,7 +71,7 @@ static int __f2fs_convert_inline_data(struct inode *inode, struct page *page)
73 struct dnode_of_data dn; 71 struct dnode_of_data dn;
74 void *src_addr, *dst_addr; 72 void *src_addr, *dst_addr;
75 block_t new_blk_addr; 73 block_t new_blk_addr;
76 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 74 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
77 struct f2fs_io_info fio = { 75 struct f2fs_io_info fio = {
78 .type = DATA, 76 .type = DATA,
79 .rw = WRITE_SYNC | REQ_PRIO, 77 .rw = WRITE_SYNC | REQ_PRIO,
@@ -189,13 +187,12 @@ int f2fs_write_inline_data(struct inode *inode,
189 187
190void truncate_inline_data(struct inode *inode, u64 from) 188void truncate_inline_data(struct inode *inode, u64 from)
191{ 189{
192 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
193 struct page *ipage; 190 struct page *ipage;
194 191
195 if (from >= MAX_INLINE_DATA) 192 if (from >= MAX_INLINE_DATA)
196 return; 193 return;
197 194
198 ipage = get_node_page(sbi, inode->i_ino); 195 ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
199 if (IS_ERR(ipage)) 196 if (IS_ERR(ipage))
200 return; 197 return;
201 198
@@ -209,7 +206,7 @@ void truncate_inline_data(struct inode *inode, u64 from)
209 206
210bool recover_inline_data(struct inode *inode, struct page *npage) 207bool recover_inline_data(struct inode *inode, struct page *npage)
211{ 208{
212 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 209 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
213 struct f2fs_inode *ri = NULL; 210 struct f2fs_inode *ri = NULL;
214 void *src_addr, *dst_addr; 211 void *src_addr, *dst_addr;
215 struct page *ipage; 212 struct page *ipage;
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
index 2c39999f3868..bf99e1fe82a0 100644
--- a/fs/f2fs/inode.c
+++ b/fs/f2fs/inode.c
@@ -69,7 +69,7 @@ static void __set_inode_rdev(struct inode *inode, struct f2fs_inode *ri)
69 69
70static int do_read_inode(struct inode *inode) 70static int do_read_inode(struct inode *inode)
71{ 71{
72 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 72 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
73 struct f2fs_inode_info *fi = F2FS_I(inode); 73 struct f2fs_inode_info *fi = F2FS_I(inode);
74 struct page *node_page; 74 struct page *node_page;
75 struct f2fs_inode *ri; 75 struct f2fs_inode *ri;
@@ -218,7 +218,7 @@ void update_inode(struct inode *inode, struct page *node_page)
218 218
219void update_inode_page(struct inode *inode) 219void update_inode_page(struct inode *inode)
220{ 220{
221 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 221 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
222 struct page *node_page; 222 struct page *node_page;
223retry: 223retry:
224 node_page = get_node_page(sbi, inode->i_ino); 224 node_page = get_node_page(sbi, inode->i_ino);
@@ -238,7 +238,7 @@ retry:
238 238
239int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) 239int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
240{ 240{
241 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 241 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
242 242
243 if (inode->i_ino == F2FS_NODE_INO(sbi) || 243 if (inode->i_ino == F2FS_NODE_INO(sbi) ||
244 inode->i_ino == F2FS_META_INO(sbi)) 244 inode->i_ino == F2FS_META_INO(sbi))
@@ -266,7 +266,7 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
266 */ 266 */
267void f2fs_evict_inode(struct inode *inode) 267void f2fs_evict_inode(struct inode *inode)
268{ 268{
269 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 269 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
270 nid_t xnid = F2FS_I(inode)->i_xattr_nid; 270 nid_t xnid = F2FS_I(inode)->i_xattr_nid;
271 271
272 trace_f2fs_evict_inode(inode); 272 trace_f2fs_evict_inode(inode);
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index ee103fd7283c..ba0779d4cfd7 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -23,7 +23,7 @@
23 23
24static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) 24static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
25{ 25{
26 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 26 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
27 nid_t ino; 27 nid_t ino;
28 struct inode *inode; 28 struct inode *inode;
29 bool nid_free = false; 29 bool nid_free = false;
@@ -102,7 +102,7 @@ static inline void set_cold_files(struct f2fs_sb_info *sbi, struct inode *inode,
102static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, 102static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
103 bool excl) 103 bool excl)
104{ 104{
105 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 105 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
106 struct inode *inode; 106 struct inode *inode;
107 nid_t ino = 0; 107 nid_t ino = 0;
108 int err; 108 int err;
@@ -143,7 +143,7 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
143 struct dentry *dentry) 143 struct dentry *dentry)
144{ 144{
145 struct inode *inode = old_dentry->d_inode; 145 struct inode *inode = old_dentry->d_inode;
146 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 146 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
147 int err; 147 int err;
148 148
149 f2fs_balance_fs(sbi); 149 f2fs_balance_fs(sbi);
@@ -203,7 +203,7 @@ static struct dentry *f2fs_lookup(struct inode *dir, struct dentry *dentry,
203 203
204static int f2fs_unlink(struct inode *dir, struct dentry *dentry) 204static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
205{ 205{
206 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 206 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
207 struct inode *inode = dentry->d_inode; 207 struct inode *inode = dentry->d_inode;
208 struct f2fs_dir_entry *de; 208 struct f2fs_dir_entry *de;
209 struct page *page; 209 struct page *page;
@@ -237,7 +237,7 @@ fail:
237static int f2fs_symlink(struct inode *dir, struct dentry *dentry, 237static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
238 const char *symname) 238 const char *symname)
239{ 239{
240 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 240 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
241 struct inode *inode; 241 struct inode *inode;
242 size_t symlen = strlen(symname) + 1; 242 size_t symlen = strlen(symname) + 1;
243 int err; 243 int err;
@@ -272,7 +272,7 @@ out:
272 272
273static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 273static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
274{ 274{
275 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 275 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
276 struct inode *inode; 276 struct inode *inode;
277 int err; 277 int err;
278 278
@@ -320,7 +320,7 @@ static int f2fs_rmdir(struct inode *dir, struct dentry *dentry)
320static int f2fs_mknod(struct inode *dir, struct dentry *dentry, 320static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
321 umode_t mode, dev_t rdev) 321 umode_t mode, dev_t rdev)
322{ 322{
323 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 323 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
324 struct inode *inode; 324 struct inode *inode;
325 int err = 0; 325 int err = 0;
326 326
@@ -356,7 +356,7 @@ out:
356static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, 356static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
357 struct inode *new_dir, struct dentry *new_dentry) 357 struct inode *new_dir, struct dentry *new_dentry)
358{ 358{
359 struct f2fs_sb_info *sbi = F2FS_SB(old_dir->i_sb); 359 struct f2fs_sb_info *sbi = F2FS_I_SB(old_dir);
360 struct inode *old_inode = old_dentry->d_inode; 360 struct inode *old_inode = old_dentry->d_inode;
361 struct inode *new_inode = new_dentry->d_inode; 361 struct inode *new_inode = new_dentry->d_inode;
362 struct page *old_dir_page; 362 struct page *old_dir_page;
@@ -480,8 +480,7 @@ out:
480static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, 480static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
481 struct inode *new_dir, struct dentry *new_dentry) 481 struct inode *new_dir, struct dentry *new_dentry)
482{ 482{
483 struct super_block *sb = old_dir->i_sb; 483 struct f2fs_sb_info *sbi = F2FS_I_SB(old_dir);
484 struct f2fs_sb_info *sbi = F2FS_SB(sb);
485 struct inode *old_inode = old_dentry->d_inode; 484 struct inode *old_inode = old_dentry->d_inode;
486 struct inode *new_inode = new_dentry->d_inode; 485 struct inode *new_inode = new_dentry->d_inode;
487 struct page *old_dir_page, *new_dir_page; 486 struct page *old_dir_page, *new_dir_page;
@@ -642,7 +641,7 @@ static int f2fs_rename2(struct inode *old_dir, struct dentry *old_dentry,
642 641
643static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) 642static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
644{ 643{
645 struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb); 644 struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
646 struct inode *inode; 645 struct inode *inode;
647 int err; 646 int err;
648 647
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 45378196e19a..725a47130b82 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -54,7 +54,6 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type)
54static void clear_node_page_dirty(struct page *page) 54static void clear_node_page_dirty(struct page *page)
55{ 55{
56 struct address_space *mapping = page->mapping; 56 struct address_space *mapping = page->mapping;
57 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb);
58 unsigned int long flags; 57 unsigned int long flags;
59 58
60 if (PageDirty(page)) { 59 if (PageDirty(page)) {
@@ -65,7 +64,7 @@ static void clear_node_page_dirty(struct page *page)
65 spin_unlock_irqrestore(&mapping->tree_lock, flags); 64 spin_unlock_irqrestore(&mapping->tree_lock, flags);
66 65
67 clear_page_dirty_for_io(page); 66 clear_page_dirty_for_io(page);
68 dec_page_count(sbi, F2FS_DIRTY_NODES); 67 dec_page_count(F2FS_M_SB(mapping), F2FS_DIRTY_NODES);
69 } 68 }
70 ClearPageUptodate(page); 69 ClearPageUptodate(page);
71} 70}
@@ -411,7 +410,7 @@ got:
411 */ 410 */
412int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode) 411int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
413{ 412{
414 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 413 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
415 struct page *npage[4]; 414 struct page *npage[4];
416 struct page *parent; 415 struct page *parent;
417 int offset[4]; 416 int offset[4];
@@ -504,7 +503,7 @@ release_out:
504 503
505static void truncate_node(struct dnode_of_data *dn) 504static void truncate_node(struct dnode_of_data *dn)
506{ 505{
507 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 506 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
508 struct node_info ni; 507 struct node_info ni;
509 508
510 get_node_info(sbi, dn->nid, &ni); 509 get_node_info(sbi, dn->nid, &ni);
@@ -540,14 +539,13 @@ invalidate:
540 539
541static int truncate_dnode(struct dnode_of_data *dn) 540static int truncate_dnode(struct dnode_of_data *dn)
542{ 541{
543 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb);
544 struct page *page; 542 struct page *page;
545 543
546 if (dn->nid == 0) 544 if (dn->nid == 0)
547 return 1; 545 return 1;
548 546
549 /* get direct node */ 547 /* get direct node */
550 page = get_node_page(sbi, dn->nid); 548 page = get_node_page(F2FS_I_SB(dn->inode), dn->nid);
551 if (IS_ERR(page) && PTR_ERR(page) == -ENOENT) 549 if (IS_ERR(page) && PTR_ERR(page) == -ENOENT)
552 return 1; 550 return 1;
553 else if (IS_ERR(page)) 551 else if (IS_ERR(page))
@@ -564,7 +562,6 @@ static int truncate_dnode(struct dnode_of_data *dn)
564static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs, 562static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs,
565 int ofs, int depth) 563 int ofs, int depth)
566{ 564{
567 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb);
568 struct dnode_of_data rdn = *dn; 565 struct dnode_of_data rdn = *dn;
569 struct page *page; 566 struct page *page;
570 struct f2fs_node *rn; 567 struct f2fs_node *rn;
@@ -578,7 +575,7 @@ static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs,
578 575
579 trace_f2fs_truncate_nodes_enter(dn->inode, dn->nid, dn->data_blkaddr); 576 trace_f2fs_truncate_nodes_enter(dn->inode, dn->nid, dn->data_blkaddr);
580 577
581 page = get_node_page(sbi, dn->nid); 578 page = get_node_page(F2FS_I_SB(dn->inode), dn->nid);
582 if (IS_ERR(page)) { 579 if (IS_ERR(page)) {
583 trace_f2fs_truncate_nodes_exit(dn->inode, PTR_ERR(page)); 580 trace_f2fs_truncate_nodes_exit(dn->inode, PTR_ERR(page));
584 return PTR_ERR(page); 581 return PTR_ERR(page);
@@ -636,7 +633,6 @@ out_err:
636static int truncate_partial_nodes(struct dnode_of_data *dn, 633static int truncate_partial_nodes(struct dnode_of_data *dn,
637 struct f2fs_inode *ri, int *offset, int depth) 634 struct f2fs_inode *ri, int *offset, int depth)
638{ 635{
639 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb);
640 struct page *pages[2]; 636 struct page *pages[2];
641 nid_t nid[3]; 637 nid_t nid[3];
642 nid_t child_nid; 638 nid_t child_nid;
@@ -651,7 +647,7 @@ static int truncate_partial_nodes(struct dnode_of_data *dn,
651 /* get indirect nodes in the path */ 647 /* get indirect nodes in the path */
652 for (i = 0; i < idx + 1; i++) { 648 for (i = 0; i < idx + 1; i++) {
653 /* reference count'll be increased */ 649 /* reference count'll be increased */
654 pages[i] = get_node_page(sbi, nid[i]); 650 pages[i] = get_node_page(F2FS_I_SB(dn->inode), nid[i]);
655 if (IS_ERR(pages[i])) { 651 if (IS_ERR(pages[i])) {
656 err = PTR_ERR(pages[i]); 652 err = PTR_ERR(pages[i]);
657 idx = i - 1; 653 idx = i - 1;
@@ -696,7 +692,7 @@ fail:
696 */ 692 */
697int truncate_inode_blocks(struct inode *inode, pgoff_t from) 693int truncate_inode_blocks(struct inode *inode, pgoff_t from)
698{ 694{
699 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 695 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
700 int err = 0, cont = 1; 696 int err = 0, cont = 1;
701 int level, offset[4], noffset[4]; 697 int level, offset[4], noffset[4];
702 unsigned int nofs = 0; 698 unsigned int nofs = 0;
@@ -792,7 +788,7 @@ fail:
792 788
793int truncate_xattr_node(struct inode *inode, struct page *page) 789int truncate_xattr_node(struct inode *inode, struct page *page)
794{ 790{
795 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 791 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
796 nid_t nid = F2FS_I(inode)->i_xattr_nid; 792 nid_t nid = F2FS_I(inode)->i_xattr_nid;
797 struct dnode_of_data dn; 793 struct dnode_of_data dn;
798 struct page *npage; 794 struct page *npage;
@@ -860,7 +856,7 @@ struct page *new_inode_page(struct inode *inode)
860struct page *new_node_page(struct dnode_of_data *dn, 856struct page *new_node_page(struct dnode_of_data *dn,
861 unsigned int ofs, struct page *ipage) 857 unsigned int ofs, struct page *ipage)
862{ 858{
863 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 859 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
864 struct node_info old_ni, new_ni; 860 struct node_info old_ni, new_ni;
865 struct page *page; 861 struct page *page;
866 int err; 862 int err;
@@ -918,7 +914,7 @@ fail:
918 */ 914 */
919static int read_node_page(struct page *page, int rw) 915static int read_node_page(struct page *page, int rw)
920{ 916{
921 struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); 917 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
922 struct node_info ni; 918 struct node_info ni;
923 919
924 get_node_info(sbi, page->index, &ni); 920 get_node_info(sbi, page->index, &ni);
@@ -994,7 +990,7 @@ got_it:
994 */ 990 */
995struct page *get_node_page_ra(struct page *parent, int start) 991struct page *get_node_page_ra(struct page *parent, int start)
996{ 992{
997 struct f2fs_sb_info *sbi = F2FS_SB(parent->mapping->host->i_sb); 993 struct f2fs_sb_info *sbi = F2FS_P_SB(parent);
998 struct blk_plug plug; 994 struct blk_plug plug;
999 struct page *page; 995 struct page *page;
1000 int err, i, end; 996 int err, i, end;
@@ -1206,7 +1202,7 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
1206static int f2fs_write_node_page(struct page *page, 1202static int f2fs_write_node_page(struct page *page,
1207 struct writeback_control *wbc) 1203 struct writeback_control *wbc)
1208{ 1204{
1209 struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); 1205 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
1210 nid_t nid; 1206 nid_t nid;
1211 block_t new_addr; 1207 block_t new_addr;
1212 struct node_info ni; 1208 struct node_info ni;
@@ -1257,7 +1253,7 @@ redirty_out:
1257static int f2fs_write_node_pages(struct address_space *mapping, 1253static int f2fs_write_node_pages(struct address_space *mapping,
1258 struct writeback_control *wbc) 1254 struct writeback_control *wbc)
1259{ 1255{
1260 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb); 1256 struct f2fs_sb_info *sbi = F2FS_M_SB(mapping);
1261 long diff; 1257 long diff;
1262 1258
1263 trace_f2fs_writepages(mapping->host, wbc, NODE); 1259 trace_f2fs_writepages(mapping->host, wbc, NODE);
@@ -1282,15 +1278,12 @@ skip_write:
1282 1278
1283static int f2fs_set_node_page_dirty(struct page *page) 1279static int f2fs_set_node_page_dirty(struct page *page)
1284{ 1280{
1285 struct address_space *mapping = page->mapping;
1286 struct f2fs_sb_info *sbi = F2FS_SB(mapping->host->i_sb);
1287
1288 trace_f2fs_set_page_dirty(page, NODE); 1281 trace_f2fs_set_page_dirty(page, NODE);
1289 1282
1290 SetPageUptodate(page); 1283 SetPageUptodate(page);
1291 if (!PageDirty(page)) { 1284 if (!PageDirty(page)) {
1292 __set_page_dirty_nobuffers(page); 1285 __set_page_dirty_nobuffers(page);
1293 inc_page_count(sbi, F2FS_DIRTY_NODES); 1286 inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_NODES);
1294 SetPagePrivate(page); 1287 SetPagePrivate(page);
1295 return 1; 1288 return 1;
1296 } 1289 }
@@ -1301,9 +1294,8 @@ static void f2fs_invalidate_node_page(struct page *page, unsigned int offset,
1301 unsigned int length) 1294 unsigned int length)
1302{ 1295{
1303 struct inode *inode = page->mapping->host; 1296 struct inode *inode = page->mapping->host;
1304 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
1305 if (PageDirty(page)) 1297 if (PageDirty(page))
1306 dec_page_count(sbi, F2FS_DIRTY_NODES); 1298 dec_page_count(F2FS_I_SB(inode), F2FS_DIRTY_NODES);
1307 ClearPagePrivate(page); 1299 ClearPagePrivate(page);
1308} 1300}
1309 1301
@@ -1551,13 +1543,12 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
1551 1543
1552void recover_inline_xattr(struct inode *inode, struct page *page) 1544void recover_inline_xattr(struct inode *inode, struct page *page)
1553{ 1545{
1554 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
1555 void *src_addr, *dst_addr; 1546 void *src_addr, *dst_addr;
1556 size_t inline_size; 1547 size_t inline_size;
1557 struct page *ipage; 1548 struct page *ipage;
1558 struct f2fs_inode *ri; 1549 struct f2fs_inode *ri;
1559 1550
1560 ipage = get_node_page(sbi, inode->i_ino); 1551 ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
1561 f2fs_bug_on(IS_ERR(ipage)); 1552 f2fs_bug_on(IS_ERR(ipage));
1562 1553
1563 ri = F2FS_INODE(page); 1554 ri = F2FS_INODE(page);
@@ -1579,7 +1570,7 @@ update_inode:
1579 1570
1580void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) 1571void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr)
1581{ 1572{
1582 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 1573 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
1583 nid_t prev_xnid = F2FS_I(inode)->i_xattr_nid; 1574 nid_t prev_xnid = F2FS_I(inode)->i_xattr_nid;
1584 nid_t new_xnid = nid_of_node(page); 1575 nid_t new_xnid = nid_of_node(page);
1585 struct node_info ni; 1576 struct node_info ni;
diff --git a/fs/f2fs/node.h b/fs/f2fs/node.h
index 8a116a407599..b24f588a0fe4 100644
--- a/fs/f2fs/node.h
+++ b/fs/f2fs/node.h
@@ -197,8 +197,7 @@ static inline void copy_node_footer(struct page *dst, struct page *src)
197 197
198static inline void fill_node_footer_blkaddr(struct page *page, block_t blkaddr) 198static inline void fill_node_footer_blkaddr(struct page *page, block_t blkaddr)
199{ 199{
200 struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); 200 struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
201 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
202 struct f2fs_node *rn = F2FS_NODE(page); 201 struct f2fs_node *rn = F2FS_NODE(page);
203 202
204 rn->footer.cp_ver = ckpt->checkpoint_ver; 203 rn->footer.cp_ver = ckpt->checkpoint_ver;
diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 756c41cd2582..5c095f7ac21c 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -75,7 +75,7 @@ retry:
75 err = -EEXIST; 75 err = -EEXIST;
76 goto out_unmap_put; 76 goto out_unmap_put;
77 } 77 }
78 err = acquire_orphan_inode(F2FS_SB(inode->i_sb)); 78 err = acquire_orphan_inode(F2FS_I_SB(inode));
79 if (err) { 79 if (err) {
80 iput(einode); 80 iput(einode);
81 goto out_unmap_put; 81 goto out_unmap_put;
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0aa337cd5bba..a270726e3367 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -953,15 +953,14 @@ static int __get_segment_type_6(struct page *page, enum page_type p_type)
953 953
954static int __get_segment_type(struct page *page, enum page_type p_type) 954static int __get_segment_type(struct page *page, enum page_type p_type)
955{ 955{
956 struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb); 956 switch (F2FS_P_SB(page)->active_logs) {
957 switch (sbi->active_logs) {
958 case 2: 957 case 2:
959 return __get_segment_type_2(page, p_type); 958 return __get_segment_type_2(page, p_type);
960 case 4: 959 case 4:
961 return __get_segment_type_4(page, p_type); 960 return __get_segment_type_4(page, p_type);
962 } 961 }
963 /* NR_CURSEG_TYPE(6) logs by default */ 962 /* NR_CURSEG_TYPE(6) logs by default */
964 f2fs_bug_on(sbi->active_logs != NR_CURSEG_TYPE); 963 f2fs_bug_on(F2FS_P_SB(page)->active_logs != NR_CURSEG_TYPE);
965 return __get_segment_type_6(page, p_type); 964 return __get_segment_type_6(page, p_type);
966} 965}
967 966
@@ -1041,7 +1040,7 @@ void write_node_page(struct f2fs_sb_info *sbi, struct page *page,
1041void write_data_page(struct page *page, struct dnode_of_data *dn, 1040void write_data_page(struct page *page, struct dnode_of_data *dn,
1042 block_t *new_blkaddr, struct f2fs_io_info *fio) 1041 block_t *new_blkaddr, struct f2fs_io_info *fio)
1043{ 1042{
1044 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 1043 struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
1045 struct f2fs_summary sum; 1044 struct f2fs_summary sum;
1046 struct node_info ni; 1045 struct node_info ni;
1047 1046
@@ -1055,9 +1054,7 @@ void write_data_page(struct page *page, struct dnode_of_data *dn,
1055void rewrite_data_page(struct page *page, block_t old_blkaddr, 1054void rewrite_data_page(struct page *page, block_t old_blkaddr,
1056 struct f2fs_io_info *fio) 1055 struct f2fs_io_info *fio)
1057{ 1056{
1058 struct inode *inode = page->mapping->host; 1057 f2fs_submit_page_mbio(F2FS_P_SB(page), page, old_blkaddr, fio);
1059 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
1060 f2fs_submit_page_mbio(sbi, page, old_blkaddr, fio);
1061} 1058}
1062 1059
1063void recover_data_page(struct f2fs_sb_info *sbi, 1060void recover_data_page(struct f2fs_sb_info *sbi,
@@ -1130,8 +1127,9 @@ out:
1130void f2fs_wait_on_page_writeback(struct page *page, 1127void f2fs_wait_on_page_writeback(struct page *page,
1131 enum page_type type) 1128 enum page_type type)
1132{ 1129{
1133 struct f2fs_sb_info *sbi = F2FS_SB(page->mapping->host->i_sb);
1134 if (PageWriteback(page)) { 1130 if (PageWriteback(page)) {
1131 struct f2fs_sb_info *sbi = F2FS_P_SB(page);
1132
1135 if (is_merged_page(sbi, page, type)) 1133 if (is_merged_page(sbi, page, type))
1136 f2fs_submit_merged_bio(sbi, type, WRITE); 1134 f2fs_submit_merged_bio(sbi, type, WRITE);
1137 wait_on_page_writeback(page); 1135 wait_on_page_writeback(page);
diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h
index ff483257283b..793ca27b9c88 100644
--- a/fs/f2fs/segment.h
+++ b/fs/f2fs/segment.h
@@ -480,7 +480,7 @@ enum {
480 480
481static inline bool need_inplace_update(struct inode *inode) 481static inline bool need_inplace_update(struct inode *inode)
482{ 482{
483 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 483 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
484 484
485 /* IPU can be done only for the user data */ 485 /* IPU can be done only for the user data */
486 if (S_ISDIR(inode->i_mode)) 486 if (S_ISDIR(inode->i_mode))
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 728a5dc3dc16..d92a47da62b8 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -266,7 +266,7 @@ static struct f2fs_xattr_entry *__find_xattr(void *base_addr, int index,
266 266
267static void *read_all_xattrs(struct inode *inode, struct page *ipage) 267static void *read_all_xattrs(struct inode *inode, struct page *ipage)
268{ 268{
269 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 269 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
270 struct f2fs_xattr_header *header; 270 struct f2fs_xattr_header *header;
271 size_t size = PAGE_SIZE, inline_size = 0; 271 size_t size = PAGE_SIZE, inline_size = 0;
272 void *txattr_addr; 272 void *txattr_addr;
@@ -325,7 +325,7 @@ fail:
325static inline int write_all_xattrs(struct inode *inode, __u32 hsize, 325static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
326 void *txattr_addr, struct page *ipage) 326 void *txattr_addr, struct page *ipage)
327{ 327{
328 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 328 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
329 size_t inline_size = 0; 329 size_t inline_size = 0;
330 void *xattr_addr; 330 void *xattr_addr;
331 struct page *xpage; 331 struct page *xpage;
@@ -596,7 +596,7 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
596 const void *value, size_t size, 596 const void *value, size_t size,
597 struct page *ipage, int flags) 597 struct page *ipage, int flags)
598{ 598{
599 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 599 struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
600 int err; 600 int err;
601 601
602 /* this case is only from init_inode_metadata */ 602 /* this case is only from init_inode_metadata */