From patchwork Fri Nov 23 12:53:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kim Woelders X-Patchwork-Id: 1002299 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=thrane.eu Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kiMUA7xy"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=thrane.onmicrosoft.com header.i=@thrane.onmicrosoft.com header.b="baHZLD1n"; 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 431bpg6CpSz9s29 for ; Fri, 23 Nov 2018 23:53:47 +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: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=K/XkQ+tcRBopxf2iOVBz5Lk5VjvP7TmgVoRjhYCNsgQ=; b=kiMUA7xyz7gevw 3fi4u+HJP6Ee4iiOeOaUbXCnAjDEAvB6CDs2AhwCd40iJRMMmw7uqbcNT9dSmr589RCX61yBZO6ab EcT34U8FrRUkZ6VipOr8tnR9yIM/tH1AgbkpshM3WApN+nlQIJjdN7MzQiAXx6pR6rWkbXk4H/tQD KplExptKhzwitGO1Qlq+gMHLuUq82A0W8mCTu8FdoWpAmO68nldDymHRxLf3oEgjCwHztdg0sPpUb Ey96Je0NAwQH9BJ6E+uLWgT7kZ6G4Lc8NnhGx87bXEiah/dHdTKfQfjzyuMY9KWpRKIApgLe4TtlP pNGoaSXSsGeSvnQggTmw==; 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 1gQAxr-000219-2W; Fri, 23 Nov 2018 12:53:43 +0000 Received: from mail-eopbgr30082.outbound.protection.outlook.com ([40.107.3.82] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gQAxn-00020d-Jc for linux-mtd@lists.infradead.org; Fri, 23 Nov 2018 12:53:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=thrane.onmicrosoft.com; s=selector1-thrane-eu; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sKu+fNqP4kpK1yEhJC4fob7HPosaYypi7fbVXNlgpWA=; b=baHZLD1n2bdURrIMewwy0Of42V0T/oXaTf2cMILonTm7FCavN3C2wK5ySPXGvobiOorziEUy4479mJolrleZnb33MOSstcbJxZQNdiOv3WsS460TW8Z9ZoCZIx4QNqPsrhyjn0LS5Uhe0i31BJUdO46ARxEWzTgmUQ7JrJCFsXQ= Received: from AM0PR10MB2274.EURPRD10.PROD.OUTLOOK.COM (20.177.109.21) by AM0PR10MB2754.EURPRD10.PROD.OUTLOOK.COM (20.178.202.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.18; Fri, 23 Nov 2018 12:53:23 +0000 Received: from AM0PR10MB2274.EURPRD10.PROD.OUTLOOK.COM ([fe80::c49:cc4a:c58e:8535]) by AM0PR10MB2274.EURPRD10.PROD.OUTLOOK.COM ([fe80::c49:cc4a:c58e:8535%4]) with mapi id 15.20.1361.017; Fri, 23 Nov 2018 12:53:23 +0000 From: Kim Woelders To: "linux-mtd@lists.infradead.org" Subject: [PATCH] jffs2: Fix garbage collection when jffs2_read_dnode() returns EIO Thread-Topic: [PATCH] jffs2: Fix garbage collection when jffs2_read_dnode() returns EIO Thread-Index: AQHUgyuF2VBdYTAsk0mHIm2ijp0kUA== Date: Fri, 23 Nov 2018 12:53:23 +0000 Message-ID: <20181123125313.30041-1-kw@thrane.eu> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR1001CA0002.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:3:f7::12) To AM0PR10MB2274.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:db::21) authentication-results: spf=none (sender IP is ) smtp.mailfrom=kw@thrane.eu; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [80.63.34.126] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; AM0PR10MB2754; 6:y1DimwN9eo05Fl22+qBxD6+UzQDflFJO/Uc8wzAD3kgS2yA5acpUZGMDSd93tDe0vBZYRWtZtFH3jSJVk8W+gOi/GA/hTgcuCxZRKRFvtszgPfakhin9wyeIsAFVZJ8yqVo942IeJg+dv3tnCCbGrUeM9Nxfgf8DUOt8BL4U+H8duo8sVj/OpyDGJYdoYGVkqAy6KBrX6nWaDxVHv+C8L1NraFmyEXunwkaDNavxTxk3WCHsXYqril+t812NQ0dk0l5aDj6sE1qdRzvntck46NS0kqLdjI84lCkIKzE2Ebxg9BNsSwm5XX43d9mTtclyaeW+zl6YC2S1JN1HUtH6rA6BWOG8SEbCdPwbvvUOM6cAQ8oUsAkpDU03Ud0XsEp4FYn20p1icHkns60qJuRu8KBbovGv37L4rJ7zsWjmx1i/SXGU9BxMNHdgyNbBBCKkG6LcBWkBsnMHQkU0B7R96Q==; 5:G1VWW2DrxWg96iXhQ2/kqL45p+tT8VfeEXRkwj8M75rY4cmuDjywGGHz37F71K5kqNnp3iX/P5arVk3YG5If9KCMw2JapCWxdQDXNxJjRkT6qiM0mQpVzrkzrt+yxVzzGrZhy6Wm1h0cWhCkOyhPCkGBwWcYcTgfCSHVrGLxc70=; 7:FIESk401EJnRhkoSQQL/6TsCFjrSpEArJEs8sDbNQHJPBlXaRySyzL0nUwKUWU5dYmVVf4KBTZ9sXRR/z1iYpmQS+ucdPR0sBVlmGyYVIAMD2lIWvvuEK+mF30gMc/lLN/RV7IWPAx0bSCFve6j9dw== x-ms-office365-filtering-correlation-id: a685c5fe-3e04-47f5-5106-08d65142a760 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(7021145)(8989299)(5600074)(711020)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(2017052603328)(7153060)(7193020); SRVR:AM0PR10MB2754; x-ms-traffictypediagnostic: AM0PR10MB2754: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(2016111802025)(20161123562045)(20161123560045)(20161123558120)(20161123564045)(6043046)(201708071742011)(7699051)(76991095); SRVR:AM0PR10MB2754; BCL:0; PCL:0; RULEID:; SRVR:AM0PR10MB2754; x-forefront-prvs: 086597191B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(376002)(346002)(396003)(39830400003)(366004)(199004)(189003)(5660300001)(575784001)(7736002)(106356001)(2351001)(6116002)(305945005)(105586002)(3846002)(1076002)(36756003)(2501003)(74482002)(508600001)(316002)(25786009)(66066001)(8676002)(2900100001)(8936002)(14454004)(81156014)(81166006)(86362001)(97736004)(53936002)(6916009)(1857600001)(71200400001)(71190400001)(52116002)(6436002)(256004)(14444005)(107886003)(5640700003)(26005)(186003)(4326008)(68736007)(102836004)(6512007)(386003)(6506007)(476003)(2616005)(2906002)(486006)(99286004)(6486002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR10MB2754; H:AM0PR10MB2274.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: thrane.eu does not designate permitted sender hosts) x-microsoft-antispam-message-info: SVnoLao4L971AZh5QhtoVteZQB1zCyjbCCvsyisN5cLiLC76vFSOYKWqG5eH/oMvwkX8sUuN4sebe/4ee391WrGdjezeNGux21hHLJlrFJ6QJFbJaxWWMQvnVmxZlDP5j/zwkd8vRKm1XgXT6C4y94n9zV7ra8/0PcQ5wOYDM/4E6zcya6ZBvVRKmMFPdNu73rSc/NWzlbXZ2EcyyeQJATriJtcOHyMPUwwbISvDNQTlQnxuoNaJ2KbNhySH4ueBwtzFO0+W0OgNWWXSNzP3V+w8cfUII1CVjsZAFAo+2c94oBVc6SFMfHou1kbm3FWSd7eS2O/TiQgM0aO3GJyWNxQ95XFQ8AyuRbkc7jZ9iZ0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: thrane.eu X-MS-Exchange-CrossTenant-Network-Message-Id: a685c5fe-3e04-47f5-5106-08d65142a760 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Nov 2018 12:53:23.9021 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4acdf9d4-aad5-42be-ab09-e3f3d0b38479 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB2754 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181123_045339_685590_B1AE6444 X-CRM114-Status: GOOD ( 11.47 ) X-Spam-Score: -1.5 (-) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-1.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [40.107.3.82 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.5 DKIMWL_WL_MED DKIMwl.org - Whitelisted Medium sender 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: Kim Woelders Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Hello, I am by no means certain that this is the correct fix for the problem at hand but it seems to work for us. /Kim --- For unknown reasons a jffs2 partition had entered a state where it would not function properly (e.g. writing new files would abort) and give log messages like: jffs2: Data CRC 178b4d59 != calculated CRC 22902b28 for node at 011425d0 jffs2: read_cache_page() returned error: -5 jffs2: Error garbage collecting node at 01141f88! The file system was effectively unusable until the file containing the offending node(s) was deleted. The "Data CRC" message is issued by jffs2_read_dnode() which returns -EIO (= -5). The problem in our case first manifests itself during garbage collection after mount where the call tree in reverse order is: jffs2_read_dnode() -> EIO jffs2_read_inode_range() -> EIO jffs2_do_readpage_nolock() -> EIO jffs2_do_readpage_unlock() -> EIO read_cache_page() -> EIO jffs2_gc_fetch_page() -> EIO jffs2_garbage_collect_dnode() -> EIO jffs2_garbage_collect_live() -> EIO jffs2_garbage_collect_pass() -> ENOSPC jffs2_garbage_collect_thread() The garbage collection thread is then aborted: jffs2: No space for garbage collection. Aborting GC thread This commit changes the behavior so that if jffs2_garbage_collect_live() in jffs2_garbage_collect_pass() returns EIO, we obsolete the offending node. During subsequent GC passes this will clean up the file system to become usable. Signed-off-by: Kim Woelders diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 9ed0f26cf023..25c075b3c189 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c @@ -470,7 +470,10 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) /* Eep. This really should never happen. GC is broken */ pr_err("Error garbage collecting node at %08x!\n", ref_offset(jeb->gc_node)); - ret = -ENOSPC; + if (ret == -EIO) + jffs2_mark_node_obsolete(c, raw); + else + ret = -ENOSPC; } release_sem: mutex_unlock(&c->alloc_sem);