Skip to contentSkip to conversation

2.6.8-rc3 slab corruption (jffs2?)

BUG Russell King 4 participants 11 messages Aug 7, 2004 – Aug 10, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Not sure exactly what caused this, but it happened while logging in (after fixing the previous two reported problems - the first by backing out the last change to redboot.c and the second by commenting out ri->usercompr in fs/jffs2/read.c.)

Slab corruption: start=c1e39474, len=64
Redzone: 0x5a2cf071/0x5a2cf071.
Last user: [<c032ca10>](cfi_intelext_erase_varsize+0x58/0x64) 000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 4f 6b
Prev obj: start=c1e39428, len=64
Redzone: 0x5a2cf071/0x5a2cf071.
Last user: [<c02c767c>](jffs2_garbage_collect_deletion_dirent+0x80/0x8c) 000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
Next obj: start=c1e394c0, len=64
Redzone: 0x170fc2a5/0x170fc2a5.
Last user: [<c03514f8>](neigh_hh_init+0x64/0x11c)
000: 00 00 00 00 03 00 00 00 08 00 00 00 0e 00 00 00
010: 00 b0 34 c0 00 00 08 00 2b 95 1d 7b 00 c0 1b 00

Due to tail call optimisation, its difficult to work out exactly what's going on, but the first seems to be a kfree call from the erase callback (possibly jffs2_erase_callback). The second function is the call to jffs2_free_full_dirent() in jffs2_garbage_collect_deletion_dirent().

Any ideas? I haven't been able to reproduce (presumably because the erase succeeded, and we didn't need to re-erase again.)

Signature · 4 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core
maintainer
#1 lore raw
Quoted 2 lines · Russell King

Any ideas? I haven't been able to reproduce (presumably because the erase succeeded, and we didn't need to re-erase again.)

Hmmm. None right now. Will take a closer look in the morning. Thanks for the reports.

Signature · 1 line
dwmw2
#2 lore raw
In reply to Russell King

Can't figure out why but have a quick workaround for this:

fs/jffs2/erase.c +3 -2
@@ -72,8 +72,10 @@
 	((struct erase_priv_struct *)instr->priv)->c = c;
 
 	ret = c->mtd->erase(c->mtd, instr);
-	if (!ret)
+	if (!ret) {
+		kfree(instr);
 		return;
+	}
 
 	bad_offset = instr->fail_addr;
 	kfree(instr);
@@ -206,7 +208,6 @@
 	} else {
 		jffs2_erase_succeeded(priv->c, priv->jeb);
 	}	
-	kfree(instr);
 }
 #endif /* !__ECOS */
 
Quoted 37 lines · Russell King

Not sure exactly what caused this, but it happened while logging in (after fixing the previous two reported problems - the first by backing out the last change to redboot.c and the second by commenting out ri->usercompr in fs/jffs2/read.c.)

Slab corruption: start=c1e39474, len=64
Redzone: 0x5a2cf071/0x5a2cf071.
Last user: [<c032ca10>](cfi_intelext_erase_varsize+0x58/0x64) 000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 4f 6b
Prev obj: start=c1e39428, len=64
Redzone: 0x5a2cf071/0x5a2cf071.
Last user: [<c02c767c>](jffs2_garbage_collect_deletion_dirent+0x80/0x8c) 000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
Next obj: start=c1e394c0, len=64
Redzone: 0x170fc2a5/0x170fc2a5.
Last user: [<c03514f8>](neigh_hh_init+0x64/0x11c)
000: 00 00 00 00 03 00 00 00 08 00 00 00 0e 00 00 00
010: 00 b0 34 c0 00 00 08 00 2b 95 1d 7b 00 c0 1b 00

Due to tail call optimisation, its difficult to work out exactly what's going on, but the first seems to be a kfree call from the erase callback (possibly jffs2_erase_callback). The second function is the call to jffs2_free_full_dirent() in jffs2_garbage_collect_deletion_dirent().

Any ideas? I haven't been able to reproduce (presumably because the erase succeeded, and we didn't need to re-erase again.)

