Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-wantedi-2.6-rhel4.patch
1 diff -urp RH_2_6_9_42_0_3.orig/fs/ext3/ialloc.c RH_2_6_9_42_0_3/fs/ext3/ialloc.c
2 --- RH_2_6_9_42_0_3.orig/fs/ext3/ialloc.c       2006-10-23 13:32:46.000000000 +0300
3 +++ RH_2_6_9_42_0_3/fs/ext3/ialloc.c    2007-02-16 07:22:28.000000000 +0200
4 @@ -419,7 +419,8 @@ static int find_group_other(struct super
5   * For other inodes, search forward from the parent directory's block
6   * group to find a free inode.
7   */
8 -struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
9 +struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode,
10 +                               unsigned long goal)
11  {
12         struct super_block *sb;
13         struct buffer_head *bitmap_bh = NULL;
14 @@ -447,6 +448,41 @@ struct inode *ext3_new_inode(handle_t *h
15  
16         sbi = EXT3_SB(sb);
17         es = sbi->s_es;
18 +       if (goal) {
19 +               group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
20 +               ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
21 +               err = -EIO;
22 +
23 +               gdp = ext3_get_group_desc(sb, group, &bh2);
24 +               if (!gdp)
25 +                       goto fail;
26 +
27 +               bitmap_bh = read_inode_bitmap (sb, group);
28 +               if (!bitmap_bh)
29 +                       goto fail;
30 +
31 +               BUFFER_TRACE(bh, "get_write_access");
32 +               err = ext3_journal_get_write_access(handle, bitmap_bh);
33 +               if (err) goto fail;
34 +
35 +               if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
36 +                                       ino, bitmap_bh->b_data)) {
37 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
38 +                       /* Oh well, we tried. */
39 +                       goto continue_allocation;
40 +               }
41 +
42 +               BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
43 +               err = ext3_journal_dirty_metadata(handle, bitmap_bh);
44 +               if (err) goto fail;
45 +
46 +               /* We've shortcircuited the allocation system successfully,
47 +                * now finish filling in the inode.
48 +                */
49 +               goto got;
50 +       }
51 +
52 +continue_allocation:
53         if (S_ISDIR(mode)) {
54                 if (test_opt (sb, OLDALLOC))
55                         group = find_group_dir(sb, dir);
56 diff -urp RH_2_6_9_42_0_3.orig/fs/ext3/ioctl.c RH_2_6_9_42_0_3/fs/ext3/ioctl.c
57 --- RH_2_6_9_42_0_3.orig/fs/ext3/ioctl.c        2006-10-23 13:32:46.000000000 +0300
58 +++ RH_2_6_9_42_0_3/fs/ext3/ioctl.c     2007-02-16 07:22:28.000000000 +0200
59 @@ -25,6 +25,31 @@ int ext3_ioctl (struct inode * inode, st
60         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
61  
62         switch (cmd) {
63 +       case EXT3_IOC_CREATE_INUM: {
64 +               char name[32];
65 +               struct dentry *dchild, *dparent;
66 +               int rc = 0;
67 +
68 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
69 +                                    d_alias);
70 +               snprintf(name, sizeof name, "%lu", arg);
71 +               dchild = lookup_one_len(name, dparent, strlen(name));
72 +               if (dchild->d_inode) {
73 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
74 +                              dparent->d_name.len, dparent->d_name.name, arg,
75 +                              dchild->d_inode->i_ino);
76 +                       rc = -EEXIST;
77 +               } else {
78 +                       dchild->d_fsdata = (void *)arg;
79 +                       rc = vfs_create(inode, dchild, 0644, NULL);
80 +                       if (rc)
81 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
82 +                       else if (dchild->d_inode->i_ino != arg)
83 +                               rc = -EEXIST;
84 +               }
85 +               dput(dchild);
86 +               return rc;
87 +       }
88         case EXT3_IOC_GETFLAGS:
89                 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
90                 return put_user(flags, (int __user *) arg);
91 diff -urp RH_2_6_9_42_0_3.orig/fs/ext3/namei.c RH_2_6_9_42_0_3/fs/ext3/namei.c
92 --- RH_2_6_9_42_0_3.orig/fs/ext3/namei.c        2006-10-23 13:32:59.000000000 +0300
93 +++ RH_2_6_9_42_0_3/fs/ext3/namei.c     2007-02-22 18:58:13.000000000 +0200
94 @@ -97,6 +97,7 @@ struct dx_entry
95         __le32 block;
96  };
97  
98 +
99  /*
100   * dx_root_info is laid out so that if it should somehow get overlaid by a
101   * dirent the two low bits of the hash version will be zero.  Therefore, the
102 @@ -141,6 +142,14 @@ struct dx_map_entry
103         u32 offs;
104  };
105  
106 +#define LVFS_DENTRY_PARAM_MAGIC                20070216UL
107 +struct lvfs_dentry_params
108 +{
109 +       unsigned long   p_inum;
110 +       void            *p_ptr; 
111 +       u32             magic;
112 +};
113 +
114  #ifdef CONFIG_EXT3_INDEX
115  static inline unsigned dx_get_block (struct dx_entry *entry);
116  static void dx_set_block (struct dx_entry *entry, unsigned value);
117 @@ -1624,6 +1633,20 @@ static int ext3_add_nondir(handle_t *han
118         return err;
119  }
120  
121 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
122 +                                               int mode, struct dentry *dentry)
123 +{
124 +       unsigned long inum = 0;
125 +
126 +       if (dentry->d_fsdata != NULL) {
127 +               struct lvfs_dentry_params *param = dentry->d_fsdata;
128 +
129 +               if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
130 +                       inum = param->p_inum;
131 +       }
132 +       return ext3_new_inode(handle, dir, mode, inum);
133 +}
134 +
135  /*
136   * By the time this is called, we already have created
137   * the directory cache entry for the new file, but it
138 @@ -1649,7 +1672,7 @@ retry:
139         if (IS_DIRSYNC(dir))
140                 handle->h_sync = 1;
141  
142 -       inode = ext3_new_inode (handle, dir, mode);
143 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
144         err = PTR_ERR(inode);
145         if (!IS_ERR(inode)) {
146                 inode->i_op = &ext3_file_inode_operations;
147 @@ -1683,7 +1706,7 @@ retry:
148         if (IS_DIRSYNC(dir))
149                 handle->h_sync = 1;
150  
151 -       inode = ext3_new_inode (handle, dir, mode);
152 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
153         err = PTR_ERR(inode);
154         if (!IS_ERR(inode)) {
155                 init_special_inode(inode, inode->i_mode, rdev);
156 @@ -1719,7 +1742,7 @@ retry:
157         if (IS_DIRSYNC(dir))
158                 handle->h_sync = 1;
159  
160 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
161 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
162         err = PTR_ERR(inode);
163         if (IS_ERR(inode))
164                 goto out_stop;
165 @@ -2124,7 +2147,7 @@ retry:
166         if (IS_DIRSYNC(dir))
167                 handle->h_sync = 1;
168  
169 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
170 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
171         err = PTR_ERR(inode);
172         if (IS_ERR(inode))
173                 goto out_stop;
174 diff -urp RH_2_6_9_42_0_3.orig/include/linux/ext3_fs.h RH_2_6_9_42_0_3/include/linux/ext3_fs.h
175 --- RH_2_6_9_42_0_3.orig/include/linux/ext3_fs.h        2006-10-23 13:32:46.000000000 +0300
176 +++ RH_2_6_9_42_0_3/include/linux/ext3_fs.h     2007-02-16 07:22:28.000000000 +0200
177 @@ -741,7 +741,8 @@ extern int ext3fs_dirhash(const char *na
178                           dx_hash_info *hinfo);
179  
180  /* ialloc.c */
181 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
182 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
183 +                                     unsigned long);
184  extern void ext3_free_inode (handle_t *, struct inode *);
185  extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
186  extern unsigned long ext3_count_free_inodes (struct super_block *);
187 @@ -833,4 +834,6 @@ extern struct inode_operations ext3_fast
188  
189  #endif /* __KERNEL__ */
190  
191 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
192 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
193  #endif /* _LINUX_EXT3_FS_H */