# This is a BitKeeper generated patch for the following project: # Project Name: Linux kernel tree # # namei.c | 21 ++++++++++++++++++++- # 1 files changed, 20 insertions(+), 1 deletion(-) # # The following is the BitKeeper ChangeSet Log # -------------------------------------------- # 02/11/07 tytso@snap.thunk.org 1.779 # Fix ext3 htree rename bug. # # This fixes an ext3 htree bug pointed out by Christopher Li; if # adding the new name to the directory causes a split, this can cause # the directory entry containing the old name to move to another # block, and then the removal of the old name will fail. # -------------------------------------------- # --- linux-2.4-ext3merge/fs/ext3/namei.c.=K0008=.orig 2003-03-13 16:22:45.000000000 +0000 +++ linux-2.4-ext3merge/fs/ext3/namei.c 2003-03-13 16:22:45.000000000 +0000 @@ -2178,7 +2178,26 @@ static int ext3_rename (struct inode * o /* * ok, that's it */ - ext3_delete_entry(handle, old_dir, old_de, old_bh); + retval = ext3_delete_entry(handle, old_dir, old_de, old_bh); + if (retval == -ENOENT) { + /* + * old_de could have moved out from under us. + */ + struct buffer_head *old_bh2; + struct ext3_dir_entry_2 *old_de2; + + old_bh2 = ext3_find_entry(old_dentry, &old_de2); + if (old_bh2) { + retval = ext3_delete_entry(handle, old_dir, + old_de2, old_bh2); + brelse(old_bh2); + } + } + if (retval) { + ext3_warning(old_dir->i_sb, "ext3_rename", + "Deleting old file (%lu), %d, error=%d", + old_dir->i_ino, old_dir->i_nlink, retval); + } if (new_inode) { new_inode->i_nlink--;