From 04574ba1c6233a09578988d565a4cc3f2e27f723 Mon Sep 17 00:00:00 2001 From: Jean Pihet Date: Wed, 9 Apr 2008 11:04:32 +0200 Subject: [PATCH] mtd jffs2: Fix non contiguous write BUG, warning about 'len too short' Merged 2 fixes from mtd-jffs2-stable-linux-2.6.23 at http://sourceforge.net/projects/mtd-mods: - non contiguous write BUG - false warning about 'len too short' Cf. http://sourceforge.net/project/showfiles.php?group_id=207166&package_id=261645 for archive download Tested with intensive (2+ GB data) simultaneous read/write, flash fill-up, data removal cycles Signed-off-by: Jean Pihet --- fs/jffs2/readinode.c | 2 +- fs/jffs2/wbuf.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-) diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 2eae5d2..20efdda 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c @@ -63,7 +63,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info * adding and jffs2_flash_read_end() interface. */ if (c->mtd->point) { err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer); - if (!err && retlen < tn->csize) { + if (!err && retlen < len) { JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); c->mtd->unpoint(c->mtd, buffer, ofs, retlen); } else if (err) diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index d1d4f27..e023511 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c @@ -888,6 +888,10 @@ int jffs2_flash_writev(struct jffs2_sb_info *c, const struct kvec *invecs, donelen += wbuf_retlen; } + /* 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; + /* * If there's a remainder in the wbuf and it's a non-GC write, * remember that the wbuf affects this ino -- 1.5.4.1.159.gc4a6c