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