Signature · 8 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
maintainer
#3 lore raw
Quoted 1 line · Wu Jian Feng

Can't figure out why but have a quick workaround for this:

Erases are permitted to be asynchronous -- if the erase was submitted sucessfully, you may not free the object until the callback is called. You _may_ free the object from the callback, and we do.

Can I infer from this that you've actually seen the same problem? Could you reproduce it? What arch, compiler, etc?

Signature · 1 line
dwmw2
#4 lore raw
Quoted 14 lines · David Woodhouse
Quoted 1 line · Wu Jian Feng

Can't figure out why but have a quick workaround for this:

Erases are permitted to be asynchronous -- if the erase was submitted sucessfully, you may not free the object until the callback is called. You _may_ free the object from the callback, and we do.

Can I infer from this that you've actually seen the same problem? Could you reproduce it? What arch, compiler, etc?

Signature · 1 line
dwmw2

I see the same thing as rmk, used both gcc-3.3.2 and 3.4.0, on a OMAP730 (arm926ejs).

maintainer
#5 lore raw
Quoted 2 lines · Wu Jian Feng

I see the same thing as rmk, used both gcc-3.3.2 and 3.4.0, on a OMAP730 (arm926ejs).

Russell hasn't been able to reproduce it. Can you? If so, how -- and can you do same with CONFIG_JFFS2_FS_DEBUG=1 and show me the output?

Signature · 1 line
dwmw2
maintainer
#6 lore raw
Quoted 2 lines · David Woodhouse

Russell hasn't been able to reproduce it. Can you? If so, how -- and can you do same with CONFIG_JFFS2_FS_DEBUG=1 and show me the output?

Don't bother, thanks. I found the problem, in the part_erase() code. Waiting for the culprit to wake up and fix it... :)

Signature · 1 line
dwmw2
#7 lore raw
Quoted 2 lines · ext David Woodhouse

Don't bother, thanks. I found the problem, in the part_erase() code. Waiting for the culprit to wake up and fix it... :)

I also see the Slab corruption and it is very reproducible with something like:

flash_eraseall -j /dev/mtd0
mount -t jffs2 /dev/mtdblock0 /mnt
cp -a /usr /mnt

I am using Nand flash and 2.6.8-rc3-omap1. Once the fs is filled enough I see typically following:

Slab corruption: start=c3a31980, len=64
Redzone: 0x5a2cf071/0x5a2cf071.
Last user: [<c0185fd0>](nand_erase_nand+0x1fc/0x210) 000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 09 6b Prev obj: start=c3a31934, len=64
Redzone: 0x5a2cf071/0x5a2cf071.
Last user: [<00000000>](0x0)
000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b Next obj: start=c3a319cc, len=64
Redzone: 0x170fc2a5/0x170fc2a5.
Last user: [<c00fcddc>](jffs2_alloc_full_dirent+0x18/0x1c) 000: 8c 68 80 c3 30 11 a3 c3 0d 00 00 00 a1 0c 00 00 010: 46 4d 28 9e 08 44 62 44 72 69 76 65 72 2e 70 6d

Jarkko Lavinen

maintainer
#8 lore raw
In reply to Wu Jian Feng
Quoted 2 lines · Wu Jian Feng

I see the same thing as rmk, used both gcc-3.3.2 and 3.4.0, on a OMAP730 (arm926ejs).

Please could you test this....

Index: drivers/mtd/Kconfig
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/Kconfig,v
retrieving revision 1.5

mtd/Kconfig +1 -1
diff -u -p -r1.5 Kconfig
@@ -28,7 +28,7 @@ config MTD_DEBUG_VERBOSE
 	  Determines the verbosity level of the MTD debugging messages.
 
 config MTD_PARTITIONS
-	tristate "MTD partitioning support"
+	bool "MTD partitioning support"
 	depends on MTD
 	help
 	  If you have a device which needs to divide its flash chip(s) up

Index: drivers/mtd/Makefile.common
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/Makefile.common,v retrieving revision 1.3

