f2fs: treat volatile file's data as hot one
authorChao Yu <yuchao0@huawei.com>
Thu, 26 Apr 2018 09:05:50 +0000 (17:05 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 31 May 2018 18:31:49 +0000 (11:31 -0700)
Volatile file's data will be updated oftenly, so it'd better to place
its data into hot data segment.

In addition, for atomic file, we change to check FI_ATOMIC_FILE instead
of FI_HOT_DATA to make code readability better.

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

index 8af352c3239d9c845c4f19d5cf5110e670db9a43..26b32108b09b9cb02359a301e97b05805853dff3 100644 (file)
@@ -1696,7 +1696,6 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
        if (ret)
                goto out;
 skip_flush:
-       set_inode_flag(inode, FI_HOT_DATA);
        set_inode_flag(inode, FI_ATOMIC_FILE);
        f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
 
@@ -1739,7 +1738,6 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
                ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
                if (!ret) {
                        clear_inode_flag(inode, FI_ATOMIC_FILE);
-                       clear_inode_flag(inode, FI_HOT_DATA);
                        stat_dec_atomic_write(inode);
                }
        } else {
index 916b16e768fb6a7679b0b49bff305fb8fd717f50..9937265a63c5f8eafbfb97a92bc82036e8c4f544 100644 (file)
@@ -309,7 +309,6 @@ void drop_inmem_pages(struct inode *inode)
        mutex_unlock(&fi->inmem_lock);
 
        clear_inode_flag(inode, FI_ATOMIC_FILE);
-       clear_inode_flag(inode, FI_HOT_DATA);
        stat_dec_atomic_write(inode);
 }
 
@@ -2613,7 +2612,9 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
                if (is_cold_data(fio->page) || file_is_cold(inode))
                        return CURSEG_COLD_DATA;
                if (file_is_hot(inode) ||
-                               is_inode_flag_set(inode, FI_HOT_DATA))
+                               is_inode_flag_set(inode, FI_HOT_DATA) ||
+                               is_inode_flag_set(inode, FI_ATOMIC_FILE) ||
+                               is_inode_flag_set(inode, FI_VOLATILE_FILE))
                        return CURSEG_HOT_DATA;
                return rw_hint_to_seg_type(inode->i_write_hint);
        } else {