From patchwork Tue Nov 28 00:23:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hyunchul Lee X-Patchwork-Id: 10078449 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 01D516028E for ; Tue, 28 Nov 2017 00:24:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E9F69290CD for ; Tue, 28 Nov 2017 00:24:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD3FA290F0; Tue, 28 Nov 2017 00:24:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 93030290CD for ; Tue, 28 Nov 2017 00:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752638AbdK1AXr (ORCPT ); Mon, 27 Nov 2017 19:23:47 -0500 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:48164 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753359AbdK1AXe (ORCPT ); Mon, 27 Nov 2017 19:23:34 -0500 Received: from unknown (HELO lgeamrelo01.lge.com) (156.147.1.125) by 156.147.23.51 with ESMTP; 28 Nov 2017 09:23:33 +0900 X-Original-SENDERIP: 156.147.1.125 X-Original-MAILFROM: hyc.lee@gmail.com Received: from unknown (HELO localhost.localdomain) (10.177.225.35) by 156.147.1.125 with ESMTP; 28 Nov 2017 09:23:33 +0900 X-Original-SENDERIP: 10.177.225.35 X-Original-MAILFROM: hyc.lee@gmail.com From: Hyunchul Lee To: Jaegeuk Kim , Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-team@lge.com, Jens Axboe , Hyunchul Lee Subject: [PATCH 1/2] f2fs: pass down write hints to block layer for bufferd write Date: Tue, 28 Nov 2017 09:23:26 +0900 Message-Id: <1511828607-624-1-git-send-email-hyc.lee@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Hyunchul Lee 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 --- 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); } }