Skip to contentSkip to conversation

mtdblock_ro and ext2 yields panic: block not locked

DISCUSSION William A. Gatliff 2 participants 3 messages Oct 23, 2002 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Guys:

I'm running linux-2.4.18-mips on an Au1500 board with an AMD AM29LV642 flash. I'm using the readonly block driver and a partitioned flash. The mtdblock_ro.c file has "mtdblock_ro.c,v 1.9" at the top.

I've been tinkering with mounting ext2 and romfs root filesystems at boot from my mtdblock0 partition. I seem to be able to mount romfs fine, but when I use ext2, I get this:

...
ttyS03 at 0xb1400000 (irq = 3) is a 16550
mtdblock_open
ok
mtdblock_open
ok
mtdblock_release
ok
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 192k freed

Kernel panic: mtdblock: block not locked

The panic comes via the INIT_REQUEST macro in mtdblock_request, but only after half a dozen requests or so. The requests appear to be associated with the execve at the end of the kernel boot process.

I also get this with yesterday's CVS.

Ideas? I don't think this is an MTD problem per se, but I'm stumped nonetheless.

Thanks!

b.g.

Signature · 3 lines
Bill Gatliff
I'm an embedded GNU developer first, GNU instructor second.
See http://billgatliff.com for details.
#2 lore raw
In reply to a message not in the archive

Bill,

Quoted 1 line · you

Care to post the patch? I'd love to see if it fixes my problem...

Sure :)
Here it is:

drivers/mtd/mtdblock_ro.c +6 -5
diff -ur a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c
@@ -138,10 +138,11 @@
       }
 
       if (current_request->sector << 9 > mtd->size ||
-         (current_request->sector + current_request->nr_sectors) << 9 > mtd->size)
+         (current_request->sector + current_request->current_nr_sectors) << 9 > mtd->size)
       {
         printk("mtd: Attempt to read past end of device!\n");
-        printk("size: %x, sector: %lx, nr_sectors %lx\n", mtd->size, current_request->sector, current_request->nr_sectors);
+        printk("size: %x, sector: %lx, nr_sectors %lx\n", mtd->size, current_request->sector,
+               current_request->current_nr_sectors);
         end_request(0);
         continue;
       }
@@ -162,7 +163,7 @@
 
         case READ:
         if (MTD_READ(mtd,current_request->sector<<9,
-                     current_request->nr_sectors << 9,
+                     current_request->current_nr_sectors << 9,
                      &retlen, current_request->buffer) == 0)
            res = 1;
         else
@@ -184,7 +185,7 @@
 
         // Do the write
         if (MTD_WRITE(mtd,current_request->sector<<9,
-                      current_request->nr_sectors << 9,
+                      current_request->current_nr_sectors << 9,
                       &retlen, current_request->buffer) == 0)
            res = 1;
         else
@@ -287,7 +288,7 @@
 static void __exit cleanup_mtdblock(void)
 {
        unregister_blkdev(MAJOR_NR,DEVICE_NAME);
-       blksize_size[MAJOR_NR] = NULL;
+       blk_size[MAJOR_NR] = NULL;
        blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
 }
 

Eugene Surovegin <mailto:[email protected]>

#3 lore raw

Eugene:

That looks like it fixed the problem:

...
ttyS03 at 0xb1400000 (irq = 3) is a 16550
mtdblock_open
ok
mtdblock_open
ok
mtdblock_release
ok
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 196k freed
Algorithmics/MIPS FPU Emulator v1.5
init started: BusyBox v0.60.4 (2002.10.16-16:11+0000) multi-call binary Running rc.S... done
eth0: link up

Please press Enter to activate this console.

BusyBox v0.60.4 (2002.10.16-16:11+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands.

#

Thanks!! Yay! :^) :^)

b.g.

Quoted 62 lines · Eugene Surovegin

Bill,

Quoted 1 line · you

Care to post the patch? I'd love to see if it fixes my problem...

Sure :)
Here it is:

diff -ur a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c

drivers/mtd/mtdblock_ro.c +2 -2
@@ -138,10 +138,11 @@
        }
 
        if (current_request->sector << 9 > mtd->size ||
-         (current_request->sector + current_request->nr_sectors) << 9 > 
 mtd->size)
+         (current_request->sector + current_request->current_nr_sectors) 
 << 9 > mtd->size)
        {
          printk("mtd: Attempt to read past end of device!\n");
-        printk("size: %x, sector: %lx, nr_sectors %lx\n", mtd->size, 
 current_request->sector, current_request->nr_sectors);
+        printk("size: %x, sector: %lx, nr_sectors %lx\n", mtd->size, 

current_request->sector,

drivers/mtd/mtdblock_ro.c +4 -3
+               current_request->current_nr_sectors);
          end_request(0);
          continue;
        }
@@ -162,7 +163,7 @@
 
          case READ:
          if (MTD_READ(mtd,current_request->sector<<9,
-                     current_request->nr_sectors << 9,
+                     current_request->current_nr_sectors << 9,
                       &retlen, current_request->buffer) == 0)
             res = 1;
          else
@@ -184,7 +185,7 @@
 
          // Do the write
          if (MTD_WRITE(mtd,current_request->sector<<9,
-                      current_request->nr_sectors << 9,
+                      current_request->current_nr_sectors << 9,
                        &retlen, current_request->buffer) == 0)
             res = 1;
          else
@@ -287,7 +288,7 @@
  static void __exit cleanup_mtdblock(void)
  {
         unregister_blkdev(MAJOR_NR,DEVICE_NAME);
-       blksize_size[MAJOR_NR] = NULL;
+       blk_size[MAJOR_NR] = NULL;
         blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR));
  }
 

Eugene Surovegin <mailto:[email protected]>

Signature · 3 lines
Bill Gatliff
I'm an embedded GNU developer first, GNU instructor second.
See http://billgatliff.com for details.