From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758165AbcIWF0O (ORCPT ); Fri, 23 Sep 2016 01:26:14 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:11209 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752652AbcIWFZe (ORCPT ); Fri, 23 Sep 2016 01:25:34 -0400 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 2/3] f2fs: support checkpoint error injection Date: Fri, 23 Sep 2016 13:24:57 +0800 Message-ID: <20160923052458.83849-2-yuchao0@huawei.com> X-Mailer: git-send-email 2.8.2.311.gee88674 In-Reply-To: <20160923052458.83849-1-yuchao0@huawei.com> References: <20160923052458.83849-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.57E4BCB8.0048,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: a763474ddaa51c311c5b7db7b1ae8abe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds to support checkpoint error injection in f2fs for testing fatal error tolerance. Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h | 7 +++++++ fs/f2fs/super.c | 1 + 2 files changed, 8 insertions(+) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e216bc0..3c513fe 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -47,6 +47,7 @@ enum { FAULT_DIR_DEPTH, FAULT_EVICT_INODE, FAULT_IO, + FAULT_CHECKPOINT, FAULT_MAX, }; @@ -80,6 +81,8 @@ static inline bool time_to_inject(int type) return false; else if (type == FAULT_IO && !IS_FAULT_SET(type)) return false; + else if (type == FAULT_CHECKPOINT && !IS_FAULT_SET(type)) + return false; atomic_inc(&f2fs_fault.inject_ops); if (atomic_read(&f2fs_fault.inject_ops) >= f2fs_fault.inject_rate) { @@ -1873,6 +1876,10 @@ static inline int f2fs_readonly(struct super_block *sb) static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi) { +#ifdef CONFIG_F2FS_FAULT_INJECTION + if (time_to_inject(FAULT_CHECKPOINT)) + return true; +#endif return is_set_ckpt_flags(sbi, CP_ERROR_FLAG); } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 6426855..3c49419 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -51,6 +51,7 @@ char *fault_name[FAULT_MAX] = { [FAULT_DIR_DEPTH] = "too big dir depth", [FAULT_EVICT_INODE] = "evict_inode fail", [FAULT_IO] = "IO error", + [FAULT_CHECKPOINT] = "checkpoint error", }; static void f2fs_build_fault_attr(unsigned int rate) -- 2.8.2.311.gee88674