From: David Woodhouse <dwmw2@infradead.org>
To: "Steve Tsai" <startec@ms11.hinet.net>
Cc: "'Thomas Gleixner'" <tglx@linutronix.de>,
"Linux MTD mailing list" <linux-mtd@lists.infradead.org>
Subject: Re: NAND Configuration
Date: Thu, 08 Aug 2002 12:05:45 +0100 [thread overview]
Message-ID: <12213.1028804745@redhat.com> (raw)
In-Reply-To: <002c01c23ebf$40a81c70$5501a8c0@synso.com.tw>
startec@ms11.hinet.net said:
> In jffs2_wbuf_process, when free_size is smaller than (c->
> wbuf_pagesize - c->wbuf_len), jffs2_flush_wbuf(c, 1) was called, but
> free_size will not be assigned right value. In the case, the block can
> not be used anymore because the last page in the block was used here,
> but jffs2_do_reserve_space does not know. jffs2_do_reserve_space will
> use the block, if minsize > jeb->free_size and it maybe happen here.
Try this (it's in CVS)....
Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -p -r1.12 -r1.13
--- wbuf.c 20 May 2002 14:56:39 -0000 1.12
+++ wbuf.c 8 Aug 2002 11:04:40 -0000 1.13
@@ -7,7 +7,7 @@
*
* For licensing information, see the file 'LICENCE' in this directory.
*
- * $Id: wbuf.c,v 1.12 2002/05/20 14:56:39 dwmw2 Exp $
+ * $Id: wbuf.c,v 1.13 2002/08/08 11:04:40 dwmw2 Exp $
*
*/
@@ -80,17 +80,33 @@ void jffs2_wbuf_process (void *data)
D1(printk(KERN_DEBUG "jffs2_wbuf_process() entered\n"));
- if (!down_trylock(&c->alloc_sem)) {
- D1(printk (KERN_DEBUG "jffs2_wbuf_process() alloc_sem got\n"));
-
- if(!c->nextblock || (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len)))
- jffs2_flush_wbuf(c, 1); /* pad only */
- else
- jffs2_flush_wbuf(c, 2); /* pad and adjust nextblock */
- up(&c->alloc_sem);
- } else {
+ if (down_trylock(&c->alloc_sem)) {
+ /* If someone else has the alloc_sem, they're about to
+ write anyway. So no need to waste space by
+ padding */
D1(printk (KERN_DEBUG "jffs2_wbuf_process() alloc_sem already occupied\n"));
+ return;
}
+
+ D1(printk (KERN_DEBUG "jffs2_wbuf_process() alloc_sem got\n"));
+
+ if (!c->nextblock) {
+ D1(printk(KERN_DEBUG "jffs2_wbuf_process(): nextblock NULL, nothing to do\n"));
+ if (c->wbuf_len) {
+ printk(KERN_WARNING "jffs2_wbuf_process(): c->wbuf_len is 0x%03x but nextblock is NULL!\n", c->wbuf_len);
+ up(&c->alloc_sem);
+ BUG();
+ }
+ return;
+ }
+
+
+ /* if !c->nextblock then the tail will have got flushed from
+ jffs2_do_reserve_space() anyway. */
+ if(c->nextblock)
+ jffs2_flush_wbuf(c, 2); /* pad and adjust nextblock */
+
+ up(&c->alloc_sem);
}
@@ -166,8 +182,16 @@ int jffs2_flush_wbuf(struct jffs2_sb_inf
spin_lock_bh(&c->erase_completion_lock);
if (!c->nextblock)
BUG();
- if (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len))
+ /* wbuf_pagesize - wbuf_len is the amount of space that's to be
+ padded. If there is less free space in the block than that,
+ something screwed up */
+ if (c->nextblock->free_size < (c->wbuf_pagesize - c->wbuf_len)) {
+ printk(KERN_CRIT "jffs2_flush_wbuf(): Accounting error. wbuf at 0x%08x has 0x%03x bytes, 0x%03x left.\n",
+ c->wbuf_ofs, c->wbuf_len, c->wbuf_pagesize-c->wbuf_len);
+ printk(KERN_CRIT "jffs2_flush_wbuf(): But free_size for block at 0x%08x is only 0x%08x\n",
+ c->nextblock->offset, c->nextblock->free_size);
BUG();
+ }
c->nextblock->free_size -= (c->wbuf_pagesize - c->wbuf_len);
c->nextblock->dirty_size += (c->wbuf_pagesize - c->wbuf_len);
spin_unlock_bh(&c->erase_completion_lock);
--
dwmw2
next prev parent reply other threads:[~2002-08-08 11:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-06 7:25 NAND Configuration Steve Tsai
2002-08-06 9:07 ` Thomas Gleixner
2002-08-06 10:40 ` Steve Tsai
2002-08-06 12:16 ` Thomas Gleixner
2002-08-07 9:08 ` Steve Tsai
2002-08-07 10:05 ` David Woodhouse
2002-08-07 10:19 ` Steve Tsai
2002-08-07 10:49 ` Thomas Gleixner
2002-08-07 21:11 ` Alice Hennessy
2002-08-08 8:59 ` Thomas Gleixner
2002-08-08 9:14 ` David Woodhouse
2002-08-08 9:28 ` Thomas Gleixner
2002-08-08 2:47 ` Steve Tsai
2002-08-08 5:23 ` Steve Tsai
2002-08-08 9:11 ` Thomas Gleixner
2002-08-08 9:37 ` Steve Tsai
2002-08-08 11:05 ` David Woodhouse [this message]
2002-08-09 6:53 ` Steve Tsai
2002-08-09 8:09 ` Thomas Gleixner
2002-08-10 7:54 ` Steve Tsai
2002-08-10 8:41 ` Thomas Gleixner
2002-08-12 6:30 ` Steve Tsai
2002-08-06 9:45 ` Thomas Gleixner
2002-08-06 10:25 ` Steve Tsai
2002-08-06 12:28 ` Thomas Gleixner
2002-08-06 12:32 ` David Woodhouse
2002-08-06 12:40 ` Thomas Gleixner
2002-08-07 10:45 ` Steve Tsai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=12213.1028804745@redhat.com \
--to=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=startec@ms11.hinet.net \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.