mtd/Makefile.common +4 -1
diff -u -p -r1.3 Makefile.common
@@ -4,7 +4,10 @@
 # $Id: Makefile.common,v 1.3 2004/07/12 16:07:30 dwmw2 Exp $
 
 # Core functionality.
-obj-$(CONFIG_MTD)		+= mtdcore.o
+mtd-y				:= mtdcore.o
+mtd-$(CONFIG_MTD_PARTITIONS)	+= mtdpart.o
+obj-$(CONFIG_MTD)		+= $(mtd-y)
+
 obj-$(CONFIG_MTD_CONCAT)	+= mtdconcat.o
 obj-$(CONFIG_MTD_PARTITIONS)	+= mtdpart.o
 obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o

Index: drivers/mtd/mtdchar.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdchar.c,v
retrieving revision 1.62

mtd/mtdchar.c +2 -2
diff -u -p -r1.62 mtdchar.c
@@ -262,7 +262,7 @@ static ssize_t mtd_write(struct file *fi
     IOCTL calls for getting device parameters.
 
 ======================================================================*/
-static void mtd_erase_callback (struct erase_info *instr)
+static void mtdchar_erase_callback (struct erase_info *instr)
 {
 	wake_up((wait_queue_head_t *)instr->priv);
 }
@@ -336,7 +336,7 @@ static int mtd_ioctl(struct inode *inode
 				return -EFAULT;
 			}
 			erase->mtd = mtd;
-			erase->callback = mtd_erase_callback;
+			erase->callback = mtdchar_erase_callback;
 			erase->priv = (unsigned long)&waitq;
 			
 			/*

Index: drivers/mtd/mtdpart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdpart.c,v
retrieving revision 1.46

mtd/mtdpart.c +12 -2
diff -u -p -r1.46 mtdpart.c
@@ -246,11 +246,21 @@ static int part_erase (struct mtd_info *
 		return -EINVAL;
 	instr->addr += part->offset;
 	ret = part->master->erase(part->master, instr);
-	if (instr->fail_addr != 0xffffffff)
-		instr->fail_addr -= part->offset;
 	return ret;
 }
 
+void mtd_erase_callback(struct erase_info *instr)
+{
+	if (instr->mtd->erase == part_erase) {
+		struct mtd_part *part = PART(mtd);
+
+		if (instr->fail_addr != 0xffffffff)
+			instr->fail_addr -= part->offset;
+	}
+	if (instr->callback)
+		instr->callback(instr);
+}
+
 static int part_lock (struct mtd_info *mtd, loff_t ofs, size_t len)
 {
 	struct mtd_part *part = PART(mtd);

Index: drivers/mtd/chips/amd_flash.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/amd_flash.c,v retrieving revision 1.24

mtd/chips/amd_flash.c +1 -3
diff -u -p -r1.24 amd_flash.c
@@ -1307,9 +1307,7 @@ static int amd_flash_erase(struct mtd_in
 	}
 		
 	instr->state = MTD_ERASE_DONE;
-	if (instr->callback) {
-		instr->callback(instr);
-	}
+	mtd_erase_callback(instr);
 	
 	return 0;
 }

Index: drivers/mtd/chips/cfi_cmdset_0001.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0001.c,v retrieving revision 1.153

mtd/chips/cfi_cmdset_0001.c +1 -2
diff -u -p -r1.153 cfi_cmdset_0001.c
@@ -1554,8 +1554,7 @@ int cfi_intelext_erase_varsize(struct mt
 		return ret;
 
 	instr->state = MTD_ERASE_DONE;
-	if (instr->callback)
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 	
 	return 0;
 }

Index: drivers/mtd/chips/cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v retrieving revision 1.104

mtd/chips/cfi_cmdset_0002.c +2 -4
diff -u -p -r1.104 cfi_cmdset_0002.c
@@ -1420,8 +1420,7 @@ int cfi_amdstd_erase_varsize(struct mtd_
 		return ret;
 
 	instr->state = MTD_ERASE_DONE;
-	if (instr->callback)
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 	
 	return 0;
 }
@@ -1444,8 +1443,7 @@ static int cfi_amdstd_erase_chip(struct 
 		return ret;
 
 	instr->state = MTD_ERASE_DONE;
-	if (instr->callback)
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 	
 	return 0;
 }

Index: drivers/mtd/chips/cfi_cmdset_0020.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0020.c,v retrieving revision 1.14

mtd/chips/cfi_cmdset_0020.c +1 -2
diff -u -p -r1.14 cfi_cmdset_0020.c
@@ -966,8 +966,7 @@ int cfi_staa_erase_varsize(struct mtd_in
 	}
 		
 	instr->state = MTD_ERASE_DONE;
-	if (instr->callback)
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 	
 	return 0;
 }

Index: drivers/mtd/chips/jedec.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/jedec.c,v retrieving revision 1.20

mtd/chips/jedec.c +1 -2
diff -u -p -r1.20 jedec.c
@@ -780,8 +780,7 @@ static int flash_erase(struct mtd_info *
        	    
    //printk("done\n");
    instr->state = MTD_ERASE_DONE;
-   if (instr->callback)
-	instr->callback(instr);
+   mtd_erase_callback(instr);
    return 0;
    
    #undef flread

Index: drivers/mtd/chips/map_ram.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/map_ram.c,v retrieving revision 1.19

mtd/chips/map_ram.c +1 -2
diff -u -p -r1.19 map_ram.c
@@ -114,8 +114,7 @@ static int mapram_erase (struct mtd_info
 
 	instr->state = MTD_ERASE_DONE;
 
-	if (instr->callback)
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 
 	return 0;
 }

Index: drivers/mtd/chips/sharp.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/sharp.c,v retrieving revision 1.13

mtd/chips/sharp.c +1 -2
diff -u -p -r1.13 sharp.c
@@ -425,8 +425,7 @@ static int sharp_erase(struct mtd_info *
 	}
 
 	instr->state = MTD_ERASE_DONE;
-	if(instr->callback)
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 
 	return 0;
 }

Index: drivers/mtd/devices/blkmtd-24.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/blkmtd-24.c,v retrieving revision 1.21

mtd/devices/blkmtd-24.c +1 -3
diff -u -p -r1.21 blkmtd-24.c
@@ -466,9 +466,7 @@ static int blkmtd_erase(struct mtd_info 
 
 	DEBUG(3, "blkmtd: erase: checking callback\n");
  erase_callback:
-	if (instr->callback) {
-		(*(instr->callback))(instr);
-	}
+	mtd_erase_callback(instr);
 	DEBUG(2, "blkmtd: erase: finished (err = %d)\n", err);
 	return err;
 }

Index: drivers/mtd/devices/blkmtd.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/blkmtd.c,v retrieving revision 1.21

mtd/devices/blkmtd.c +1 -3
diff -u -p -r1.21 blkmtd.c
@@ -435,9 +435,7 @@ static int blkmtd_erase(struct mtd_info 
 	}
 
 	DEBUG(3, "blkmtd: erase: checking callback\n");
-	if (instr->callback) {
-		(*(instr->callback))(instr);
-	}
+	mtd_erase_callback(instr);
 	DEBUG(2, "blkmtd: erase: finished (err = %d)\n", err);
 	return err;
 }

Index: drivers/mtd/devices/doc2000.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/doc2000.c,v retrieving revision 1.60

mtd/devices/doc2000.c +1 -2
diff -u -p -r1.60 doc2000.c
@@ -1277,8 +1277,7 @@ static int doc_erase(struct mtd_info *mt
 	instr->state = MTD_ERASE_DONE;
 
  callback:
-	if (instr->callback)
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 
 	up(&this->lock);
 	return 0;

Index: drivers/mtd/devices/doc2001.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/doc2001.c,v retrieving revision 1.42

mtd/devices/doc2001.c +1 -2
diff -u -p -r1.42 doc2001.c
@@ -841,8 +841,7 @@ int doc_erase (struct mtd_info *mtd, str
 		instr->state = MTD_ERASE_DONE;
 	dummy = ReadDOC(docptr, LastDataRead);
 
-	if (instr->callback) 
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 
 	return 0;
 }

Index: drivers/mtd/devices/doc2001plus.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/doc2001plus.c,v retrieving revision 1.8

mtd/devices/doc2001plus.c +1 -2
diff -u -p -r1.8 doc2001plus.c
@@ -1111,8 +1111,7 @@ int doc_erase(struct mtd_info *mtd, stru
 	/* Disable flash internally */
 	WriteDOC(0, docptr, Mplus_FlashSelect);
 
-	if (instr->callback) 
-		instr->callback(instr);
+	mtd_erase_callback(instr);
 
 	return 0;
 }

