aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/f2fs/checkpoint.c2
-rw-r--r--fs/f2fs/debug.c4
-rw-r--r--fs/f2fs/f2fs.h5
-rw-r--r--fs/f2fs/node.c50
4 files changed, 30 insertions, 31 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index ed82de6bfb47..293d0486a40f 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -771,7 +771,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, bool is_umount)
771 /* wait for previous submitted node/meta pages writeback */ 771 /* wait for previous submitted node/meta pages writeback */
772 wait_on_all_pages_writeback(sbi); 772 wait_on_all_pages_writeback(sbi);
773 773
774 filemap_fdatawait_range(sbi->node_inode->i_mapping, 0, LONG_MAX); 774 filemap_fdatawait_range(NODE_MAPPING(sbi), 0, LONG_MAX);
775 filemap_fdatawait_range(META_MAPPING(sbi), 0, LONG_MAX); 775 filemap_fdatawait_range(META_MAPPING(sbi), 0, LONG_MAX);
776 776
777 /* update user_block_counts */ 777 /* update user_block_counts */
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index 8bdc365be9e3..3de9d20d0c14 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -52,7 +52,7 @@ static void update_general_status(struct f2fs_sb_info *sbi)
52 si->free_secs = free_sections(sbi); 52 si->free_secs = free_sections(sbi);
53 si->prefree_count = prefree_segments(sbi); 53 si->prefree_count = prefree_segments(sbi);
54 si->dirty_count = dirty_segments(sbi); 54 si->dirty_count = dirty_segments(sbi);
55 si->node_pages = sbi->node_inode->i_mapping->nrpages; 55 si->node_pages = NODE_MAPPING(sbi)->nrpages;
56 si->meta_pages = META_MAPPING(sbi)->nrpages; 56 si->meta_pages = META_MAPPING(sbi)->nrpages;
57 si->nats = NM_I(sbi)->nat_cnt; 57 si->nats = NM_I(sbi)->nat_cnt;
58 si->sits = SIT_I(sbi)->dirty_sentries; 58 si->sits = SIT_I(sbi)->dirty_sentries;
@@ -166,7 +166,7 @@ get_cache:
166 /* free nids */ 166 /* free nids */
167 si->cache_mem = NM_I(sbi)->fcnt; 167 si->cache_mem = NM_I(sbi)->fcnt;
168 si->cache_mem += NM_I(sbi)->nat_cnt; 168 si->cache_mem += NM_I(sbi)->nat_cnt;
169 npages = sbi->node_inode->i_mapping->nrpages; 169 npages = NODE_MAPPING(sbi)->nrpages;
170 si->cache_mem += npages << PAGE_CACHE_SHIFT; 170 si->cache_mem += npages << PAGE_CACHE_SHIFT;
171 npages = META_MAPPING(sbi)->nrpages; 171 npages = META_MAPPING(sbi)->nrpages;
172 si->cache_mem += npages << PAGE_CACHE_SHIFT; 172 si->cache_mem += npages << PAGE_CACHE_SHIFT;
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 117e30f6b88c..af51a0bd2dee 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -538,6 +538,11 @@ static inline struct address_space *META_MAPPING(struct f2fs_sb_info *sbi)
538 return sbi->meta_inode->i_mapping; 538 return sbi->meta_inode->i_mapping;
539} 539}
540 540
541static inline struct address_space *NODE_MAPPING(struct f2fs_sb_info *sbi)
542{
543 return sbi->node_inode->i_mapping;
544}
545
541static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi) 546static inline void F2FS_SET_SB_DIRT(struct f2fs_sb_info *sbi)
542{ 547{
543 sbi->s_dirty = 1; 548 sbi->s_dirty = 1;
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 527bd12d8ae1..bbfc655493dc 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -681,7 +681,6 @@ fail:
681int truncate_inode_blocks(struct inode *inode, pgoff_t from) 681int truncate_inode_blocks(struct inode *inode, pgoff_t from)
682{ 682{
683 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); 683 struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb);
684 struct address_space *node_mapping = sbi->node_inode->i_mapping;
685 int err = 0, cont = 1; 684 int err = 0, cont = 1;
686 int level, offset[4], noffset[4]; 685 int level, offset[4], noffset[4];
687 unsigned int nofs = 0; 686 unsigned int nofs = 0;
@@ -756,7 +755,7 @@ skip_partial:
756 if (offset[1] == 0 && 755 if (offset[1] == 0 &&
757 ri->i_nid[offset[0] - NODE_DIR1_BLOCK]) { 756 ri->i_nid[offset[0] - NODE_DIR1_BLOCK]) {
758 lock_page(page); 757 lock_page(page);
759 if (unlikely(page->mapping != node_mapping)) { 758 if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
760 f2fs_put_page(page, 1); 759 f2fs_put_page(page, 1);
761 goto restart; 760 goto restart;
762 } 761 }
@@ -842,7 +841,6 @@ struct page *new_node_page(struct dnode_of_data *dn,
842 unsigned int ofs, struct page *ipage) 841 unsigned int ofs, struct page *ipage)
843{ 842{
844 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb); 843 struct f2fs_sb_info *sbi = F2FS_SB(dn->inode->i_sb);
845 struct address_space *mapping = sbi->node_inode->i_mapping;
846 struct node_info old_ni, new_ni; 844 struct node_info old_ni, new_ni;
847 struct page *page; 845 struct page *page;
848 int err; 846 int err;
@@ -850,7 +848,7 @@ struct page *new_node_page(struct dnode_of_data *dn,
850 if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC))) 848 if (unlikely(is_inode_flag_set(F2FS_I(dn->inode), FI_NO_ALLOC)))
851 return ERR_PTR(-EPERM); 849 return ERR_PTR(-EPERM);
852 850
853 page = grab_cache_page(mapping, dn->nid); 851 page = grab_cache_page(NODE_MAPPING(sbi), dn->nid);
854 if (!page) 852 if (!page)
855 return ERR_PTR(-ENOMEM); 853 return ERR_PTR(-ENOMEM);
856 854
@@ -920,18 +918,17 @@ static int read_node_page(struct page *page, int rw)
920 */ 918 */
921void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid) 919void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
922{ 920{
923 struct address_space *mapping = sbi->node_inode->i_mapping;
924 struct page *apage; 921 struct page *apage;
925 int err; 922 int err;
926 923
927 apage = find_get_page(mapping, nid); 924 apage = find_get_page(NODE_MAPPING(sbi), nid);
928 if (apage && PageUptodate(apage)) { 925 if (apage && PageUptodate(apage)) {
929 f2fs_put_page(apage, 0); 926 f2fs_put_page(apage, 0);
930 return; 927 return;
931 } 928 }
932 f2fs_put_page(apage, 0); 929 f2fs_put_page(apage, 0);
933 930
934 apage = grab_cache_page(mapping, nid); 931 apage = grab_cache_page(NODE_MAPPING(sbi), nid);
935 if (!apage) 932 if (!apage)
936 return; 933 return;
937 934
@@ -944,11 +941,10 @@ void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
944 941
945struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid) 942struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
946{ 943{
947 struct address_space *mapping = sbi->node_inode->i_mapping;
948 struct page *page; 944 struct page *page;
949 int err; 945 int err;
950repeat: 946repeat:
951 page = grab_cache_page(mapping, nid); 947 page = grab_cache_page(NODE_MAPPING(sbi), nid);
952 if (!page) 948 if (!page)
953 return ERR_PTR(-ENOMEM); 949 return ERR_PTR(-ENOMEM);
954 950
@@ -963,7 +959,7 @@ repeat:
963 f2fs_put_page(page, 1); 959 f2fs_put_page(page, 1);
964 return ERR_PTR(-EIO); 960 return ERR_PTR(-EIO);
965 } 961 }
966 if (unlikely(page->mapping != mapping)) { 962 if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
967 f2fs_put_page(page, 1); 963 f2fs_put_page(page, 1);
968 goto repeat; 964 goto repeat;
969 } 965 }
@@ -980,7 +976,6 @@ got_it:
980struct page *get_node_page_ra(struct page *parent, int start) 976struct page *get_node_page_ra(struct page *parent, int start)
981{ 977{
982 struct f2fs_sb_info *sbi = F2FS_SB(parent->mapping->host->i_sb); 978 struct f2fs_sb_info *sbi = F2FS_SB(parent->mapping->host->i_sb);
983 struct address_space *mapping = sbi->node_inode->i_mapping;
984 struct blk_plug plug; 979 struct blk_plug plug;
985 struct page *page; 980 struct page *page;
986 int err, i, end; 981 int err, i, end;
@@ -991,7 +986,7 @@ struct page *get_node_page_ra(struct page *parent, int start)
991 if (!nid) 986 if (!nid)
992 return ERR_PTR(-ENOENT); 987 return ERR_PTR(-ENOENT);
993repeat: 988repeat:
994 page = grab_cache_page(mapping, nid); 989 page = grab_cache_page(NODE_MAPPING(sbi), nid);
995 if (!page) 990 if (!page)
996 return ERR_PTR(-ENOMEM); 991 return ERR_PTR(-ENOMEM);
997 992
@@ -1016,7 +1011,7 @@ repeat:
1016 blk_finish_plug(&plug); 1011 blk_finish_plug(&plug);
1017 1012
1018 lock_page(page); 1013 lock_page(page);
1019 if (unlikely(page->mapping != mapping)) { 1014 if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
1020 f2fs_put_page(page, 1); 1015 f2fs_put_page(page, 1);
1021 goto repeat; 1016 goto repeat;
1022 } 1017 }
@@ -1047,7 +1042,6 @@ void sync_inode_page(struct dnode_of_data *dn)
1047int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino, 1042int sync_node_pages(struct f2fs_sb_info *sbi, nid_t ino,
1048 struct writeback_control *wbc) 1043 struct writeback_control *wbc)
1049{ 1044{
1050 struct address_space *mapping = sbi->node_inode->i_mapping;
1051 pgoff_t index, end; 1045 pgoff_t index, end;
1052 struct pagevec pvec; 1046 struct pagevec pvec;
1053 int step = ino ? 2 : 0; 1047 int step = ino ? 2 : 0;
@@ -1061,7 +1055,7 @@ next_step:
1061 1055
1062 while (index <= end) { 1056 while (index <= end) {
1063 int i, nr_pages; 1057 int i, nr_pages;
1064 nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, 1058 nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
1065 PAGECACHE_TAG_DIRTY, 1059 PAGECACHE_TAG_DIRTY,
1066 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1); 1060 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
1067 if (nr_pages == 0) 1061 if (nr_pages == 0)
@@ -1094,7 +1088,7 @@ next_step:
1094 else if (!trylock_page(page)) 1088 else if (!trylock_page(page))
1095 continue; 1089 continue;
1096 1090
1097 if (unlikely(page->mapping != mapping)) { 1091 if (unlikely(page->mapping != NODE_MAPPING(sbi))) {
1098continue_unlock: 1092continue_unlock:
1099 unlock_page(page); 1093 unlock_page(page);
1100 continue; 1094 continue;
@@ -1121,7 +1115,7 @@ continue_unlock:
1121 set_fsync_mark(page, 0); 1115 set_fsync_mark(page, 0);
1122 set_dentry_mark(page, 0); 1116 set_dentry_mark(page, 0);
1123 } 1117 }
1124 mapping->a_ops->writepage(page, wbc); 1118 NODE_MAPPING(sbi)->a_ops->writepage(page, wbc);
1125 wrote++; 1119 wrote++;
1126 1120
1127 if (--wbc->nr_to_write == 0) 1121 if (--wbc->nr_to_write == 0)
@@ -1148,18 +1142,19 @@ continue_unlock:
1148 1142
1149int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino) 1143int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
1150{ 1144{
1151 struct address_space *mapping = sbi->node_inode->i_mapping;
1152 pgoff_t index = 0, end = LONG_MAX; 1145 pgoff_t index = 0, end = LONG_MAX;
1153 struct pagevec pvec; 1146 struct pagevec pvec;
1154 int nr_pages;
1155 int ret2 = 0, ret = 0; 1147 int ret2 = 0, ret = 0;
1156 1148
1157 pagevec_init(&pvec, 0); 1149 pagevec_init(&pvec, 0);
1158 while ((index <= end) && 1150
1159 (nr_pages = pagevec_lookup_tag(&pvec, mapping, &index, 1151 while (index <= end) {
1160 PAGECACHE_TAG_WRITEBACK, 1152 int i, nr_pages;
1161 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1)) != 0) { 1153 nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
1162 unsigned i; 1154 PAGECACHE_TAG_WRITEBACK,
1155 min(end - index, (pgoff_t)PAGEVEC_SIZE-1) + 1);
1156 if (nr_pages == 0)
1157 break;
1163 1158
1164 for (i = 0; i < nr_pages; i++) { 1159 for (i = 0; i < nr_pages; i++) {
1165 struct page *page = pvec.pages[i]; 1160 struct page *page = pvec.pages[i];
@@ -1178,9 +1173,9 @@ int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
1178 cond_resched(); 1173 cond_resched();
1179 } 1174 }
1180 1175
1181 if (unlikely(test_and_clear_bit(AS_ENOSPC, &mapping->flags))) 1176 if (unlikely(test_and_clear_bit(AS_ENOSPC, &NODE_MAPPING(sbi)->flags)))
1182 ret2 = -ENOSPC; 1177 ret2 = -ENOSPC;
1183 if (unlikely(test_and_clear_bit(AS_EIO, &mapping->flags))) 1178 if (unlikely(test_and_clear_bit(AS_EIO, &NODE_MAPPING(sbi)->flags)))
1184 ret2 = -EIO; 1179 ret2 = -EIO;
1185 if (!ret) 1180 if (!ret)
1186 ret = ret2; 1181 ret = ret2;
@@ -1538,13 +1533,12 @@ void recover_node_page(struct f2fs_sb_info *sbi, struct page *page,
1538 1533
1539int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) 1534int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
1540{ 1535{
1541 struct address_space *mapping = sbi->node_inode->i_mapping;
1542 struct f2fs_inode *src, *dst; 1536 struct f2fs_inode *src, *dst;
1543 nid_t ino = ino_of_node(page); 1537 nid_t ino = ino_of_node(page);
1544 struct node_info old_ni, new_ni; 1538 struct node_info old_ni, new_ni;
1545 struct page *ipage; 1539 struct page *ipage;
1546 1540
1547 ipage = grab_cache_page(mapping, ino); 1541 ipage = grab_cache_page(NODE_MAPPING(sbi), ino);
1548 if (!ipage) 1542 if (!ipage)
1549 return -ENOMEM; 1543 return -ENOMEM;
1550 1544