Avoid ext2/FAT panic on media error ?

Jochen Karrer (karrer@wpfd25.physik.uni-wuerzburg.de)
Fri, 1 Aug 1997 12:26:30 +0200 (MET DST)


Hi,
ext2 (and FAT) filesystem is still totally unusuable
for removeable media like ZIP-disks because
a kernel panic will occur when using
a defective disk even if the error behaviour is set to
"remount read only" or to "continue". This forces me
to reboot the machine. This happens because ext2_panic()
is called, if a inode can not be read. I substituted
this with a call to ext2_error(). But unfortunately I don't
know if there are any side effects when continuing without
reading a valid block. So please send me your comments on
the patch below. The patch is for 2.1.47. But 2.0.30 has
the same problem.

(minix-filesystem continues on this read-error.)

Jochen

--- linux/fs/ext2/inode.c.orig Fri Aug 1 12:05:02 1997
+++ linux/fs/ext2/inode.c Fri Aug 1 12:10:05 1997
@@ -455,10 +455,12 @@
EXT2_INODE_SIZE(inode->i_sb);
block = le32_to_cpu(gdp[desc].bg_inode_table) +
(offset >> EXT2_BLOCK_SIZE_BITS(inode->i_sb));
- if (!(bh = bread (inode->i_dev, block, inode->i_sb->s_blocksize)))
- ext2_panic (inode->i_sb, "ext2_read_inode",
+ if (!(bh = bread (inode->i_dev, block, inode->i_sb->s_blocksize))) {
+ ext2_error (inode->i_sb, "ext2_read_inode",
"unable to read i-node block - "
"inode=%lu, block=%lu", inode->i_ino, block);
+ return;
+ }
offset &= (EXT2_BLOCK_SIZE(inode->i_sb) - 1);
raw_inode = (struct ext2_inode *) (bh->b_data + offset);

@@ -569,10 +571,12 @@
EXT2_INODE_SIZE(inode->i_sb);
block = le32_to_cpu(gdp[desc].bg_inode_table) +
(offset >> EXT2_BLOCK_SIZE_BITS(inode->i_sb));
- if (!(bh = bread (inode->i_dev, block, inode->i_sb->s_blocksize)))
- ext2_panic (inode->i_sb, "ext2_write_inode",
+ if (!(bh = bread (inode->i_dev, block, inode->i_sb->s_blocksize))) {
+ ext2_error (inode->i_sb, "ext2_write_inode",
"unable to read i-node block - "
"inode=%lu, block=%lu", inode->i_ino, block);
+ return 0;
+ }
offset &= EXT2_BLOCK_SIZE(inode->i_sb) - 1;
raw_inode = (struct ext2_inode *) (bh->b_data + offset);