Index: drivers/mtd/devices/lart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/lart.c,v retrieving revision 1.6

mtd/devices/lart.c +1 -1
diff -u -p -r1.6 lart.c
@@ -433,7 +433,7 @@ static int flash_erase (struct mtd_info 
 	 }
 
    instr->state = MTD_ERASE_DONE;
-   if (instr->callback) instr->callback (instr);
+   mtd_erase_callback(instr);
 
    return (0);
 }

Index: drivers/mtd/devices/mtdram.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/mtdram.c,v retrieving revision 1.32

mtd/devices/mtdram.c +1 -2
diff -u -p -r1.32 mtdram.c
@@ -57,9 +57,8 @@ ram_erase(struct mtd_info *mtd, struct e
   memset((char *)mtd->priv + instr->addr, 0xff, instr->len);
 	
   instr->state = MTD_ERASE_DONE;
+  mtd_erase_callback(instr);
 
-  if (instr->callback)
-    (*(instr->callback))(instr);
   return 0;
 }
 

Index: drivers/mtd/devices/phram.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/phram.c,v retrieving revision 1.1

mtd/devices/phram.c +1 -4
diff -u -p -r1.1 phram.c
@@ -55,10 +55,7 @@ int phram_erase(struct mtd_info *mtd, st
 
 	instr->state = MTD_ERASE_DONE;
 
-	if (instr->callback)
-		(*(instr->callback))(instr);
-	else
-		kfree(instr);
+	mtd_erase_callback(instr);
 
 	return 0;
 }

Index: drivers/mtd/devices/pmc551.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/pmc551.c,v retrieving revision 1.27

mtd/devices/pmc551.c +1 -3
diff -u -p -r1.27 pmc551.c
@@ -169,9 +169,7 @@ out:
 	printk(KERN_DEBUG "pmc551_erase() done\n");
 #endif
 
-        if (instr->callback) {
-                (*(instr->callback))(instr);
-	}
+        mtd_erase_callback(instr);
         return 0;
 }
 

Index: drivers/mtd/devices/slram.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/devices/slram.c,v retrieving revision 1.30

mtd/devices/slram.c +1 -6
diff -u -p -r1.30 slram.c
@@ -98,12 +98,7 @@ int slram_erase(struct mtd_info *mtd, st
 
 	instr->state = MTD_ERASE_DONE;
 
-	if (instr->callback) {
-		(*(instr->callback))(instr);
-	}
-	else {
-		kfree(instr);
-	}
+	mtd_erase_callback(instr);
 
 	return(0);
 }

Index: drivers/mtd/nand/diskonchip.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/diskonchip.c,v retrieving revision 1.31

mtd/nand/diskonchip.c +6 -4
diff -u -p -r1.31 diskonchip.c
@@ -1239,8 +1239,9 @@ static int __init nftl_scan_bbt(struct m
 	if ((ret = nand_scan_bbt(mtd, NULL)))
 		return ret;
 	add_mtd_device(mtd);
-#if defined(CONFIG_MTD_PARTITIONS) || defined(CONFIG_MTD_PARTITIONS_MODULE)
-	if (!no_autopart) add_mtd_partitions(mtd, parts, numparts);
+#ifdef CONFIG_MTD_PARTITIONS
+	if (!no_autopart)
+		add_mtd_partitions(mtd, parts, numparts);
 #endif
 	return 0;
 }
@@ -1298,8 +1299,9 @@ static int __init inftl_scan_bbt(struct 
 	   autopartitioning, but I want to give it more thought. */
 	if (!numparts) return -EIO;
 	add_mtd_device(mtd);
-#if defined(CONFIG_MTD_PARTITIONS) || defined(CONFIG_MTD_PARTITIONS_MODULE)
-	if (!no_autopart) add_mtd_partitions(mtd, parts, numparts);
+#ifdefined CONFIG_MTD_PARTITIONS
+	if (!no_autopart)
+		add_mtd_partitions(mtd, parts, numparts);
 #endif
 	return 0;
 }

Index: drivers/mtd/nand/nand_base.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/nand/nand_base.c,v retrieving revision 1.114

mtd/nand/nand_base.c +6 -6
diff -u -p -r1.114 nand_base.c
@@ -58,7 +58,7 @@
 #include <linux/bitops.h>
 #include <asm/io.h>
 
-#if defined(CONFIG_MTD_PARTITIONS) || defined(CONFIG_MTD_PARTITIONS_MODULE)
+#ifdef CONFIG_MTD_PARTITIONS
 #include <linux/mtd/partitions.h>
 #endif
 
@@ -2108,8 +2108,8 @@ erase_exit:
 
 	ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
 	/* Do call back function */
-	if (!ret && instr->callback)
-		instr->callback (instr);
+	if (!ret)
+		mtd_erase_callback(instr);
 
 	/* Deselect and wake up anyone waiting on the device */
 	nand_release_chip(mtd);
@@ -2555,11 +2555,11 @@ void nand_release (struct mtd_info *mtd)
 {
 	struct nand_chip *this = mtd->priv;
 
-#if defined(CONFIG_MTD_PARTITIONS) || defined(CONFIG_MTD_PARTITIONS_MODULE)
-	/* Unregister partitions */
+#ifdef CONFIG_MTD_PARTITIONS
+	/* Deregister partitions */
 	del_mtd_partitions (mtd);
 #endif
-	/* Unregister the device */
+	/* Deregister the device */
 	del_mtd_device (mtd);
 
 	/* Free bad block table memory, if allocated */

Index: include/linux/mtd/mtd.h
===================================================================
RCS file: /home/cvs/mtd/include/linux/mtd/mtd.h,v
retrieving revision 1.54

linux/mtd/mtd.h +11 -0
diff -u -p -r1.54 mtd.h
@@ -192,6 +192,17 @@ int default_mtd_readv(struct mtd_info *m
 #define MTD_WRITEOOB(mtd, args...) (*(mtd->write_oob))(mtd, args)
 #define MTD_SYNC(mtd) do { if (mtd->sync) (*(mtd->sync))(mtd);  } while (0) 
 
+
+#ifdef CONFIG_MTD_PARTITIONS
+void mtd_erase_callback(struct erase_info *instr);
+#else
+static inline void mtd_erase_callback(struct erase_info *instr)
+{
+	if (instr->callback)
+		instr->callback(instr);
+}
+#endif
+
 /*
  * Debugging macro and defines
  */
Signature · 1 line
dwmw2
#9 lore raw
Quoted 3 lines · David Woodhouse

Please could you test this....

It doesn't compile :-(

mtdpart.c renamed from mtdpart.c.old +1 -1
@@ -252,7 +252,7 @@
 void mtd_erase_callback(struct erase_info *instr)
 {
 	if (instr->mtd->erase == part_erase) {
-		struct mtd_part *part = PART(mtd);
+		struct mtd_part *part = PART(instr->mtd);
 
 		if (instr->fail_addr != 0xffffffff)
 			instr->fail_addr -= part->offset;

Then worked fine here, Thanks!

maintainer
#10 lore raw
Quoted 6 lines · Wu Jian Feng
Quoted 3 lines · David Woodhouse

Please could you test this....

It doesn't compile :-(

Doh. I committed that fix too -- I'll send it to Linus today. Thanks.

Signature · 1 line
dwmw2