aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jffs2/scan.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/jffs2/scan.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'fs/jffs2/scan.c')
-rw-r--r--fs/jffs2/scan.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c
index 46f870d1cc36..8d8cd3419d02 100644
--- a/fs/jffs2/scan.c
+++ b/fs/jffs2/scan.c
@@ -20,7 +20,7 @@
20#include "summary.h" 20#include "summary.h"
21#include "debug.h" 21#include "debug.h"
22 22
23#define DEFAULT_EMPTY_SCAN_SIZE 1024 23#define DEFAULT_EMPTY_SCAN_SIZE 256
24 24
25#define noisy_printk(noise, args...) do { \ 25#define noisy_printk(noise, args...) do { \
26 if (*(noise)) { \ 26 if (*(noise)) { \
@@ -94,7 +94,7 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
94 uint32_t buf_size = 0; 94 uint32_t buf_size = 0;
95 struct jffs2_summary *s = NULL; /* summary info collected by the scan process */ 95 struct jffs2_summary *s = NULL; /* summary info collected by the scan process */
96#ifndef __ECOS 96#ifndef __ECOS
97 size_t pointlen; 97 size_t pointlen, try_size;
98 98
99 if (c->mtd->point) { 99 if (c->mtd->point) {
100 ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen, 100 ret = c->mtd->point(c->mtd, 0, c->mtd->size, &pointlen,
@@ -113,18 +113,21 @@ int jffs2_scan_medium(struct jffs2_sb_info *c)
113 /* For NAND it's quicker to read a whole eraseblock at a time, 113 /* For NAND it's quicker to read a whole eraseblock at a time,
114 apparently */ 114 apparently */
115 if (jffs2_cleanmarker_oob(c)) 115 if (jffs2_cleanmarker_oob(c))
116 buf_size = c->sector_size; 116 try_size = c->sector_size;
117 else 117 else
118 buf_size = PAGE_SIZE; 118 try_size = PAGE_SIZE;
119 119
120 /* Respect kmalloc limitations */ 120 D1(printk(KERN_DEBUG "Trying to allocate readbuf of %zu "
121 if (buf_size > 128*1024) 121 "bytes\n", try_size));
122 buf_size = 128*1024;
123 122
124 D1(printk(KERN_DEBUG "Allocating readbuf of %d bytes\n", buf_size)); 123 flashbuf = mtd_kmalloc_up_to(c->mtd, &try_size);
125 flashbuf = kmalloc(buf_size, GFP_KERNEL);
126 if (!flashbuf) 124 if (!flashbuf)
127 return -ENOMEM; 125 return -ENOMEM;
126
127 D1(printk(KERN_DEBUG "Allocated readbuf of %zu bytes\n",
128 try_size));
129
130 buf_size = (uint32_t)try_size;
128 } 131 }
129 132
130 if (jffs2_sum_active()) { 133 if (jffs2_sum_active()) {
@@ -435,7 +438,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
435 unsigned char *buf, uint32_t buf_size, struct jffs2_summary *s) { 438 unsigned char *buf, uint32_t buf_size, struct jffs2_summary *s) {
436 struct jffs2_unknown_node *node; 439 struct jffs2_unknown_node *node;
437 struct jffs2_unknown_node crcnode; 440 struct jffs2_unknown_node crcnode;
438 uint32_t ofs, prevofs; 441 uint32_t ofs, prevofs, max_ofs;
439 uint32_t hdr_crc, buf_ofs, buf_len; 442 uint32_t hdr_crc, buf_ofs, buf_len;
440 int err; 443 int err;
441 int noise = 0; 444 int noise = 0;
@@ -550,12 +553,12 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo
550 553
551 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */ 554 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
552 ofs = 0; 555 ofs = 0;
553 556 max_ofs = EMPTY_SCAN_SIZE(c->sector_size);
554 /* Scan only 4KiB of 0xFF before declaring it's empty */ 557 /* Scan only EMPTY_SCAN_SIZE of 0xFF before declaring it's empty */
555 while(ofs < EMPTY_SCAN_SIZE(c->sector_size) && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF) 558 while(ofs < max_ofs && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF)
556 ofs += 4; 559 ofs += 4;
557 560
558 if (ofs == EMPTY_SCAN_SIZE(c->sector_size)) { 561 if (ofs == max_ofs) {
559#ifdef CONFIG_JFFS2_FS_WRITEBUFFER 562#ifdef CONFIG_JFFS2_FS_WRITEBUFFER
560 if (jffs2_cleanmarker_oob(c)) { 563 if (jffs2_cleanmarker_oob(c)) {
561 /* scan oob, take care of cleanmarker */ 564 /* scan oob, take care of cleanmarker */