From patchwork Fri Oct 17 15:19:13 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Belyakov X-Patchwork-Id: 4879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@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 C1B7EDDED7 for ; Sat, 18 Oct 2008 02:21:34 +1100 (EST) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1Kqr6k-0007Iu-VW; Fri, 17 Oct 2008 15:19:18 +0000 Received: from f225.mail.ru ([194.186.55.103]) by bombadil.infradead.org with esmtp (Exim 4.68 #1 (Red Hat Linux)) id 1Kqr6i-0007EM-Pt for linux-mtd@lists.infradead.org; Fri, 17 Oct 2008 15:19:17 +0000 Received: from mail by f225.mail.ru with local id 1Kqr6f-0005ZX-00; Fri, 17 Oct 2008 19:19:13 +0400 Received: from [192.55.52.1] by win.mail.ru with HTTP; Fri, 17 Oct 2008 19:19:13 +0400 From: Alexander Belyakov To: David Woodhouse , =?windows-1251?Q?linux-mtd=40lists.infradead.org?= Subject: [PATCH][JFFS2] Write buffer offset adjustment for NOR-ECC (Sibley) flash Mime-Version: 1.0 X-Mailer: mPOP Web-Mail 2.19 X-Originating-IP: unknown via proxy [192.55.52.1] Date: Fri, 17 Oct 2008 19:19:13 +0400 Message-Id: X-Spam: Not detected X-Mras: OK X-Spam-Score: 0.0 (/) Cc: Alexander Belyakov X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.9 Precedence: list Reply-To: Alexander Belyakov 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 choosing new c->nextblock, don't leave the wbuf offset field occasionally pointing at the start of the next physical eraseblock. This was causing a BUG() on NOR-ECC (Sibley) flash, where we start writing after the cleanmarker. Among other this fix should cover write buffer offset adjustment after flushing the last page of an eraseblock. Signed-off-by: Alexander Belyakov diff -uNrp a/fs/jffs2/nodemgmt.c b/fs/jffs2/nodemgmt.c --- a/fs/jffs2/nodemgmt.c 2008-08-20 22:11:37.000000000 +0400 +++ b/fs/jffs2/nodemgmt.c 2008-10-17 12:46:53.000000000 +0400 @@ -261,6 +261,10 @@ static int jffs2_find_nextblock(struct j jffs2_sum_reset_collected(c->summary); /* reset collected summary */ + /* adjust write buffer offset, else we get a non contiguous write bug */ + if (!(c->wbuf_ofs % c->sector_size) && !c->wbuf_len) + c->wbuf_ofs = 0xffffffff; + D1(printk(KERN_DEBUG "jffs2_find_nextblock(): new nextblock = 0x%08x\n", c->nextblock->offset)); return 0; diff -uNrp a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c --- a/fs/jffs2/wbuf.c 2008-08-20 22:11:37.000000000 +0400 +++ b/fs/jffs2/wbuf.c 2008-10-17 12:35:45.000000000 +0400 @@ -679,10 +679,7 @@ static int __jffs2_flush_wbuf(struct jff memset(c->wbuf,0xff,c->wbuf_pagesize); /* adjust write buffer offset, else we get a non contiguous write bug */ - if (SECTOR_ADDR(c->wbuf_ofs) == SECTOR_ADDR(c->wbuf_ofs+c->wbuf_pagesize)) - c->wbuf_ofs += c->wbuf_pagesize; - else - c->wbuf_ofs = 0xffffffff; + c->wbuf_ofs += c->wbuf_pagesize; c->wbuf_len = 0; return 0; }