From patchwork Wed May 15 16:21:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dirk Behme X-Patchwork-Id: 244130 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5169B2C009E for ; Thu, 16 May 2013 02:22:01 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UceSQ-00063n-6r; Wed, 15 May 2013 16:21:38 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UceSO-0004tu-1A; Wed, 15 May 2013 16:21:36 +0000 Received: from mail-bk0-x22c.google.com ([2a00:1450:4008:c01::22c]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UceSL-0004tS-7C for linux-mtd@lists.infradead.org; Wed, 15 May 2013 16:21:34 +0000 Received: by mail-bk0-f44.google.com with SMTP id jk13so1109600bkc.3 for ; Wed, 15 May 2013 09:21:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:mime-version :content-type:content-transfer-encoding; bh=ssq75M9fs/tLNer/l2Ax+k/MOsoSt4oaPBh06KGyHEg=; b=INjROALbr2LjwLnH7CtH86ifar8kWu/Xum5CSTTZcQK664YNh93kQ0yfkNN0BSUyf7 fk8XAD0+Ln58U79UpNwZ0OCKp5fo0dgZXnESE9Ylg+jR+bLxYb1RUQn6oedsnDM/d6xS WacdsFzgFd7PHvJCowUYFPMjjk+b/6iqptwI75A+nR9DJlsFtKIDkDf+GAUmZ6JIpxWy ZLgelHPX/sYa4aFWSA0+rd83YnUo7P5BSWGLSx5qKul/m2RUTLn/5yAW+HPfYvrwVygS iawXpD1RcSPugnw6pniFYfyUSmgrOvgRf4ouktKUvXddZZMvElrMuFl187z4SiWt5Wf2 Z30g== X-Received: by 10.204.185.201 with SMTP id cp9mr736512bkb.128.1368634870657; Wed, 15 May 2013 09:21:10 -0700 (PDT) Received: from localhost.localdomain (p4FEE3F6F.dip0.t-ipconnect.de. [79.238.63.111]) by mx.google.com with ESMTPSA id tc9sm1049322bkb.18.2013.05.15.09.21.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 15 May 2013 09:21:09 -0700 (PDT) From: Dirk Behme To: linux-mtd@lists.infradead.org Subject: [PATCH] UBIFS: add tolerance to use variable writesize Date: Wed, 15 May 2013 18:21:05 +0200 Message-Id: <1368634865-4186-1-git-send-email-dirk.behme@gmail.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130515_122133_399085_6006EBA8 X-CRM114-Status: GOOD ( 15.32 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (dirk.behme[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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: dirk.behme@de.bosch.com, Achim Dahlhoff , dedekind1@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Achim Dahlhoff UBIfs adapts it‘s structures according to the minimum writeSize reported by the MTD device. For NOR flash devices, this is normally 1. For NOR devices with internal hardware-ECC it might be more, such as the S-Die flash chips of Micron which can use an internal ECC if the chip is accessed in 32 byte chunks. The UBIfs mount process checks and compares the writeSize set in the image and the writeSize reported from the /dev/mtd . UBIfs will fail to mount if the values differ. It should, though, not be a problem to mount an image which was created with a writeSize larger than that of the MTD, if it is larger by an integer factor. This commit changes the check in a way so it will allow the image writeSize to be larger than that of the MTD by an integer factor. It will allow to create images and deploy them on different devices using different writeSizes. writeSize found using values of 1, 8 and 32. Signed-off-by: Achim Dahlhoff --- fs/ubifs/sb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/ubifs/sb.c b/fs/ubifs/sb.c index 4c37607..69dd794 100644 --- a/fs/ubifs/sb.c +++ b/fs/ubifs/sb.c @@ -351,6 +351,7 @@ static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup) { long long max_bytes; int err = 1, min_leb_cnt; + int chk_tmp; if (!c->key_hash) { err = 2; @@ -362,9 +363,16 @@ static int validate_sb(struct ubifs_info *c, struct ubifs_sb_node *sup) goto failed; } - if (le32_to_cpu(sup->min_io_size) != c->min_io_size) { + /* + * Allow a min_io_size mismatch in the way that + * the size in the superblock (the image) is larger by + * an integer factor. If image-IOsize mod real-IOsize + * is zero, it should be ok to mount this. + */ + chk_tmp = le32_to_cpu(sup->min_io_size); + if (chk_tmp != c->min_io_size && ((chk_tmp%c->min_io_size) != 0)) { ubifs_err("min. I/O unit mismatch: %d in superblock, %d real", - le32_to_cpu(sup->min_io_size), c->min_io_size); + chk_tmp, c->min_io_size); goto failed; }