From patchwork Thu Aug 17 04:09:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Tomlinson X-Patchwork-Id: 802318 X-Patchwork-Delegate: dwmw2@infradead.org 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=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hNR9ARbL"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="dbEIcAe8"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.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 3xXt902WDSz9t2M for ; Thu, 17 Aug 2017 14:12:36 +1000 (AEST) 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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: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:In-Reply-To: References:List-Owner; bh=hKS8m8sNV/cHI3bZdjQbSy3iE5FrmivOC6bjq0cMUCM=; b=hNR 9ARbLDFZlt8Q49Iby8/e1rkWAJmrVRliwBDlkBWRoS25Ia1vtKsdyiqwJFBsK/xm+QlRwDOxtwPIU uQ02kTSw3ZLpQ2n4ztrQaTYQpoF1Mcnk2v2/4ULOca9Lpr9yWabveNbMRyztDAN7reKv0MbrM7M6X OIy8YrnZbPCw+vIAVmNESQX1vq4t3cJlkZ5Y5Ot+5/sNFNUIJfVFHuO7iZQmpP5Qp4Ohfz0GpZ337 IOttQkXIaQMsUfuNcwrNDeOgwIqfAHZZeue2XEuypH115cYT1kKD+AfD4m9YkbDXTIHBPJTXpiKhp eZrIFBNADCXSfdOhIUpIVU0ozr3aFYQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1diCAZ-0004KG-3y; Thu, 17 Aug 2017 04:12:31 +0000 Received: from gate2.alliedtelesis.co.nz ([2001:df5:b000:5::4]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1diC8P-0002i5-UO for linux-mtd@lists.infradead.org; Thu, 17 Aug 2017 04:12:08 +0000 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id AF21B8365F for ; Thu, 17 Aug 2017 16:09:48 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail; t=1502942988; bh=ZlZ0s4JvCnSHKkUBEdHul7eQyWQq7Mh+QW+/n1RNx38=; h=From:To:Cc:Subject:Date; b=dbEIcAe8SzRXsEctfBWEBpAqtnRcdrCNXd9KRMtjfa7kW85eMZcOE5CkYydmUgfUP GPioaqUacpnfujxe5G3EcfeSkNVM0UdMQ6UluImy7V88qEh4x7tMWxWkLZm4X8UyKG GqQ7PMKCZR/jGCJDKR1510M2sXbirMevOWEN9g94= Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 17 Aug 2017 16:09:48 +1200 Received: from markto-dl.ws.atlnz.lc (markto-dl.ws.atlnz.lc [10.33.23.31]) by smtp (Postfix) with ESMTP id 3532E13EC40; Thu, 17 Aug 2017 16:09:57 +1200 (NZST) Received: by markto-dl.ws.atlnz.lc (Postfix, from userid 1155) id 8CF0C61D52; Thu, 17 Aug 2017 16:09:48 +1200 (NZST) From: Mark Tomlinson To: linux-mtd@lists.infradead.org Subject: [PATCH] jffs2: Fix garbage collector BUG Date: Thu, 17 Aug 2017 16:09:16 +1200 Message-Id: <20170817040916.32570-1-mark.tomlinson@alliedtelesis.co.nz> X-Mailer: git-send-email 2.14.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170816_211205_695223_E35F666A X-CRM114-Status: UNSURE ( 9.67 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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: Mark Tomlinson MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org During garbage collection, the state INO_STATE_CLEARING is possible, but was not checked. Even though this state is transient, there is a chance that the garbage collector will see an inode in this state and needs to be able to deal with it. Previously the default case was hit, resulting in BUG(). The only time an inode can be in clearing state is during clear_inode. After this, the inode is either removed or put into CHECKEDABSENT state. So the fix here is to simply treat clearing state the same as CHECKEDABSENT, i.e. ignore this node and move to the next. Note that this is not a new issue. For example, there is a bug report here: http://lists.infradead.org/pipermail/linux-mtd/2011-December/038850.html Signed-off-by: Mark Tomlinson --- fs/jffs2/gc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 9ed0f26cf023..e153ef699ae8 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c @@ -196,6 +196,10 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) continue; } switch(ic->state) { + case INO_STATE_CLEARING: + /* Once in CLEARING state, it will always transition to + * CHECKEDABSENT, so may as well treat it as that now + */ case INO_STATE_CHECKEDABSENT: case INO_STATE_PRESENT: spin_unlock(&c->inocache_lock);