Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext-2.4-patch-4.patch
1 # This is a BitKeeper generated patch for the following project:
2 # Project Name: Linux kernel tree
3 #
4 # namei.c |   21 ++++++++++++++++++++-
5 # 1 files changed, 20 insertions(+), 1 deletion(-)
6 #
7 # The following is the BitKeeper ChangeSet Log
8 # --------------------------------------------
9 # 02/11/07      tytso@snap.thunk.org    1.779
10 # Fix ext3 htree rename bug.
11
12 # This fixes an ext3 htree bug pointed out by Christopher Li; if 
13 # adding the new name to the directory causes a split, this can cause
14 # the directory entry containing the old name to move to another 
15 # block, and then the removal of the old name will fail.
16 # --------------------------------------------
17 #
18 diff -Nru a/fs/ext3/namei.c b/fs/ext3/namei.c
19 --- a/fs/ext3/namei.c   Thu Nov  7 10:57:49 2002
20 +++ b/fs/ext3/namei.c   Thu Nov  7 10:57:49 2002
21 @@ -2173,7 +2173,30 @@
22         /*
23          * ok, that's it
24          */
25 -       ext3_delete_entry(handle, old_dir, old_de, old_bh);
26 +       if (le32_to_cpu(old_de->inode) != old_inode->i_ino ||
27 +           old_de->name_len != old_dentry->d_name.len ||
28 +           strncmp(old_de->name, old_dentry->d_name.name, old_de->name_len) ||
29 +           (retval = ext3_delete_entry(handle, old_dir,
30 +                                       old_de, old_bh)) == -ENOENT) {
31 +               /* old_de could have moved from under us during htree split, so
32 +                * make sure that we are deleting the right entry.  We might
33 +                * also be pointing to a stale entry in the unused part of
34 +                * old_bh so just checking inum and the name isn't enough. */
35 +               struct buffer_head *old_bh2;
36 +               struct ext3_dir_entry_2 *old_de2;
37 +
38 +               old_bh2 = ext3_find_entry(old_dentry, &old_de2);
39 +               if (old_bh2) {
40 +                       retval = ext3_delete_entry(handle, old_dir,
41 +                                                  old_de2, old_bh2);
42 +                       brelse(old_bh2);
43 +               }
44 +       }
45 +       if (retval) {
46 +               ext3_warning(old_dir->i_sb, "ext3_rename",
47 +                               "Deleting old file (%lu), %d, error=%d",
48 +                               old_dir->i_ino, old_dir->i_nlink, retval);
49 +       }
50  
51         if (new_inode) {
52                 new_inode->i_nlink--;