f2fs: apply write hints to select the type of segments for buffered write
authorHyunchul Lee <cheol.lee@lge.com>
Thu, 9 Nov 2017 05:51:27 +0000 (14:51 +0900)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 9 Nov 2017 18:18:16 +0000 (10:18 -0800)
Write hints helps F2FS to determine which type of segments would be
selected for buffered write.

This patch implements the mapping from write hints to segment types
as shown below.

  hints               segment type
  -----               ------------
  WRITE_LIFE_SHORT    CURSEG_HOT_DATA
  WRITE_LIFE_EXTREME  CURSEG_COLD_DATA
  others              CURSEG_WARM_DATA

the F2FS poliy for hot/cold seperation has precedence over this hints.
And hints are not applied in in-place update.

Signed-off-by: Hyunchul Lee <cheol.lee@lge.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/segment.c

index 20722b2..c117e09 100644 (file)
@@ -2434,6 +2434,18 @@ static bool __has_curseg_space(struct f2fs_sb_info *sbi, int type)
        return false;
 }
 
+int rw_hint_to_seg_type(enum rw_hint hint)
+{
+       switch (hint) {
+       case WRITE_LIFE_SHORT:
+               return CURSEG_HOT_DATA;
+       case WRITE_LIFE_EXTREME:
+               return CURSEG_COLD_DATA;
+       default:
+               return CURSEG_WARM_DATA;
+       }
+}
+
 static int __get_segment_type_2(struct f2fs_io_info *fio)
 {
        if (fio->type == DATA)
@@ -2468,7 +2480,7 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
                        return CURSEG_COLD_DATA;
                if (is_inode_flag_set(inode, FI_HOT_DATA))
                        return CURSEG_HOT_DATA;
-               return CURSEG_WARM_DATA;
+               return rw_hint_to_seg_type(inode->i_write_hint);
        } else {
                if (IS_DNODE(fio->page))
                        return is_cold_node(fio->page) ? CURSEG_WARM_NODE :