diff -urN -x CVS mtd/drivers/mtd/mtdpart.c mtd.new/drivers/mtd/mtdpart.c --- mtd/drivers/mtd/mtdpart.c Tue Jul 22 12:43:45 2003 +++ mtd.new/drivers/mtd/mtdpart.c Fri Jul 25 15:05:45 2003 @@ -399,8 +399,9 @@ if (slave->offset == MTDPART_OFS_APPEND) slave->offset = cur_offset; if (slave->offset == MTDPART_OFS_NXTBLK) { - u_int32_t emask = master->erasesize-1; - slave->offset = (cur_offset + emask) & ~emask; + slave->offset = cur_offset; + if ((cur_offset % master->erasesize) != 0) + slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize; if (slave->offset != cur_offset) { printk(KERN_NOTICE "Moving partition %d: " "0x%08x -> 0x%08x\n", i, diff -urN -x CVS mtd/fs/jffs2/erase.c mtd.new/fs/jffs2/erase.c --- mtd/fs/jffs2/erase.c Mon May 12 00:47:36 2003 +++ mtd.new/fs/jffs2/erase.c Fri Jul 25 14:56:53 2003 @@ -207,7 +207,8 @@ continue; } - if (((*prev)->flash_offset & ~(c->sector_size -1)) == jeb->offset) { + if (((*prev)->flash_offset >= jeb->offset) && + ((*prev)->flash_offset < (jeb->offset + c->sector_size))) { /* It's in the block we're erasing */ struct jffs2_raw_node_ref *this; diff -urN -x CVS mtd/fs/jffs2/gc.c mtd.new/fs/jffs2/gc.c --- mtd/fs/jffs2/gc.c Tue Jun 17 15:08:09 2003 +++ mtd.new/fs/jffs2/gc.c Fri Jul 25 14:57:54 2003 @@ -770,8 +770,7 @@ /* Doesn't matter if there's one in the same erase block. We're going to delete it too at the same time. */ - if ((raw->flash_offset & ~(c->sector_size-1)) == - (fd->raw->flash_offset & ~(c->sector_size-1))) + if ((raw->flash_offset / c->sector_size) == (fd->raw->flash_offset / c->sector_size)) continue; /* This is an obsolete node belonging to the same directory */ diff -urN -x CVS mtd/fs/jffs2/scan.c mtd.new/fs/jffs2/scan.c --- mtd/fs/jffs2/scan.c Tue Jul 22 12:44:10 2003 +++ mtd.new/fs/jffs2/scan.c Fri Jul 25 15:41:52 2003 @@ -19,7 +19,7 @@ #include #include "nodelist.h" -#define EMPTY_SCAN_SIZE 1024 +#define DEFAULT_EMPTY_SCAN_SIZE 1024 #define DIRTY_SPACE(x) do { typeof(x) _x = (x); \ c->free_size -= _x; c->dirty_size += _x; \ @@ -274,6 +274,13 @@ return 0; } +static inline uint32_t EMPTY_SCAN_SIZE(uint32_t sector_size) { + if (sector_size < DEFAULT_EMPTY_SCAN_SIZE) + return sector_size; + else + return DEFAULT_EMPTY_SCAN_SIZE; +} + static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb, unsigned char *buf, uint32_t buf_size) { struct jffs2_unknown_node *node; @@ -314,7 +321,7 @@ if (!buf_size) { buf_len = c->sector_size; } else { - buf_len = EMPTY_SCAN_SIZE; + buf_len = EMPTY_SCAN_SIZE(c->sector_size); err = jffs2_fill_scan_buf(c, buf, buf_ofs, buf_len); if (err) return err; @@ -324,10 +331,10 @@ ofs = 0; /* Scan only 4KiB of 0xFF before declaring it's empty */ - while(ofs < EMPTY_SCAN_SIZE && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF) + while(ofs < EMPTY_SCAN_SIZE(c->sector_size) && *(uint32_t *)(&buf[ofs]) == 0xFFFFFFFF) ofs += 4; - if (ofs == EMPTY_SCAN_SIZE) { + if (ofs == EMPTY_SCAN_SIZE(c->sector_size)) { #ifdef CONFIG_JFFS2_FS_NAND if (jffs2_cleanmarker_oob(c)) { /* scan oob, take care of cleanmarker */ @@ -404,8 +411,8 @@ /* If scanning empty space after only a cleanmarker, don't bother scanning the whole block */ if (unlikely(empty_start == jeb->offset + c->cleanmarker_size && - jeb->offset + EMPTY_SCAN_SIZE < buf_ofs + buf_len)) - scanend = jeb->offset + EMPTY_SCAN_SIZE - buf_ofs; + jeb->offset + EMPTY_SCAN_SIZE(c->sector_size) < buf_ofs + buf_len)) + scanend = jeb->offset + EMPTY_SCAN_SIZE(c->sector_size) - buf_ofs; else scanend = buf_len;