2002-04-02 20:15:45

by Chris Mason

[permalink] [raw]
Subject: [PATCH] 2.5.7 reiserfs mount fixes

Hello everyone,

These patches fix reiserfs corruption problems while finishing unlinks
and truncates during mount. They have been very lightly tested,
reiserfs under 2.5.x should be used with caution until we've hammered on
it a bit more.

2.5.[67] will oops on mount without Oleg's journal.c patch that has been
floating around. You can grab it at:

ftp.namesys.com/pub/reiserfs-for-2.5/2.5.7.pending/02-jdev_bd_uninitialised_fix.diff

There are a few other patches in that ftp directory, but at least one of
them is still causing corruptions. The most critical patches are the
02_jdev fix, and the one below. I would skip all the others right now.

reiserfs copies a key into the private part of the inode, and uses this
for some operations. If an iget fails because the object no longer
exists, iput might trigger deletion of whatever object previously lived
in that inode, leading to corruption on disk. The patch below fixes
that, and a minor thinko in the read_super call. bk receivable patch
included as well.

[email protected], 2002-04-02 13:51:46-05:00, [email protected]
cleanup fixes:

reiserfs_read_inode2 needs to clear the private key when it fails to
read the inode from disk.

brelse called too soon while reading the super.

diff -Nru a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
--- a/fs/reiserfs/inode.c Tue Apr 2 14:44:38 2002
+++ b/fs/reiserfs/inode.c Tue Apr 2 14:44:38 2002
@@ -1107,8 +1107,19 @@
return;
}

+/* reiserfs_read_inode2 is called to read the inode off disk, and it
+** does a make_bad_inode when things go wrong. But, we need to make sure
+** and clear the key in the private portion of the inode, otherwise a
+** corresponding iput might try to delete whatever object the inode last
+** represented.
+*/
+static void reiserfs_make_bad_inode(struct inode *inode) {
+ memset(INODE_PKEY(inode), 0, KEY_SIZE);
+ make_bad_inode(inode);
+}
+
void reiserfs_read_inode(struct inode *inode) {
- make_bad_inode(inode) ;
+ reiserfs_make_bad_inode(inode) ;
}


@@ -1128,7 +1139,7 @@
int retval;

if (!p) {
- make_bad_inode(inode) ;
+ reiserfs_make_bad_inode(inode) ;
return;
}

@@ -1148,13 +1159,13 @@
reiserfs_warning ("vs-13070: reiserfs_read_inode2: "
"i/o failure occurred trying to find stat data of %K\n",
&key);
- make_bad_inode(inode) ;
+ reiserfs_make_bad_inode(inode) ;
return;
}
if (retval != ITEM_FOUND) {
/* a stale NFS handle can trigger this without it being an error */
pathrelse (&path_to_sd);
- make_bad_inode(inode) ;
+ reiserfs_make_bad_inode(inode) ;
inode->i_nlink = 0;
return;
}
@@ -1181,7 +1192,7 @@
"dead inode read from disk %K. "
"This is likely to be race with knfsd. Ignore\n",
&key );
- make_bad_inode( inode );
+ reiserfs_make_bad_inode( inode );
}

reiserfs_check_path(&path_to_sd) ; /* init inode should be relsing */
diff -Nru a/fs/reiserfs/super.c b/fs/reiserfs/super.c
--- a/fs/reiserfs/super.c Tue Apr 2 14:44:38 2002
+++ b/fs/reiserfs/super.c Tue Apr 2 14:44:38 2002
@@ -740,9 +740,8 @@
//
// ok, reiserfs signature (old or new) found in at the given offset
//
- brelse (bh);
-
sb_set_blocksize (s, sb_blocksize(rs));
+ brelse (bh);

bh = reiserfs_bread (s, offset / s->s_blocksize);
if (!bh) {

================================================================


This BitKeeper patch contains the following changesets:
1.538
## Wrapped with gzip_uu ##


begin 664 bkpatch2053
M'XL(`"8*JCP``[56VV[C-A!]-K]B@'UQ4E](76S908ITDV`;;-$-LMV'%@4,
M61I%;&31("E[T[K_WB%]R:5.FBP:60`M:N9P.#/G4._@BT$];LU2HVKV#GY4
MQHY;IC'8R]2,)JZ4HHG^]*9?R;KYVIL)1K.7J<U*6*`VXY;HA;L9>SO'<>OJ
M_,.7GWZX8NSX&$[+M+[&SVCA^)A9I1=IE9N3U):5JGM6I[69H4W=8JN=Z2K@
M/*!?+(8ACP<K,>#1<)6)7(@T$ICS($H&T1U:J6;X/%8H$C&*R&\5#9)@R,Y`
M].(P`1[T>=3G`8AP'(MQ-.CR>,PY^'2<;-,`WP70Y>P]_+_QG[(,L@K3NIE#
M(;^B&=,$W1HEU:0P$XUI/I&URC&`&C$W%(#WT&!+A+F6B]0BW.`M+$NL05HH
M4EEY,X^3YM[00T"A:2>Y-#>]]3)3C95!R-*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