f2fs: introduce async IPU policy
authorHou Pengyang <houpengyang@huawei.com>
Tue, 18 Apr 2017 11:57:16 +0000 (11:57 +0000)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 19 Apr 2017 18:00:46 +0000 (11:00 -0700)
This patch introduces an ASYNC IPU policy.

Under senario of large # of async updating(e.g. log writing in Android),
disk would be seriously fragmented, and higher frequent gc would be triggered.

This patch uses IPU to rewrite the async update writting, since async is
NOT sensitive to io latency.

Signed-off-by: Hou Pengyang <houpengyang@huawei.com>
fs/f2fs/data.c
fs/f2fs/file.c
fs/f2fs/segment.h

index 32d5a3b38a3f113c5995ba14b923286ed2f434dc..7d46a8e6d35019ee649eeb0103734107d307efc0 100644 (file)
@@ -1356,7 +1356,7 @@ retry_encrypt:
        if (unlikely(fio->old_blkaddr != NEW_ADDR &&
                        !is_cold_data(page) &&
                        !IS_ATOMIC_WRITTEN_PAGE(page) &&
-                       need_inplace_update(inode))) {
+                       need_inplace_update(inode, fio))) {
                f2fs_unlock_op(F2FS_I_SB(inode));
                fio->cp_rwsem_locked = false;
                err = rewrite_data_page(fio);
index 0ac833dd263401eebb159c0c46cdb9954013d2c4..0ccc8cf70e7a40873d338ed326656844367b1af1 100644 (file)
@@ -1898,7 +1898,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
        int err;
 
        /* if in-place-update policy is enabled, don't waste time here */
-       if (need_inplace_update(inode))
+       if (need_inplace_update(inode, NULL))
                return -EINVAL;
 
        pg_start = range->start >> PAGE_SHIFT;
index 5f6ef163aa8f34409b8737356d84914cbb6ea1fd..3cd780a42f516f50969d695511bf621069d2b96c 100644 (file)
@@ -556,9 +556,11 @@ enum {
        F2FS_IPU_UTIL,
        F2FS_IPU_SSR_UTIL,
        F2FS_IPU_FSYNC,
+       F2FS_IPU_ASYNC,
 };
 
-static inline bool need_inplace_update(struct inode *inode)
+static inline bool need_inplace_update(struct inode *inode,
+                               struct f2fs_io_info *fio)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        unsigned int policy = SM_I(sbi)->ipu_policy;
@@ -581,6 +583,14 @@ static inline bool need_inplace_update(struct inode *inode)
                        utilization(sbi) > SM_I(sbi)->min_ipu_util)
                return true;
 
+       /*
+        * IPU for rewrite async pages
+        */
+       if (policy & (0x1 << F2FS_IPU_ASYNC) &&
+                       fio && fio->op == REQ_OP_WRITE &&
+                       !(fio->op_flags & REQ_SYNC))
+               return true;
+
        /* this is only set during fdatasync */
        if (policy & (0x1 << F2FS_IPU_FSYNC) &&
                        is_inode_flag_set(inode, FI_NEED_IPU))