f2fs: expand counting dirty pages in the inode page cache
[deliverable/linux.git] / fs / f2fs / gc.c
index d7947d90ccc3df487919723578bf5f81dde2d8a6..dca7818c06627a03a2cc45c13c41b0b3a1c4fece 100644 (file)
@@ -58,7 +58,7 @@ static int gc_thread_func(void *data)
                 * 3. IO subsystem is idle by checking the # of requests in
                 *    bdev's request list.
                 *
-                * Note) We have to avoid triggering GCs too much frequently.
+                * Note) We have to avoid triggering GCs frequently.
                 * Because it is possible that some segments can be
                 * invalidated soon after by user update or deletion.
                 * So, I'd like to wait some time to collect dirty segments.
@@ -222,7 +222,7 @@ static unsigned int get_cb_cost(struct f2fs_sb_info *sbi, unsigned int segno)
 
        u = (vblocks * 100) >> sbi->log_blocks_per_seg;
 
-       /* Handle if the system time is changed by user */
+       /* Handle if the system time has changed by the user */
        if (mtime < sit_i->min_mtime)
                sit_i->min_mtime = mtime;
        if (mtime > sit_i->max_mtime)
@@ -423,6 +423,12 @@ next_step:
                if (IS_ERR(node_page))
                        continue;
 
+               /* block may become invalid during get_node_page */
+               if (check_valid_map(sbi, segno, off) == 0) {
+                       f2fs_put_page(node_page, 1);
+                       continue;
+               }
+
                /* set page dirty and write it */
                if (gc_type == FG_GC) {
                        f2fs_wait_on_page_writeback(node_page, NODE);
@@ -531,7 +537,7 @@ static void move_data_page(struct inode *inode, struct page *page, int gc_type)
                f2fs_wait_on_page_writeback(page, DATA);
 
                if (clear_page_dirty_for_io(page))
-                       inode_dec_dirty_dents(inode);
+                       inode_dec_dirty_pages(inode);
                set_cold_data(page);
                do_write_data_page(page, &fio);
                clear_cold_data(page);
@@ -593,7 +599,7 @@ next_step:
 
                if (phase == 2) {
                        inode = f2fs_iget(sb, dni.ino);
-                       if (IS_ERR(inode))
+                       if (IS_ERR(inode) || is_bad_inode(inode))
                                continue;
 
                        start_bidx = start_bidx_of_node(nofs, F2FS_I(inode));
@@ -693,7 +699,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi)
 gc_more:
        if (unlikely(!(sbi->sb->s_flags & MS_ACTIVE)))
                goto stop;
-       if (unlikely(is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ERROR_FLAG)))
+       if (unlikely(f2fs_cp_error(sbi)))
                goto stop;
 
        if (gc_type == BG_GC && has_not_enough_free_secs(sbi, nfree)) {
This page took 0.025548 seconds and 5 git commands to generate.