From patchwork Tue May 3 22:56:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew L. Creech" X-Patchwork-Id: 93932 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 0E799B6F4C for ; Wed, 4 May 2011 08:57:28 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by bombadil.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QHOVw-0000Fo-1C; Tue, 03 May 2011 22:56:20 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1QHOVu-0004Da-7z; Tue, 03 May 2011 22:56:18 +0000 Received: from mail-vx0-f177.google.com ([209.85.220.177]) by canuck.infradead.org with esmtps (Exim 4.72 #1 (Red Hat Linux)) id 1QHOVr-0004DI-Nf for linux-mtd@lists.infradead.org; Tue, 03 May 2011 22:56:16 +0000 Received: by vxd2 with SMTP id 2so682676vxd.36 for ; Tue, 03 May 2011 15:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=SH20ybQSvyOXYOrJBCU4H5cwnaI0O+RgQvYzLVj6WOU=; b=oDiaYNbSTnidYJENtv3eAaXBF85X2vnOAxcwEJm/rj/gAzNwNSQE3bN/c7kja8epxz MyVZ9SnhALo0chPz2jPp2pKx3j1goC1nkqWqCgQwNMyzDctBNfDD6c2IsOSzDcqdEYOO HrG2liwSJOb88UGEF/azEplANb1v+ScHZ+wQ8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=LuH4tPgZgytBhs/BUiQTUidL6iq56QdG2b7XOLrOWMh4KbPUcTApbLt7dlf9F0q1pC N0ShwovBSVVaBIW+fcOTy9dfYeNz5682qgd/i5vO3i20/kCBTMRvkCGB9AvRSdKwS3qP kGR2fWZhmD19+FcGxHELkqP6170lqOPvSsd2I= MIME-Version: 1.0 Received: by 10.52.66.165 with SMTP id g5mr581708vdt.61.1304463375118; Tue, 03 May 2011 15:56:15 -0700 (PDT) Received: by 10.52.182.70 with HTTP; Tue, 3 May 2011 15:56:15 -0700 (PDT) Date: Tue, 3 May 2011 18:56:15 -0400 Message-ID: Subject: [PATCH] mkfs.ubifs: add "-F" option for "LEB fixup" From: "Matthew L. Creech" To: linux-mtd@lists.infradead.org X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110503_185615_890984_5014ECDF X-CRM114-Status: GOOD ( 17.77 ) X-Spam-Score: -0.8 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.8 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (mlcreech[at]gmail.com) -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 0.0 RFC_ABUSE_POST Both abuse and postmaster missing on sender domain 0.0 T_TO_NO_BRKTS_FREEMAIL T_TO_NO_BRKTS_FREEMAIL 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: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This adds a superblock flag indicating that "LEB fixup" is needed, and allows it to be set by the user via the "-F" command-line option. The first time the filesystem is mounted, this flag will trigger a one-time re-mapping of all LEBs with empty pages. This fixes problems seen on some NAND flashes when a non-UBIFS-aware flash programmer is used. Signed-off-by: Matthew L. Creech --- mkfs.ubifs/mkfs.ubifs.c | 11 ++++++++++- mkfs.ubifs/ubifs-media.h | 2 ++ mkfs.ubifs/ubifs.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletions(-) diff --git a/mkfs.ubifs/mkfs.ubifs.c b/mkfs.ubifs/mkfs.ubifs.c index a306dd6..35947a5 100644 --- a/mkfs.ubifs/mkfs.ubifs.c +++ b/mkfs.ubifs/mkfs.ubifs.c @@ -132,7 +132,7 @@ static struct inum_mapping **hash_table; /* Inode creation sequence number */ static unsigned long long creat_sqnum; -static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:p:k:x:X:j:R:l:j:UQq"; +static const char *optstring = "d:r:m:o:D:h?vVe:c:g:f:Fp:k:x:X:j:R:l:j:UQq"; static const struct option longopts[] = { {"root", 1, NULL, 'r'}, @@ -150,6 +150,7 @@ static const struct option longopts[] = { {"compr", 1, NULL, 'x'}, {"favor-percent", 1, NULL, 'X'}, {"fanout", 1, NULL, 'f'}, + {"leb-fixup", 0, NULL, 'F'}, {"keyhash", 1, NULL, 'k'}, {"log-lebs", 1, NULL, 'l'}, {"orph-lebs", 1, NULL, 'p'}, @@ -183,6 +184,7 @@ static const char *helptext = " how many percent better zlib should compress to make\n" " mkfs.ubifs use zlib instead of LZO (default 20%)\n" "-f, --fanout=NUM fanout NUM (default: 8)\n" +"-F, --lex-fixup fixup LEBs on first mount (needed for some NANDs)\n" "-k, --keyhash=TYPE key hash type - \"r5\" or \"test\" (default: \"r5\")\n" "-p, --orph-lebs=COUNT count of erase blocks for orphans (default: 1)\n" "-D, --devtable=FILE use device table FILE\n" @@ -537,6 +539,7 @@ static int get_options(int argc, char**argv) c->max_leb_cnt = -1; c->max_bud_bytes = -1; c->log_lebs = -1; + c->leb_fixup = 0; while (1) { opt = getopt_long(argc, argv, optstring, longopts, &i); @@ -610,6 +613,9 @@ static int get_options(int argc, char**argv) if (*endp != '\0' || endp == optarg || c->fanout <= 0) return err_msg("bad fanout %s", optarg); break; + case 'F': + c->leb_fixup = 1; + break; case 'l': c->log_lebs = strtol(optarg, &endp, 0); if (*endp != '\0' || endp == optarg || c->log_lebs <= 0) @@ -758,6 +764,7 @@ static int get_options(int argc, char**argv) "r5" : "test"); printf("\tfanout: %d\n", c->fanout); printf("\torph_lebs: %d\n", c->orph_lebs); + printf("\tleb_fixup: %d\n", c->leb_fixup); } if (validate_options()) @@ -1997,6 +2004,8 @@ static int write_super(void) } if (c->big_lpt) sup.flags |= cpu_to_le32(UBIFS_FLG_BIGLPT); + if (c->leb_fixup) + sup.flags |= cpu_to_le32(UBIFS_FLG_LEB_FIXUP); return write_node(&sup, UBIFS_SB_NODE_SZ, UBIFS_SB_LNUM, UBI_LONGTERM); } diff --git a/mkfs.ubifs/ubifs-media.h b/mkfs.ubifs/ubifs-media.h index a9ecbd9..bb93f64 100644 --- a/mkfs.ubifs/ubifs-media.h +++ b/mkfs.ubifs/ubifs-media.h @@ -373,9 +373,11 @@ enum { * Superblock flags. * * UBIFS_FLG_BIGLPT: if "big" LPT model is used if set + * UBIFS_FLG_LEB_FIXUP: first-mount "fixup" of empty pages in LEBs needed */ enum { UBIFS_FLG_BIGLPT = 0x02, + UBIFS_FLG_LEB_FIXUP = 0x04, }; /** diff --git a/mkfs.ubifs/ubifs.h b/mkfs.ubifs/ubifs.h index 5c29046..57ec8df 100644 --- a/mkfs.ubifs/ubifs.h +++ b/mkfs.ubifs/ubifs.h @@ -317,6 +317,7 @@ struct ubifs_znode * @nhead_lnum: LEB number of LPT head * @nhead_offs: offset of LPT head * @big_lpt: flag that LPT is too big to write whole during commit + * @leb_fixup: flag indicating that empty space in LEBs needs to be cleaned up * @lpt_sz: LPT size * * @ltab_lnum: LEB number of LPT's own lprops table @@ -394,6 +395,7 @@ struct ubifs_info int nhead_lnum; int nhead_offs; int big_lpt; + int leb_fixup; long long lpt_sz; int ltab_lnum;