[FIX] Re: IDE problem with 2.3.39pre2-2.3.41pre3 on Athlon system

Alexander Viro aviro en redhat.com
Sab Ene 29 12:07:17 CST 2000


[fix of my part of the mess below]

On Thu, 27 Jan 2000, Andre Hedrick wrote:

> Alex and Andries, what do either of you know about the partition changes?
 
AFAICS getblk_fops() had returned some shit. Not NULL (that would be OK),
but pointer to the unmapped kernel memory. With the obvious results.
Relevant code:
        if (!bdev->bd_op)
		bdev->bd_op = get_blkfops(MAJOR(inode->i_rdev));
	if (bdev->bd_op) {
		ret = 0;
		if (bdev->bd_op->open)
			       ^^
			       There you go.
->bd_op turned out to be...
Aaargh. OK, I see now. It's a combination of my fsckup (fixed unnoticed in
the later patches, but they are still not in the kernel) and some mess with
IDE.
	Scenario:
first attempt to open the bloody thing brings the module in core, registers
something and then ->open() fails. We forget to clean ->bd_op. Then the
driver is unloaded and the next blkdev_open() oopses.

Fix:
--- linux-2.3.41/fs/block_dev.c Fri Jan 28 21:45:45 2000
+++ linux-bird.bdev/fs/block_dev.c      Sat Jan 29 05:05:02 2000
@@ -573,6 +573,8 @@
                                ret = bdev->bd_op->open(fake_inode, &fake_file);                        if (!ret)
                                atomic_inc(&bdev->bd_openers);
+                       else if (!atomic_read(&bdev->bd_openers))
+                               bdev->bd_op = NULL;
                        iput(fake_inode);
                }
        }
@@ -593,6 +595,8 @@
                        ret = bdev->bd_op->open(inode,filp);
                if (!ret)
                        atomic_inc(&bdev->bd_openers);
+               else if (!atomic_read(&bdev->bd_openers))
+                       bdev->bd_op = NULL;
        }
        up(&bdev->bd_sem);
        return ret;

However, something got fishy with IDE proper - it's not a complete solution.
There was some definitely IDE-generated complaints in syslog. Fix of my fsckup
is obviously correct (if we failed open and there is nobody else who keeps the
thing opened we have no right to keep the ->bd_op, cause the module may be
unloaded), but that's not the whole story...

Linus, please apply the patch above. It's against vanilla 2.3.41.
							TIA,
								Al


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo en vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



Más información sobre la lista de distribución Ayuda