From patchwork Thu Oct 15 07:47:21 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Kagstrom X-Patchwork-Id: 36080 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 43BC3B7B69 for ; Thu, 15 Oct 2009 18:49:44 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MyL3h-0006bx-RM; Thu, 15 Oct 2009 07:47:37 +0000 Received: from ernst.netinsight.se ([194.16.221.21]) by bombadil.infradead.org with smtp (Exim 4.69 #1 (Red Hat Linux)) id 1MyL3a-0006b4-AU for linux-mtd@lists.infradead.org; Thu, 15 Oct 2009 07:47:35 +0000 Received: from marrow.netinsight.se (unverified [10.100.3.78]) by ernst.netinsight.se (EMWAC SMTPRS 0.83) with SMTP id ; Thu, 15 Oct 2009 09:47:19 +0200 Date: Thu, 15 Oct 2009 09:47:21 +0200 From: Simon Kagstrom To: Artem Bityutskiy , linux-mtd Subject: [PATCH v7 1/5]: mtdoops: avoid erasing already empty areas Message-ID: <20091015094721.6c85cc48@marrow.netinsight.se> In-Reply-To: <20091015094057.7298e0d7@marrow.netinsight.se> References: <20091015094057.7298e0d7@marrow.netinsight.se> X-Mailer: Claws Mail 3.7.3 (GTK+ 2.16.1; i486-pc-linux-gnu) Mime-Version: 1.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20091015_034730_585609_2CE06C79 X-CRM114-Status: GOOD ( 12.77 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.2.5 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- _SUMMARY_ Cc: David Woodhouse 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 After having scanned the entire mtdoops area, mtdoops will erase it if there are no mtdoops headers in it. However, empty and already erased areas (i.e., without mtdoops headers) will therefore also be erased at each startup. This patch counts the number of unclean pages (neither empty nor with the mtdoops header) and only erases if no headers are found and the area is still unclean. Signed-off-by: Simon Kagstrom --- drivers/mtd/mtdoops.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 18c6c96..c785e1a 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c @@ -225,7 +225,7 @@ static void mtdoops_workfunc_write(struct work_struct *work) static void find_next_position(struct mtdoops_context *cxt) { struct mtd_info *mtd = cxt->mtd; - int ret, page, maxpos = 0; + int ret, page, maxpos = 0, unclean_pages = 0; u32 count[2], maxcount = 0xffffffff; size_t retlen; @@ -237,10 +237,13 @@ static void find_next_position(struct mtdoops_context *cxt) continue; } - if (count[1] != MTDOOPS_KERNMSG_MAGIC) - continue; if (count[0] == 0xffffffff) continue; + if (count[1] != MTDOOPS_KERNMSG_MAGIC) { + /* Page is neither clean nor empty */ + unclean_pages++; + continue; + } if (maxcount == 0xffffffff) { maxcount = count[0]; maxpos = page; @@ -259,7 +262,14 @@ static void find_next_position(struct mtdoops_context *cxt) if (maxcount == 0xffffffff) { cxt->nextpage = 0; cxt->nextcount = 1; - schedule_work(&cxt->work_erase); + if (unclean_pages != 0) { + printk(KERN_INFO "mtdoops: cleaning area\n"); + schedule_work(&cxt->work_erase); + } else { + printk(KERN_DEBUG "mtdoops: ready %d, %d (clean)\n", + cxt->nextpage, cxt->nextcount); + cxt->ready = 1; + } return; }