RE: [PATCH] Fix bug in ext3 htree rename: doesn't delete old name , leaves ino with bad nlink

From: Christopher Li (chrisl@vmware.com)
Date: Thu Nov 07 2002 - 00:40:57 EST


The revised patch:

--- namei.c 2002/11/06 07:19:11 1.2
+++ namei.c 2002/11/07 05:24:46
@@ -2167,8 +2167,25 @@
        /*
         * 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);
+ }
+ }
+ 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--;
                new_inode->i_ctime = CURRENT_TIME;

Chris

-----Original Message-----
From: Theodore Ts'o
To: Alexander Viro
Cc: Christopher Li; Jeremy Fitzhardinge; Ext2 devel; Linux Kernel List
Sent: 11/6/02 6:44 PM
Subject: Re: [PATCH] Fix bug in ext3 htree rename: doesn't delete old name,
leaves ino with bad nlink

On Wed, Nov 06, 2002 at 05:47:40PM -0500, Alexander Viro wrote:
>
> HUH?
>
> ->rename() holds ->i_sem on both directories. So do all other
directory
> methods. What the hell is going on there?

What's going on is that had a brain-fart, and forgot about inode
semaphore that's held by the VFS layer. Chris, sorry about that;
there is no need retry multiple times. We only need to retry once, in
the case where the node gets split.

                                                - Ted

-
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/



This archive was generated by hypermail 2b29 : Thu Nov 07 2002 - 22:00:47 EST