From patchwork Mon Oct 12 11:07:19 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Kagstrom X-Patchwork-Id: 35748 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 8438FB7B68 for ; Mon, 12 Oct 2009 22:09:23 +1100 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MxIka-0003ab-Ed; Mon, 12 Oct 2009 11:07:36 +0000 Received: from ernst.netinsight.se ([194.16.221.21]) by bombadil.infradead.org with smtp (Exim 4.69 #1 (Red Hat Linux)) id 1MxIkQ-00037l-W1 for linux-mtd@lists.infradead.org; Mon, 12 Oct 2009 11:07:33 +0000 Received: from marrow.netinsight.se (unverified [10.100.3.78]) by ernst.netinsight.se (EMWAC SMTPRS 0.83) with SMTP id ; Mon, 12 Oct 2009 13:07:19 +0200 Date: Mon, 12 Oct 2009 13:07:19 +0200 From: Simon Kagstrom To: linux-mtd Subject: [PATCH v4 1/4]: mtdoops: avoid erasing already empty areas Message-ID: <20091012130719.372d0f5a@marrow.netinsight.se> In-Reply-To: <20091012130635.45b76b34@marrow.netinsight.se> References: <20091002160510.191ef5a4@marrow.netinsight.se> <20091008172516.64b5c462@marrow.netinsight.se> <20091012130635.45b76b34@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-20091012_070727_311214_76C12E06 X-CRM114-Status: GOOD ( 11.58 ) 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: Artem.Bityutskiy@nokia.com, Aaro Koskinen 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; }