From patchwork Wed May 18 20:47:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Gardiner X-Patchwork-Id: 96230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 25D22B6F5A for ; Thu, 19 May 2011 06:49:05 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QMneg-0000WE-Fd; Wed, 18 May 2011 20:47:42 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QMnee-0005eL-Kw; Wed, 18 May 2011 20:47:40 +0000 Received: from na3sys009aog103.obsmtp.com ([74.125.149.71]) by canuck.infradead.org with smtps (Exim 4.76 #1 (Red Hat Linux)) id 1QMnec-0005e2-4O for linux-mtd@lists.infradead.org; Wed, 18 May 2011 20:47:38 +0000 Received: from mail-vx0-f181.google.com ([209.85.220.181]) (using TLSv1) by na3sys009aob103.postini.com ([74.125.148.12]) with SMTP ID DSNKTdQwY5YRCJcIKIkVZYXZCaOhRshd0rGr@postini.com; Wed, 18 May 2011 13:47:37 PDT Received: by mail-vx0-f181.google.com with SMTP id 39so1565189vxb.26 for ; Wed, 18 May 2011 13:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nanometrics.ca; s=google; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=MV7ydvD9MBhwlR/G63ZVb1AXssHgz3DOxA06A/yICvI=; b=X/ksFJEtaZtbK3h/TmB0G9GbM7nNVA2ooeCKbrb0iqrGXfA4c/pcBzON9eVxDfCMGo 21AHYjk+uY3uXSYiG6Oevuq6rfweHU74pzHwTGo5UR0ktQCQA0Je0Mv3xiv15Z7ZpNWT S2xPSIaLKbXXzgWTCvkBpzFqf6rib76AfsN6U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=nanometrics.ca; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=ifpiLZ6+hRjHBkhlSnWTXBQPxvGwL53Rs2VD3xqHrHmG5sjdd0ueba6osdYvXBT4nw FkBd9+nar3aA5asE00OUaN4AwU6n5fnTa7YaUT7e1eq8Zvup0GrzVjnMe0sh5yfJimSh 2ylr5wYzLuItTbe4CJyxhk5ONGICNw0xn2q9U= Received: by 10.220.194.139 with SMTP id dy11mr663195vcb.254.1305751650872; Wed, 18 May 2011 13:47:30 -0700 (PDT) Received: from localhost.localdomain ([206.191.47.130]) by mx.google.com with ESMTPS id e3sm176197vcn.3.2011.05.18.13.47.29 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 18 May 2011 13:47:30 -0700 (PDT) From: Ben Gardiner To: Artem Bityutskiy Subject: [PATCH] UBIFS: don't fail on -EBADMSG when fixing free space Date: Wed, 18 May 2011 16:47:27 -0400 Message-Id: <1305751647-3122-1-git-send-email-bengardiner@nanometrics.ca> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1305196419.2713.84.camel@localhost> References: <1305196419.2713.84.camel@localhost> X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110518_164738_418971_4988A6A1 X-CRM114-Status: GOOD ( 19.35 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [74.125.149.71 listed in list.dnswl.org] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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 Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, "Matthew L. Creech" , Adrian Hunter X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The free space fixup was introduced so that UBIFS on NAND flashes where the empty pages at the end need to be dropped when flashing or else -74 (aka -EBADMSG) failures will occur -- but due to the limited functionality of flash-programming facilities the emtpy pages cannot be dropped. In fixup_leb, which is called during free space fixup, the now-expected return code of -EBADMSG is treated as a failure. Don't fail when -EBADMSG is encountered during ubi_read. Signed-off-by: Ben Gardiner CC: Matthew L. Creech --- I tested this patch on-top-of l2 head : 'bbf2b37 UBIFS: fix extremely rare mount failure' using Matthew's 'mkfs.ubifs: add "-F" option for "free-space fixup"' patch to create the UBIFS image with the flag set. The test system was a da850evm, the image was flashed with U-boot's plain-old 'nand write' and the rootfs is mounted with 'ubi.mtd=X,2048 root=ubi0:rootfs rootfstype=ubifs' bootargs. Without this patch the first attemp to start fixing free space fails with -EBADMSG: UBIFS: start fixing up free space UBI error: ubi_io_read: error -74 (ECC error) while reading 4096 bytes from PEB 18:4096, read 4096 bytes VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0) [...] --- fs/ubifs/sb.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index c606f01..6e7da54 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c @@ -1,3 +1,4 @@ +#define DEBUG /* * This file is part of UBIFS. * @@ -679,7 +680,12 @@ static int fixup_leb(struct ubifs_info *c, int lnum, int len) dbg_mnt("fixup LEB %d, data len %d", lnum, len); err = ubi_read(c->ubi, lnum, c->sbuf, 0, len); - if (err) + /* + * Don't fail on -EBADMSG since these are precisely the error codes that + * are returned by ubi_red in the cases where free-space fix-ups are + * required. + */ + if (err && err != -EBADMSG) return err; return ubi_leb_change(c->ubi, lnum, c->sbuf, len, UBI_UNKNOWN);