From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753459AbcEPKlS (ORCPT ); Mon, 16 May 2016 06:41:18 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:54202 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752451AbcEPKlR (ORCPT ); Mon, 16 May 2016 06:41:17 -0400 From: Hou Pengyang To: CC: , , , Subject: [RFC] f2fs: fix a race condition between evict & gc Date: Mon, 16 May 2016 10:40:21 +0000 Message-ID: <1463395221-109622-1-git-send-email-houpengyang@huawei.com> X-Mailer: git-send-email 1.8.3.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.5739A3AB.007F,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: d967c72c866142f5f81eee4f6f6e8db1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When collecting data segment(gc_data_segment), there is a race condition between evict and phases of gc: 0) ra_node_page(dnode) 1) ra_node_page(inode) <--- evict the inode 2) f2fs_iget get the inode and add it to gc_list 3) move_data_page In step 2), f2fs_iget does NOT find the inode and allocs a new inode as result, which is not resonable. This patch changes f2fs_iget to ilookup. when no inode is found, no new inode is created. Signed-off-by: Hou Pengyang --- fs/f2fs/gc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 38d56f6..6e73193 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -717,8 +717,8 @@ next_step: ofs_in_node = le16_to_cpu(entry->ofs_in_node); if (phase == 2) { - inode = f2fs_iget(sb, dni.ino); - if (IS_ERR(inode) || is_bad_inode(inode)) + inode = ilookup(sb, dni.ino); + if (!inode || IS_ERR(inode) || is_bad_inode(inode)) continue; /* if encrypted inode, let's go phase 3 */ -- 1.9.1