From: Estelle HAMMACHE <estelle.hammache@st.com>
To: "Artem B. Bityuckiy" <abityuckiy@yandex.ru>
Cc: linux-mtd@lists.infradead.org
Subject: Re: JFFS2 & SMP
Date: Fri, 05 Nov 2004 10:06:55 +0100 [thread overview]
Message-ID: <418B42AF.4457A6FD@st.com> (raw)
In-Reply-To: 418A643B.2070806@yandex.ru
Artem,
you are right of course. The patch I proposed would only make sense
in a very specific environment which is very different from the
way JFFS2 and linux work. So you can forget about my previous message.
I guess there is no way around using a mutex.
Estelle
"Artem B. Bityuckiy" wrote:
>
> Estelle,
>
> I don't cleanly understand your Idea, I'll think more.
>
> Could you please answer: does it handle the following "use-case" (if
> yes, how?):
>
> Suppose we are reading node, which is in the wbuf so far.
>
> int jffs2_flash_read(struct jffs2_sb_info *c, loff_t ofs, size_t len,
> size_t *retlen, u_char *buf)
> {
> loff_t orbf = 0, owbf = 0, lwbf = 0;
> int ret;
>
> /* Read flash */
> if (!jffs2_can_mark_obsolete(c)) {
> ret = c->mtd->read_ecc(c->mtd, ofs, len, retlen, buf,
> NULL, c->oobinfo);
>
> if ( (ret == -EBADMSG) && (*retlen == len) ) {
> printk(KERN_WARNING "mtd->read(0x%zx bytes from
> 0x%llx) returned ECC error\n",
> len, ofs);
> /*
> * We have the raw data without ECC correction
> in the buffer, maybe
> * we are lucky and all data or parts are
> correct. We check the node.
> * If data are corrupted node check will sort
> it out.
> * We keep this block, it will fail on write or
> erase and the we
> * mark it bad. Or should we do that now? But
> we should give him a chance.
> * Maybe we had a system crash or power loss
> before the ecc write or
> * a erase was completed.
> * So we return success. :)
> */
> ret = 0;
> }
> } else
> return c->mtd->read(c->mtd, ofs, len, retlen, buf);
> /*________________________
> Suppose the page we have read is empty because of its data is still in
> wbuf. We have read all 0xFF. Suppose we are preempted at this point.
> Somebody else made write, the wbuf became full and was flushed to the
> correspondent flash page. Then we wake up. We see, the wbuf_len == 0.
> And we exit. Result: we have read all 0xFF instead of node....
> ________________________*/
>
> /* if no writebuffer available or write buffer empty, return */
> if (!c->wbuf_pagesize || !c->wbuf_len)
> return ret; /* <---------------------- we exit here.... */
>
> /* if we read in a different block, return */
> if ( (ofs & ~(c->sector_size-1)) != (c->wbuf_ofs &
> ~(c->sector_size-1)) )
> return ret;
>
> if (ofs >= c->wbuf_ofs) {
> owbf = (ofs - c->wbuf_ofs); /* offset in write
> buffer */
> if (owbf > c->wbuf_len) /* is read beyond write
> buffer ? */
> return ret;
> lwbf = c->wbuf_len - owbf; /* number of bytes to
> copy */
> if (lwbf > len)
> lwbf = len;
> } else {
> orbf = (c->wbuf_ofs - ofs); /* offset in read buffer */
> if (orbf > len) /* is write beyond
> write buffer ? */
> return ret;
> lwbf = len - orbf; /* number of bytes to
> copy */
> if (lwbf > c->wbuf_len)
> lwbf = c->wbuf_len;
> }
> if (lwbf > 0)
> memcpy(buf+orbf,c->wbuf+owbf,lwbf);
>
> return ret;
> }
>
next prev parent reply other threads:[~2004-11-05 9:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-27 12:35 JFFS2 & SMP Artem B. Bityuckiy
2004-10-27 12:59 ` David Woodhouse
2004-10-27 13:19 ` Artem B. Bityuckiy
2004-10-27 13:35 ` Artem B. Bityuckiy
2004-10-27 13:45 ` David Woodhouse
2004-10-27 14:09 ` Artem B. Bityuckiy
2004-10-27 14:59 ` Artem B. Bityuckiy
2004-10-27 15:07 ` Artem B. Bityuckiy
2004-10-28 12:14 ` Artem B. Bityuckiy
2004-10-28 12:33 ` Artem B. Bityuckiy
2004-10-28 13:57 ` Artem B. Bityuckiy
2004-11-02 14:31 ` Estelle HAMMACHE
2004-11-03 16:29 ` Artem B. Bityuckiy
2004-11-04 9:03 ` Estelle HAMMACHE
2004-11-04 9:36 ` Artem B. Bityuckiy
[not found] ` <418A591C.A4D46C9E@st.com>
2004-11-04 17:17 ` Artem B. Bityuckiy
2004-11-05 9:06 ` Estelle HAMMACHE [this message]
2004-11-05 11:51 ` Artem B. Bityuckiy
2004-11-03 16:39 ` Artem B. Bityuckiy
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=418B42AF.4457A6FD@st.com \
--to=estelle.hammache@st.com \
--cc=abityuckiy@yandex.ru \
--cc=linux-mtd@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox