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