diff options
Diffstat (limited to 'fs/jffs2/readinode.c')
-rw-r--r-- | fs/jffs2/readinode.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c index 6c1ba3566f58..e512a93d6249 100644 --- a/fs/jffs2/readinode.c +++ b/fs/jffs2/readinode.c | |||
@@ -37,23 +37,24 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
37 | 37 | ||
38 | BUG_ON(tn->csize == 0); | 38 | BUG_ON(tn->csize == 0); |
39 | 39 | ||
40 | if (!jffs2_is_writebuffered(c)) | ||
41 | goto adj_acc; | ||
42 | |||
43 | /* Calculate how many bytes were already checked */ | 40 | /* Calculate how many bytes were already checked */ |
44 | ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); | 41 | ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); |
45 | len = ofs % c->wbuf_pagesize; | 42 | len = tn->csize; |
46 | if (likely(len)) | 43 | |
47 | len = c->wbuf_pagesize - len; | 44 | if (jffs2_is_writebuffered(c)) { |
48 | 45 | int adj = ofs % c->wbuf_pagesize; | |
49 | if (len >= tn->csize) { | 46 | if (likely(adj)) |
50 | dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", | 47 | adj = c->wbuf_pagesize - adj; |
51 | ref_offset(ref), tn->csize, ofs); | 48 | |
52 | goto adj_acc; | 49 | if (adj >= tn->csize) { |
53 | } | 50 | dbg_readinode("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", |
51 | ref_offset(ref), tn->csize, ofs); | ||
52 | goto adj_acc; | ||
53 | } | ||
54 | 54 | ||
55 | ofs += len; | 55 | ofs += adj; |
56 | len = tn->csize - len; | 56 | len -= adj; |
57 | } | ||
57 | 58 | ||
58 | dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", | 59 | dbg_readinode("check node at %#08x, data length %u, partial CRC %#08x, correct CRC %#08x, data starts at %#08x, start checking from %#08x - %u bytes.\n", |
59 | ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); | 60 | ref_offset(ref), tn->csize, tn->partial_crc, tn->data_crc, ofs - len, ofs, len); |
@@ -63,7 +64,7 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info | |||
63 | * adding and jffs2_flash_read_end() interface. */ | 64 | * adding and jffs2_flash_read_end() interface. */ |
64 | if (c->mtd->point) { | 65 | if (c->mtd->point) { |
65 | err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer); | 66 | err = c->mtd->point(c->mtd, ofs, len, &retlen, &buffer); |
66 | if (!err && retlen < tn->csize) { | 67 | if (!err && retlen < len) { |
67 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); | 68 | JFFS2_WARNING("MTD point returned len too short: %zu instead of %u.\n", retlen, tn->csize); |
68 | c->mtd->unpoint(c->mtd, buffer, ofs, retlen); | 69 | c->mtd->unpoint(c->mtd, buffer, ofs, retlen); |
69 | } else if (err) | 70 | } else if (err) |