Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755615AbbLQJOS (ORCPT ); Thu, 17 Dec 2015 04:14:18 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:47992 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754655AbbLQJOI (ORCPT ); Thu, 17 Dec 2015 04:14:08 -0500 X-AuditID: cbfee61a-f79266d000003652-96-56727cdf2c73 From: Chao Yu To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v3 7/7] f2fs: support data flush in background Date: Thu, 17 Dec 2015 17:13:28 +0800 Message-id: <006c01d138ab$4938d740$dbaa85c0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdE4fo6+UzV0xVvOT/uxhxLrCvpWyg== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsVy+t9jAd37NUVhBl37uC2erJ/FbHFpkbvF 5V1z2ByYPTat6mTz2L3gM5PH501yAcxRXDYpqTmZZalF+nYJXBk3Jl1lKbjJW3Fz+mfGBsZZ 3F2MnBwSAiYS91YdZYSwxSQu3FvP1sXIxSEksJRRovnUU1YI5xWjxNLDn1hAqtgEVCSWd/xn ArFFgOxDiy6zg9jMAh4SjR3fgRo4OIQF7CSWPa0FCbMIqEocP/oLrJVXwFJi89tvTBC2oMSP yfdYIFq1JNbvPM4EYctLbF7zlhniIAWJHWdfM0Ks0gM6oQOqXlxi45FbLBMYBWYhGTULyahZ SEbNQtKygJFlFaNEakFyQXFSeq5hXmq5XnFibnFpXrpecn7uJkZwED+T2sF4cJf7IUYBDkYl Hl6BfYVhQqyJZcWVuYcYJTiYlUR4v+8BCvGmJFZWpRblxxeV5qQWH2KU5mBREuetvRQZJiSQ nliSmp2aWpBaBJNl4uCUamA8trokTVGqSfpz00Wl7Y7/39mr3pb7M1Ph2wve6sZidb0Mm0n9 F+1m7X/Gna27dbZbok23hQLL4qXfv8xf0ny59mpMPVOyKmuMw0S+8DCW+fFXiuIu/EjTucKX 7/k35Shn+OqfabdufmXySllf7M4mWChxm+VjgtH8+Vxs/v/jYzeWufc+4VNiKc5INNRiLipO BABF96AAXgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1948 Lines: 55 Previously, when finishing a checkpoint, we have persisted all fs meta info including meta inode, node inode, dentry page of directory inode, so, after a sudden power cut, f2fs can recover from last checkpoint with full directory structure. But during checkpoint, we didn't flush dirty pages of regular and symlink inode, so such dirty datas still in memory will be lost in that moment of power off. In order to reduce the chance of lost data, this patch enables f2fs_balance_fs_bg with the ability of data flushing. It will try to flush user data before starting a checkpoint. So user's data written after last checkpoint which may not be fsynced could be saved. When we mount with data_flush option, after every period of cp_interval (could be configured in sysfs: /sys/fs/f2fs/device/cp_interval) seconds user data could be flushed into device once f2fs_balance_fs_bg was called in kworker thread or gc thread. Signed-off-by: Chao Yu --- v2: - trigger data flush in f2fs_balance_fs_bg. v3: - adjust to modify commit message. --- fs/f2fs/segment.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 5fa519f..c247450 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -291,8 +291,11 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi) if (!available_free_memory(sbi, NAT_ENTRIES) || excess_prefree_segs(sbi) || !available_free_memory(sbi, INO_ENTRIES) || - jiffies > sbi->cp_expires) + jiffies > sbi->cp_expires) { + if (test_opt(sbi, DATA_FLUSH)) + sync_dirty_inodes(sbi, FILE_INODE); f2fs_sync_fs(sbi->sb, true); + } } static int issue_flush_thread(void *data) -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/