From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Fri, 5 Apr 2002 14:26:54 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Fri, 5 Apr 2002 14:26:45 -0500 Received: from backtop.namesys.com ([212.16.7.71]:26241 "EHLO bitshadow.namesys.com") by vger.kernel.org with ESMTP id ; Fri, 5 Apr 2002 14:26:31 -0500 Date: Sat, 6 Apr 2002 00:23:57 +0400 Message-Id: <200204052023.g35KNvR02861@bitshadow.namesys.com> From: Hans Reiser To: torvalds@transmeta.com, linux-kernel@vger.kernel.org Subject: ReiserFS Bug Fixes 1 of 6 Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org This changeset is to fix reiserfs corruption problems while finishing unlinks and truncates during mount. You can just use bk receive to get it. 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. Fix itself is from Chris Mason. Diffstat: inode.c | 21 ++++++++++++++++----- super.c | 3 +-- 2 files changed, 17 insertions(+), 7 deletions(-) plain patch: # This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas: # ChangeSet 1.537 -> 1.537.5.1 # fs/reiserfs/inode.c 1.37 -> 1.38 # fs/reiserfs/super.c 1.31 -> 1.32 # # -------------------------------------------- # 02/04/02 mason@suse.com 1.537.5.1 # 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 Fri Apr 5 14:08:08 2002 +++ b/fs/reiserfs/inode.c Fri Apr 5 14:08:08 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 Fri Apr 5 14:08:08 2002 +++ b/fs/reiserfs/super.c Fri Apr 5 14:08:08 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) { BK changeset: This BitKeeper patch contains the following changesets: 1.537.5.1 ## Wrapped with gzip_uu ## begin 664 bkpatch2212 M'XL(`/^VK3P``[56VV[C-A!]-K]B@'UQTE@F=;%E!RG2W01ML$4WR'8?6A0P M9&EDL9%%@Z3L3>O^>X>TG1N<-%DTL@!9TLSAW,ZAWL$7@WKG=E5+TKE^I.?:]?7]Z/5DI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