diff options
Diffstat (limited to 'fs/jffs2/scan.c')
-rw-r--r-- | fs/jffs2/scan.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/fs/jffs2/scan.c b/fs/jffs2/scan.c index ded53584a897..76859ff53437 100644 --- a/fs/jffs2/scan.c +++ b/fs/jffs2/scan.c | |||
@@ -7,7 +7,7 @@ | |||
7 | * | 7 | * |
8 | * For licensing information, see the file 'LICENCE' in this directory. | 8 | * For licensing information, see the file 'LICENCE' in this directory. |
9 | * | 9 | * |
10 | * $Id: scan.c,v 1.115 2004/11/17 12:59:08 dedekind Exp $ | 10 | * $Id: scan.c,v 1.116 2005/02/09 09:09:02 pavlov Exp $ |
11 | * | 11 | * |
12 | */ | 12 | */ |
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
@@ -19,7 +19,7 @@ | |||
19 | #include <linux/compiler.h> | 19 | #include <linux/compiler.h> |
20 | #include "nodelist.h" | 20 | #include "nodelist.h" |
21 | 21 | ||
22 | #define EMPTY_SCAN_SIZE 1024 | 22 | #define DEFAULT_EMPTY_SCAN_SIZE 1024 |
23 | 23 | ||
24 | #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \ | 24 | #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \ |
25 | c->free_size -= _x; c->dirty_size += _x; \ | 25 | c->free_size -= _x; c->dirty_size += _x; \ |
@@ -75,6 +75,14 @@ static inline int min_free(struct jffs2_sb_info *c) | |||
75 | return min; | 75 | return min; |
76 | 76 | ||
77 | } | 77 | } |
78 | |||
79 | static inline uint32_t EMPTY_SCAN_SIZE(uint32_t sector_size) { | ||
80 | if (sector_size < DEFAULT_EMPTY_SCAN_SIZE) | ||
81 | return sector_size; | ||
82 | else | ||
83 | return DEFAULT_EMPTY_SCAN_SIZE; | ||
84 | } | ||
85 | |||
78 | int jffs2_scan_medium(struct jffs2_sb_info *c) | 86 | int jffs2_scan_medium(struct jffs2_sb_info *c) |
79 | { | 87 | { |
80 | int i, ret; | 88 | int i, ret; |
@@ -316,7 +324,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
316 | if (!buf_size) { | 324 | if (!buf_size) { |
317 | buf_len = c->sector_size; | 325 | buf_len = c->sector_size; |
318 | } else { | 326 | } else { |
319 | buf_len = EMPTY_SCAN_SIZE; | 327 | buf_len = EMPTY_SCAN_SIZE(c->sector_size); |
320 | err = jffs2_fill_scan_buf(c, buf, buf_ofs, buf_len); | 328 | err = jffs2_fill_scan_buf(c, buf, buf_ofs, buf_len); |
321 | if (err) | 329 | if (err) |
322 | return err; | 330 | return err; |
@@ -326,10 +334,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblo | |||
326 | ofs = 0; | 334 | ofs = 0; |
327 | 335 | ||
328 | /* Scan only 4KiB of 0xFF before declaring it's empty */ | 336 | /* Scan only 4KiB of 0xFF before declaring it's empty */ |
329 | while(ofs < EMPTY_SCAN_SIZE && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF) | 337 | while(ofs < EMPTY_SCAN_SIZE(c->sector_size) && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF) |
330 | ofs += 4; | 338 | ofs += 4; |
331 | 339 | ||
332 | if (ofs == EMPTY_SCAN_SIZE) { | 340 | if (ofs == EMPTY_SCAN_SIZE(c->sector_size)) { |
333 | #ifdef CONFIG_JFFS2_FS_NAND | 341 | #ifdef CONFIG_JFFS2_FS_NAND |
334 | if (jffs2_cleanmarker_oob(c)) { | 342 | if (jffs2_cleanmarker_oob(c)) { |
335 | /* scan oob, take care of cleanmarker */ | 343 | /* scan oob, take care of cleanmarker */ |
@@ -423,7 +431,7 @@ scan_more: | |||
423 | bail now */ | 431 | bail now */ |
424 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && | 432 | if (buf_ofs == jeb->offset && jeb->used_size == PAD(c->cleanmarker_size) && |
425 | c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_in_ino) { | 433 | c->cleanmarker_size && !jeb->dirty_size && !jeb->first_node->next_in_ino) { |
426 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE)); | 434 | D1(printk(KERN_DEBUG "%d bytes at start of block seems clean... assuming all clean\n", EMPTY_SCAN_SIZE(c->sector_size))); |
427 | return BLK_STATE_CLEANMARKER; | 435 | return BLK_STATE_CLEANMARKER; |
428 | } | 436 | } |
429 | 437 | ||