Re: [PATCH] Fix bug in ext3 htree rename: doesn't delete old name,

Andrew Morton (akpm@digeo.com)
Wed, 06 Nov 2002 00:44:21 -0800


chrisl@vmware.com wrote:
>
> This should fix the ext3 htree rename problem. Please try it again.
>

The 2.5 version....

--- 25/fs/ext3/namei.c~ext3-rename-fix Wed Nov 6 00:36:43 2002
+++ 25-akpm/fs/ext3/namei.c Wed Nov 6 00:41:20 2002
@@ -2160,7 +2160,7 @@ static int ext3_rename (struct inode * o

lock_kernel();
handle = ext3_journal_start(old_dir, 2 * EXT3_DATA_TRANS_BLOCKS +
- EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2);
+ EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3);
if (IS_ERR(handle)) {
unlock_kernel();
return PTR_ERR(handle);
@@ -2237,7 +2237,30 @@ 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 can be moved during ext3_add_entry.
+ */
+ 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);
+ } else {
+ ext3_warning(old_dir->i_sb, "ext3_rename",
+ "Deleting old file not found (%lu), %d",
+ old_dir->i_ino, old_dir->i_nlink);
+ }
+ }
+
+ 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--;

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