2017-11-28 00:25:02

by Hyunchul Lee

[permalink] [raw]
Subject: [PATCH 1/2] f2fs: pass down write hints to block layer for bufferd write

From: Hyunchul Lee <[email protected]>

This implements which hint is passed down to block layer
for datas from the specific segment type.

segment type hints
------------ -----
COLD_NODE & COLD_DATA WRITE_LIFE_EXTREME
WARM_DATA WRITE_LIFE_NONE
HOT_NODE & WARM_NODE WRITE_LIFE_LONG
HOT_DATA WRITE_LIFE_MEDIUM
META_DATA WRITE_LIFE_SHORT

Many thanks to Chao Yu and Jaegeuk Kim for comments to
implement this patch.

Signed-off-by: Hyunchul Lee <[email protected]>
---
fs/f2fs/data.c | 1 +
fs/f2fs/f2fs.h | 2 ++
fs/f2fs/segment.c | 29 +++++++++++++++++++++++++++++
fs/f2fs/super.c | 2 ++
4 files changed, 34 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index a7ae418..0919a43 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -437,6 +437,7 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
}
io->bio = __bio_alloc(sbi, fio->new_blkaddr,
BIO_MAX_PAGES, false);
+ io->bio->bi_write_hint = io->write_hint;
io->fio = *fio;
}

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 7bcd148..be3cb0c 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -969,6 +969,7 @@ struct f2fs_bio_info {
struct rw_semaphore io_rwsem; /* blocking op for bio */
spinlock_t io_lock; /* serialize DATA/NODE IOs */
struct list_head io_list; /* track fios */
+ enum rw_hint write_hint;
};

#define FDEV(i) (sbi->devs[i])
@@ -2674,6 +2675,7 @@ int lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
int __init create_segment_manager_caches(void);
void destroy_segment_manager_caches(void);
int rw_hint_to_seg_type(enum rw_hint hint);
+enum rw_hint io_type_to_rw_hint(enum page_type page, enum temp_type temp);

/*
* checkpoint.c
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index c117e09..0570db7 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2446,6 +2446,35 @@ int rw_hint_to_seg_type(enum rw_hint hint)
}
}

+enum rw_hint io_type_to_rw_hint(enum page_type page, enum temp_type temp)
+{
+ if (page == DATA) {
+ switch (temp) {
+ case WARM:
+ return WRITE_LIFE_NONE;
+ case COLD:
+ return WRITE_LIFE_EXTREME;
+ case HOT:
+ return WRITE_LIFE_MEDIUM;
+ default:
+ return WRITE_LIFE_NOT_SET;
+ }
+ } else if (page == NODE) {
+ switch (temp) {
+ case WARM:
+ case HOT:
+ return WRITE_LIFE_LONG;
+ case COLD:
+ return WRITE_LIFE_EXTREME;
+ default:
+ return WRITE_LIFE_NOT_SET;
+ }
+
+ } else {
+ return WRITE_LIFE_SHORT;
+ }
+}
+
static int __get_segment_type_2(struct f2fs_io_info *fio)
{
if (fio->type == DATA)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index a6c5dd4..51c19a0 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -2508,6 +2508,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
sbi->write_io[i][j].bio = NULL;
spin_lock_init(&sbi->write_io[i][j].io_lock);
INIT_LIST_HEAD(&sbi->write_io[i][j].io_list);
+ sbi->write_io[i][j].write_hint =
+ io_type_to_rw_hint(i, j);
}
}

--
1.9.1


From 1586414764339822262@xxx Sun Dec 10 16:23:35 +0000 2017
X-GM-THRID: 1585855062439966123
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread


2017-11-28 00:25:08

by Hyunchul Lee

[permalink] [raw]
Subject: [PATCH 2/2] f2fs: pass down write hints to block layer for direct write

From: Hyunchul Lee <[email protected]>

This implements which hint is passed down to block layer
for direct write.

(allocated
file hint segment type) io hint
---------- ------------ --------
WRITE_LIFE_SHORT HOT_DATA WRITE_LIFE_MEDIUM
WRITE_LIFE_EXTREME COLD_DATA WRITE_LIFE_EXTREME
others WARM_DATA WRITE_LIFE_NONE

Signed-off-by: Hyunchul Lee <[email protected]>
---
fs/f2fs/data.c | 6 ++++++
fs/f2fs/f2fs.h | 1 +
fs/f2fs/segment.c | 12 ++++++++++++
3 files changed, 19 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 0919a43..eabd569 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2093,6 +2093,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
loff_t offset = iocb->ki_pos;
int rw = iov_iter_rw(iter);
int err;
+ enum rw_hint orig_hint;

err = check_direct_IO(inode, iter, offset);
if (err)
@@ -2103,10 +2104,15 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)

trace_f2fs_direct_IO_enter(inode, offset, count, rw);

+ orig_hint = iocb->ki_hint;
+ iocb->ki_hint = file_rwhint_to_io_rwhint(iocb->ki_hint);
+
down_read(&F2FS_I(inode)->dio_rwsem[rw]);
err = blockdev_direct_IO(iocb, inode, iter, get_data_block_dio);
up_read(&F2FS_I(inode)->dio_rwsem[rw]);

+ iocb->ki_hint = orig_hint;
+
if (rw == WRITE) {
if (err > 0) {
f2fs_update_iostat(F2FS_I_SB(inode), APP_DIRECT_IO,
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index be3cb0c..426625a 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -2676,6 +2676,7 @@ int lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
void destroy_segment_manager_caches(void);
int rw_hint_to_seg_type(enum rw_hint hint);
enum rw_hint io_type_to_rw_hint(enum page_type page, enum temp_type temp);
+enum rw_hint file_rwhint_to_io_rwhint(enum rw_hint hint);

/*
* checkpoint.c
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0570db7..b4496a5 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -2475,6 +2475,18 @@ enum rw_hint io_type_to_rw_hint(enum page_type page, enum temp_type temp)
}
}

+enum rw_hint file_rwhint_to_io_rwhint(enum rw_hint hint)
+{
+ switch(hint) {
+ case WRITE_LIFE_SHORT:
+ return WRITE_LIFE_MEDIUM;
+ case WRITE_LIFE_EXTREME:
+ return WRITE_LIFE_EXTREME;
+ default:
+ return WRITE_LIFE_NONE;
+ }
+}
+
static int __get_segment_type_2(struct f2fs_io_info *fio)
{
if (fio->type == DATA)
--
1.9.1


From 1585280419045661715@xxx Tue Nov 28 03:53:39 +0000 2017
X-GM-THRID: 1585280419045661715
X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread