From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yunlei He Subject: [PATCH v2] f2fs: stop issue discard if something wrong with f2fs Date: Mon, 9 Apr 2018 11:54:50 +0800 Message-ID: <1523246090-22055-1-git-send-email-heyunlei@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1f5O74-00065d-0T for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Apr 2018 04:09:02 +0000 Received: from [45.249.212.35] (helo=huawei.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1f5O6z-00BehZ-Oi for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Apr 2018 04:09:01 +0000 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net To: jaegeuk@kernel.org, yuchao0@huawei.com, linux-f2fs-devel@lists.sourceforge.net Cc: zhangdianfang@huawei.com This patch stop discard thread to issue discard io if something wrong with f2fs, which is similar to fstrim. v1->v2: add fs error check in not only discard thread but also umount process Signed-off-by: Yunlei He --- fs/f2fs/segment.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 5854cc4..7f45cc4 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1202,6 +1202,12 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, int i, iter = 0, issued = 0; bool io_interrupted = false; + if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) { + f2fs_msg(sbi->sb, KERN_WARNING, + "Found FS corruption, run fsck to fix."); + return issued; + } + for (i = MAX_PLIST_NUM - 1; i >= 0; i--) { if (i + 1 < dpolicy->granularity) break; @@ -1410,7 +1416,6 @@ static int issue_discard_thread(void *data) continue; if (kthread_should_stop()) return 0; - if (dcc->discard_wake) dcc->discard_wake = 0; -- 1.9.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot