Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp404856imp; Wed, 20 Feb 2019 02:19:57 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia8w90ndfUZBbjE6g607/Tc+++4H3slBhpWtYpTTAeJCBl1f3nj26u6pdGMhFwJ97XbxNZR X-Received: by 2002:a65:4383:: with SMTP id m3mr9132976pgp.96.1550657997180; Wed, 20 Feb 2019 02:19:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550657997; cv=none; d=google.com; s=arc-20160816; b=F9VMtft2FRX2w+Uj44N4YtLSGEf5jV0Gnc0wFOaUpVGjMWWkg24Ei3fojQVi6S6d9E nLi+PCfzSzz0O+7IGIItsMDZxBG1Zk6Y2KLu1rmsSYmK+IjtCMIzfzWRvHX25upvd28l O0cQsX+7d/kLRV8MDjJC1u9oVBF++AoAcBC6CmjHVfi/tiJw8aOLKyL8tPy+9Haywykx 9psrk8pRRt/M39/2EKc9OEYqbLoJBT2zq78PkzvYXfFmMDuJLVIVpnNxwz3FuOvCguFg Pxt4Df5fpb35i5XDKpDEcW86kS89U9H/rT7JFxeRN5UnEJnOCo3V5LJH4orVuetJm31a ZUtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=xLYSi49BXzkjvXXROSUtQ+MSC4ncGCUXirbmmonw54E=; b=0/oyKdMKCaVTB4z6S+lWnCAKY4V1LF1Q6rxHC/VprmlfEuPosCSb+GNOt4FYKqP6Tk odc26Xg+5af7TbkiwOcUeW54VxSrBSKmysSptIJ/qFnUSeYIdz6WTmy3gEnLvoJkTD52 Ey/3kTADnxlYfbouizD/+bNaxKSkSVpQJTbwlMPxYSQwfd5KTcd2ZbklKkn+QRGT5UtD g3/Q40spvUE2TFuzTUtcJTgEZ+9mmTjBfdlJ5F1ngB7dsFzsPk2ZRa9hueBnVbovWYYe B5fnxoWjGTvvz2TTKjb3fvbuy0fPtebsuNQg5E3x4fAnkdg0Ep3IEGWOPFVX3hH1WO9V YYqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si12979987pgh.86.2019.02.20.02.19.41; Wed, 20 Feb 2019 02:19:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727363AbfBTKRb (ORCPT + 99 others); Wed, 20 Feb 2019 05:17:31 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:4237 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726317AbfBTKR1 (ORCPT ); Wed, 20 Feb 2019 05:17:27 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 448AA253C4D8CD2A68AA; Wed, 20 Feb 2019 18:17:25 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.408.0; Wed, 20 Feb 2019 18:17:16 +0800 From: Hou Tao To: CC: David Woodhouse , Richard Weinberger , , Subject: [PATCH 2/2] jffs2: handle INO_STATE_CLEARING in jffs2_do_read_inode() Date: Wed, 20 Feb 2019 18:21:33 +0800 Message-ID: <20190220102133.7878-3-houtao1@huawei.com> X-Mailer: git-send-email 2.16.2.dirty In-Reply-To: <20190220102133.7878-1-houtao1@huawei.com> References: <20190220102133.7878-1-houtao1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For inode that fails to be created midway, GC procedure may try to GC its dnode, and in the following case BUG() will be triggered: CPU 0 CPU 1 in jffs2_do_create() in jffs2_garbage_collect_pass() jffs2_write_dnode succeed // for dirent jffs2_reserve_space fail inum = ic->ino nlink = ic->pino_nlink (> 0) iget_failed make_bad_inode remove_inode_hash iput jffs2_evict_inode jffs2_do_clear_inode jffs2_set_inocache_state(INO_STATE_CLEARING) jffs2_gc_fetch_inode jffs2_iget // a new inode is created because // the old inode had been unhashed iget_locked jffs2_do_read_inode jffs2_get_ino_cache // assert BUG() f->inocache->state = INO_STATE_CLEARING Fix it by waiting for its state changes to INO_STATE_CHECKEDABSENT. Fixes: 67e345d17ff8 ("[JFFS2] Prevent ino cache removal for inodes in use") Cc: stable@vger.kernel.org Signed-off-by: Hou Tao --- fs/jffs2/readinode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 389ea53ea487..0bae0583106e 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c @@ -1328,6 +1328,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f, case INO_STATE_CHECKING: case INO_STATE_GC: + case INO_STATE_CLEARING: /* If it's in either of these states, we need to wait for whoever's got it to finish and put it back. */ -- 2.16.2.dirty