diff options
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index daee4ab913da..f939660941bb 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
@@ -205,6 +205,8 @@ retry: | |||
205 | list_add_tail(&new->list, &fi->inmem_pages); | 205 | list_add_tail(&new->list, &fi->inmem_pages); |
206 | inc_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES); | 206 | inc_page_count(F2FS_I_SB(inode), F2FS_INMEM_PAGES); |
207 | mutex_unlock(&fi->inmem_lock); | 207 | mutex_unlock(&fi->inmem_lock); |
208 | |||
209 | trace_f2fs_register_inmem_page(page, INMEM); | ||
208 | } | 210 | } |
209 | 211 | ||
210 | void commit_inmem_pages(struct inode *inode, bool abort) | 212 | void commit_inmem_pages(struct inode *inode, bool abort) |
@@ -238,11 +240,13 @@ void commit_inmem_pages(struct inode *inode, bool abort) | |||
238 | f2fs_wait_on_page_writeback(cur->page, DATA); | 240 | f2fs_wait_on_page_writeback(cur->page, DATA); |
239 | if (clear_page_dirty_for_io(cur->page)) | 241 | if (clear_page_dirty_for_io(cur->page)) |
240 | inode_dec_dirty_pages(inode); | 242 | inode_dec_dirty_pages(inode); |
243 | trace_f2fs_commit_inmem_page(cur->page, INMEM); | ||
241 | do_write_data_page(cur->page, &fio); | 244 | do_write_data_page(cur->page, &fio); |
242 | submit_bio = true; | 245 | submit_bio = true; |
243 | } | 246 | } |
244 | f2fs_put_page(cur->page, 1); | 247 | f2fs_put_page(cur->page, 1); |
245 | } else { | 248 | } else { |
249 | trace_f2fs_commit_inmem_page(cur->page, INMEM_DROP); | ||
246 | put_page(cur->page); | 250 | put_page(cur->page); |
247 | } | 251 | } |
248 | radix_tree_delete(&fi->inmem_root, cur->page->index); | 252 | radix_tree_delete(&fi->inmem_root, cur->page->index); |
@@ -277,6 +281,9 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi) | |||
277 | 281 | ||
278 | void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) | 282 | void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) |
279 | { | 283 | { |
284 | /* try to shrink extent cache when there is no enough memory */ | ||
285 | f2fs_shrink_extent_tree(sbi, EXTENT_CACHE_SHRINK_NUMBER); | ||
286 | |||
280 | /* check the # of cached NAT entries and prefree segments */ | 287 | /* check the # of cached NAT entries and prefree segments */ |
281 | if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || | 288 | if (try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK) || |
282 | excess_prefree_segs(sbi) || | 289 | excess_prefree_segs(sbi) || |
@@ -549,7 +556,7 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
549 | 556 | ||
550 | end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1); | 557 | end = __find_rev_next_zero_bit(dmap, max_blocks, start + 1); |
551 | 558 | ||
552 | if (end - start < cpc->trim_minlen) | 559 | if (force && end - start < cpc->trim_minlen) |
553 | continue; | 560 | continue; |
554 | 561 | ||
555 | __add_discard_entry(sbi, cpc, start, end); | 562 | __add_discard_entry(sbi, cpc, start, end); |
@@ -1164,6 +1171,7 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, | |||
1164 | curseg = CURSEG_I(sbi, type); | 1171 | curseg = CURSEG_I(sbi, type); |
1165 | 1172 | ||
1166 | mutex_lock(&curseg->curseg_mutex); | 1173 | mutex_lock(&curseg->curseg_mutex); |
1174 | mutex_lock(&sit_i->sentry_lock); | ||
1167 | 1175 | ||
1168 | /* direct_io'ed data is aligned to the segment for better performance */ | 1176 | /* direct_io'ed data is aligned to the segment for better performance */ |
1169 | if (direct_io && curseg->next_blkoff) | 1177 | if (direct_io && curseg->next_blkoff) |
@@ -1178,7 +1186,6 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, | |||
1178 | */ | 1186 | */ |
1179 | __add_sum_entry(sbi, type, sum); | 1187 | __add_sum_entry(sbi, type, sum); |
1180 | 1188 | ||
1181 | mutex_lock(&sit_i->sentry_lock); | ||
1182 | __refresh_next_blkoff(sbi, curseg); | 1189 | __refresh_next_blkoff(sbi, curseg); |
1183 | 1190 | ||
1184 | stat_inc_block_count(sbi, curseg); | 1191 | stat_inc_block_count(sbi, curseg); |
@@ -1730,6 +1737,9 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
1730 | mutex_lock(&curseg->curseg_mutex); | 1737 | mutex_lock(&curseg->curseg_mutex); |
1731 | mutex_lock(&sit_i->sentry_lock); | 1738 | mutex_lock(&sit_i->sentry_lock); |
1732 | 1739 | ||
1740 | if (!sit_i->dirty_sentries) | ||
1741 | goto out; | ||
1742 | |||
1733 | /* | 1743 | /* |
1734 | * add and account sit entries of dirty bitmap in sit entry | 1744 | * add and account sit entries of dirty bitmap in sit entry |
1735 | * set temporarily | 1745 | * set temporarily |
@@ -1744,9 +1754,6 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) | |||
1744 | if (!__has_cursum_space(sum, sit_i->dirty_sentries, SIT_JOURNAL)) | 1754 | if (!__has_cursum_space(sum, sit_i->dirty_sentries, SIT_JOURNAL)) |
1745 | remove_sits_in_journal(sbi); | 1755 | remove_sits_in_journal(sbi); |
1746 | 1756 | ||
1747 | if (!sit_i->dirty_sentries) | ||
1748 | goto out; | ||
1749 | |||
1750 | /* | 1757 | /* |
1751 | * there are two steps to flush sit entries: | 1758 | * there are two steps to flush sit entries: |
1752 | * #1, flush sit entries to journal in current cold data summary block. | 1759 | * #1, flush sit entries to journal in current cold data summary block. |