f2fs: give a chance to detach from dirty list
authorChao Yu <yuchao0@huawei.com>
Tue, 11 Oct 2016 14:57:01 +0000 (22:57 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 23 Nov 2016 20:10:51 +0000 (12:10 -0800)
If there is no dirty pages in inode, we should give a chance to detach
the inode from global dirty list, otherwise it needs to call another
unnecessary .writepages for detaching.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c
fs/f2fs/dir.c
fs/f2fs/gc.c
fs/f2fs/inline.c
fs/f2fs/node.c
fs/f2fs/segment.c

index 9ae194fd2fdb81cbc54bfed9220da527d6b21a89..b2289dfab9a231edf8be4bcdddc426213f4f63b8 100644 (file)
@@ -1785,12 +1785,14 @@ void f2fs_invalidate_page(struct page *page, unsigned int offset,
                return;
 
        if (PageDirty(page)) {
-               if (inode->i_ino == F2FS_META_INO(sbi))
+               if (inode->i_ino == F2FS_META_INO(sbi)) {
                        dec_page_count(sbi, F2FS_DIRTY_META);
-               else if (inode->i_ino == F2FS_NODE_INO(sbi))
+               } else if (inode->i_ino == F2FS_NODE_INO(sbi)) {
                        dec_page_count(sbi, F2FS_DIRTY_NODES);
-               else
+               } else {
                        inode_dec_dirty_pages(inode);
+                       remove_dirty_inode(inode);
+               }
        }
 
        /* This is atomic written page, keep Private */
index 369f4513be37f8cfeb534e6fd247203c620a96a6..4df6168f43de60ef6e6644546dc1aa2917ade431 100644 (file)
@@ -742,6 +742,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
                ClearPagePrivate(page);
                ClearPageUptodate(page);
                inode_dec_dirty_pages(dir);
+               remove_dirty_inode(dir);
        }
        f2fs_put_page(page, 1);
 }
index 6f14ee923acd2b4cf75f93bed945f6fc04b79c93..9c189171b89c7a1a53797ff7d278ea6ef14184fc 100644 (file)
@@ -673,8 +673,10 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type)
 retry:
                set_page_dirty(page);
                f2fs_wait_on_page_writeback(page, DATA, true);
-               if (clear_page_dirty_for_io(page))
+               if (clear_page_dirty_for_io(page)) {
                        inode_dec_dirty_pages(inode);
+                       remove_dirty_inode(inode);
+               }
 
                set_cold_data(page);
 
index 5f1a67f756afc449283d91c276fbce899fc360cb..210b2dc795356cc6b966801adcb0317cf8279ccd 100644 (file)
@@ -137,8 +137,10 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
        fio.old_blkaddr = dn->data_blkaddr;
        write_data_page(dn, &fio);
        f2fs_wait_on_page_writeback(page, DATA, true);
-       if (dirty)
+       if (dirty) {
                inode_dec_dirty_pages(dn->inode);
+               remove_dirty_inode(dn->inode);
+       }
 
        /* this converted inline_data should be recovered. */
        set_inode_flag(dn->inode, FI_APPEND_WRITE);
index f12de4589856dde10895f5e21de616191c51589c..e5236463781a1c4f4fab40e455c961862fa810bf 100644 (file)
@@ -1204,6 +1204,7 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
 
        ret = f2fs_write_inline_data(inode, page);
        inode_dec_dirty_pages(inode);
+       remove_dirty_inode(inode);
        if (ret)
                set_page_dirty(page);
 page_out:
index fc886f0084495e84234d49edd10d55422c7cb854..f7e73b2afe68169ae33dac522392caf24d821705 100644 (file)
@@ -274,8 +274,10 @@ static int __commit_inmem_pages(struct inode *inode,
 
                        set_page_dirty(page);
                        f2fs_wait_on_page_writeback(page, DATA, true);
-                       if (clear_page_dirty_for_io(page))
+                       if (clear_page_dirty_for_io(page)) {
                                inode_dec_dirty_pages(inode);
+                               remove_dirty_inode(inode);
+                       }
 
                        fio.page = page;
                        err = do_write_data_page(&fio);