From patchwork Wed Feb 20 10:21:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 1045246 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="TccI2m5k"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 444D7g4QmYz9s8m for ; Wed, 20 Feb 2019 21:17:51 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FKgv7Ummu/gn+Rk+QRxD8KMVENGdnn7VbU+uaGX9ijM=; b=TccI2m5k0pqLSj uxF4cXc+/1z1EsPdNyYC3O8VFIp74FctTYK8iFkxAjK1SKIjre09kTRKaw9S447cXW4gppqGRqzVt OO1S+2o4fBIZWV+Xkqabv1QZySTJL8sGbnh9iJ0Dj7/CXgGZ0+k+GLRSf71+lRlOHnJ9HAKLk2V4y 3aK8KGqOtHKINOThAUmzi7CcQA4F7kdWFQw0M+6L460tN+l+wpypT1Kd4mMLkpdLHR9EYwUAquJV6 orvEdg9u019J9QGBzPW0iW9REWFkGZDfqU1Okkp0iGGCACYkDIiv9M3XxhNmpGNWYELIZeAfU6hvg JWnex0XAwioKbmqpNV4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwOwi-0007pT-Fr; Wed, 20 Feb 2019 10:17:44 +0000 Received: from szxga05-in.huawei.com ([45.249.212.191] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gwOwV-0007TL-82 for linux-mtd@lists.infradead.org; Wed, 20 Feb 2019 10:17:34 +0000 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: 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 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190220_021731_572497_C06488CD X-CRM114-Status: UNSURE ( 9.58 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [45.249.212.191 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , David Woodhouse , linux-kernel@vger.kernel.org, houtao1@huawei.com Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.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. */