Whamcloud - gitweb
- configurable stack size fo x86_64
[fs/lustre-release.git] / lustre / kernel_patches / patches / extN-wantedi.patch
1  fs/ext3/ialloc.c        |   40 ++++++++++++++++++++++++++++++++++++++--
2  fs/ext3/inode.c         |    2 +-
3  fs/ext3/ioctl.c         |   25 +++++++++++++++++++++++++
4  fs/ext3/namei.c         |   21 +++++++++++++++++----
5  include/linux/dcache.h  |    5 +++++
6  include/linux/ext3_fs.h |    5 ++++-
7  6 files changed, 90 insertions(+), 8 deletions(-)
8
9 Index: linux-2.4.24/fs/ext3/namei.c
10 ===================================================================
11 --- linux-2.4.24.orig/fs/ext3/namei.c   2004-05-19 13:58:43.000000000 +0400
12 +++ linux-2.4.24/fs/ext3/namei.c        2004-05-21 18:26:43.000000000 +0400
13 @@ -1533,6 +1533,23 @@
14         return err;
15  }
16  
17 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
18 +                                               int mode, struct dentry *dentry)
19 +{
20 +       struct dentry_params *param = (struct dentry_params *) dentry->d_fsdata;
21 +       unsigned long inum = 0;
22 +       struct inode *inode;
23 +
24 +       if (param != NULL)
25 +               inum = param->p_inum;
26 +       inode = ext3_new_inode(handle, dir, mode, inum);
27 +       if (inode && param && inum && param->p_generation) {
28 +               inode->i_generation = param->p_generation;
29 +               ext3_mark_inode_dirty(handle, inode);
30 +       }
31 +       return inode;
32 +}
33 +
34  /*
35   * By the time this is called, we already have created
36   * the directory cache entry for the new file, but it
37 @@ -1556,7 +1573,7 @@
38         if (IS_SYNC(dir))
39                 handle->h_sync = 1;
40  
41 -       inode = ext3_new_inode (handle, dir, mode);
42 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
43         err = PTR_ERR(inode);
44         if (!IS_ERR(inode)) {
45                 inode->i_op = &ext3_file_inode_operations;
46 @@ -1584,7 +1601,7 @@
47         if (IS_SYNC(dir))
48                 handle->h_sync = 1;
49  
50 -       inode = ext3_new_inode (handle, dir, mode);
51 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
52         err = PTR_ERR(inode);
53         if (!IS_ERR(inode)) {
54                 init_special_inode(inode, mode, rdev);
55 @@ -1614,7 +1631,7 @@
56         if (IS_SYNC(dir))
57                 handle->h_sync = 1;
58  
59 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
60 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
61         err = PTR_ERR(inode);
62         if (IS_ERR(inode))
63                 goto out_stop;
64 @@ -2041,7 +2058,7 @@
65         if (IS_SYNC(dir))
66                 handle->h_sync = 1;
67  
68 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
69 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
70         err = PTR_ERR(inode);
71         if (IS_ERR(inode))
72                 goto out_stop;
73 Index: linux-2.4.24/fs/ext3/ialloc.c
74 ===================================================================
75 --- linux-2.4.24.orig/fs/ext3/ialloc.c  2004-05-19 13:58:43.000000000 +0400
76 +++ linux-2.4.24/fs/ext3/ialloc.c       2004-05-19 13:58:43.000000000 +0400
77 @@ -330,7 +330,8 @@
78   * group to find a free inode.
79   */
80  struct inode * ext3_new_inode (handle_t *handle,
81 -                               const struct inode * dir, int mode)
82 +                               const struct inode * dir, int mode,
83 +                               unsigned long goal)
84  {
85         struct super_block * sb;
86         struct buffer_head * bh;
87 @@ -355,7 +356,41 @@
88         init_rwsem(&inode->u.ext3_i.truncate_sem);
89  
90         lock_super (sb);
91 -       es = sb->u.ext3_sb.s_es;
92 +       es = EXT3_SB(sb)->s_es;
93 +
94 +       if (goal) {
95 +               i = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
96 +               j = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
97 +               gdp = ext3_get_group_desc(sb, i, &bh2);
98 +
99 +               bitmap_nr = load_inode_bitmap (sb, i);
100 +               if (bitmap_nr < 0) {
101 +                       err = bitmap_nr;
102 +                       goto fail;
103 +               }
104 +
105 +               bh = EXT3_SB(sb)->s_inode_bitmap[bitmap_nr];
106 +
107 +               BUFFER_TRACE(bh, "get_write_access");
108 +               err = ext3_journal_get_write_access(handle, bh);
109 +               if (err) goto fail;
110 +
111 +               if (ext3_set_bit(j, bh->b_data)) {
112 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
113 +                       /* Oh well, we tried. */
114 +                       goto repeat;
115 +               }
116 +
117 +               BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
118 +               err = ext3_journal_dirty_metadata(handle, bh);
119 +               if (err) goto fail;
120 +
121 +               /* We've shortcircuited the allocation system successfully,
122 +                * now finish filling in the inode.
123 +                */
124 +               goto have_bit_and_group;
125 +       }
126 +
127  repeat:
128         gdp = NULL;
129         i = 0;
130 @@ -470,6 +505,7 @@
131                 }
132                 goto repeat;
133         }
134 + have_bit_and_group:
135         j += i * EXT3_INODES_PER_GROUP(sb) + 1;
136         if (j < EXT3_FIRST_INO(sb) || j > le32_to_cpu(es->s_inodes_count)) {
137                 ext3_error (sb, "ext3_new_inode",
138 Index: linux-2.4.24/fs/ext3/inode.c
139 ===================================================================
140 --- linux-2.4.24.orig/fs/ext3/inode.c   2004-05-19 13:58:43.000000000 +0400
141 +++ linux-2.4.24/fs/ext3/inode.c        2004-05-19 13:58:43.000000000 +0400
142 @@ -2605,7 +2605,7 @@
143         if (IS_ERR(handle))
144                 goto out_truncate;
145  
146 -       new_inode = ext3_new_inode(handle, old_inode, old_inode->i_mode);
147 +       new_inode = ext3_new_inode(handle, old_inode, old_inode->i_mode, 0);
148         if (IS_ERR(new_inode)) {
149                 ext3_debug("truncate inode %lu directly (no new inodes)\n",
150                            old_inode->i_ino);
151 Index: linux-2.4.24/fs/ext3/ioctl.c
152 ===================================================================
153 --- linux-2.4.24.orig/fs/ext3/ioctl.c   2004-01-10 17:04:42.000000000 +0300
154 +++ linux-2.4.24/fs/ext3/ioctl.c        2004-05-19 13:58:43.000000000 +0400
155 @@ -23,6 +23,31 @@
156         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
157  
158         switch (cmd) {
159 +       case EXT3_IOC_CREATE_INUM: {
160 +               char name[32];
161 +               struct dentry *dchild, *dparent;
162 +               int rc = 0;
163 +
164 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
165 +                                    d_alias);
166 +               snprintf(name, sizeof name, "%lu", arg);
167 +               dchild = lookup_one_len(name, dparent, strlen(name));
168 +               if (dchild->d_inode) {
169 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
170 +                              dparent->d_name.len, dparent->d_name.name, arg,
171 +                              dchild->d_inode->i_ino);
172 +                       rc = -EEXIST;
173 +               } else {
174 +                       dchild->d_fsdata = (void *)arg;
175 +                       rc = vfs_create(inode, dchild, 0644);
176 +                       if (rc)
177 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
178 +                       else if (dchild->d_inode->i_ino != arg)
179 +                               rc = -EEXIST;
180 +               }
181 +               dput(dchild);
182 +               return rc;
183 +       }
184         case EXT3_IOC_GETFLAGS:
185                 flags = inode->u.ext3_i.i_flags & EXT3_FL_USER_VISIBLE;
186                 return put_user(flags, (int *) arg);
187 Index: linux-2.4.24/include/linux/ext3_fs.h
188 ===================================================================
189 --- linux-2.4.24.orig/include/linux/ext3_fs.h   2004-05-19 13:58:43.000000000 +0400
190 +++ linux-2.4.24/include/linux/ext3_fs.h        2004-05-19 13:58:43.000000000 +0400
191 @@ -202,6 +202,7 @@
192  #define        EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
193  #define        EXT3_IOC_GETVERSION             _IOR('f', 3, long)
194  #define        EXT3_IOC_SETVERSION             _IOW('f', 4, long)
195 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
196  #define        EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
197  #define        EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
198  #ifdef CONFIG_JBD_DEBUG
199 @@ -674,7 +675,8 @@
200                           dx_hash_info *hinfo);
201  
202  /* ialloc.c */
203 -extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int);
204 +extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int,
205 +                                     unsigned long);
206  extern void ext3_free_inode (handle_t *, struct inode *);
207  extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
208  extern unsigned long ext3_count_free_inodes (struct super_block *);
209 @@ -766,4 +768,5 @@
210  
211  #endif /* __KERNEL__ */
212  
213 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
214  #endif /* _LINUX_EXT3_FS_H */
215 Index: linux-2.4.24/include/linux/dcache.h
216 ===================================================================
217 --- linux-2.4.24.orig/include/linux/dcache.h    2004-05-19 13:58:42.000000000 +0400
218 +++ linux-2.4.24/include/linux/dcache.h 2004-05-21 18:20:34.000000000 +0400
219 @@ -63,6 +63,12 @@
220  
221  #define IS_ROOT(x) ((x) == (x)->d_parent)
222  
223 +struct dentry_params {
224 +       unsigned long   p_inum;
225 +       unsigned long   p_generation;
226 +       void            *p_ptr;
227 +};
228 +
229  /*
230   * "quick string" -- eases parameter passing, but more importantly
231   * saves "metadata" about the string (ie length and the hash).