Whamcloud - gitweb
file xnu_types.h was initially added on branch b_port_step.
[fs/lustre-release.git] / lustre / kernel_patches / patches / extN-wantedi-2.4.22-rh.patch
1  fs/ext3/ialloc.c        |   41 +++++++++++++++++++++++++++++++++++++++--
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, 91 insertions(+), 8 deletions(-)
8
9 --- linux-2.4.22-ac1/fs/ext3/ialloc.c~extN-wantedi-2.4.22-rh    2003-09-26 00:57:29.000000000 +0400
10 +++ linux-2.4.22-ac1-alexey/fs/ext3/ialloc.c    2003-09-26 01:00:17.000000000 +0400
11 @@ -524,7 +524,8 @@ static int find_group_other(struct super
12   * group to find a free inode.
13   */
14  struct inode * ext3_new_inode (handle_t *handle,
15 -                               const struct inode * dir, int mode)
16 +                               const struct inode * dir, int mode,
17 +                               unsigned long goal)
18  {
19         struct super_block * sb;
20         struct buffer_head * bh;
21 @@ -549,7 +550,41 @@ struct inode * ext3_new_inode (handle_t 
22         init_rwsem(&inode->u.ext3_i.truncate_sem);
23  
24         lock_super (sb);
25 -       es = sb->u.ext3_sb.s_es;
26 +       es = EXT3_SB(sb)->s_es;
27 +
28 +       if (goal) {
29 +               group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
30 +               ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
31 +               gdp = ext3_get_group_desc(sb, group, &bh2);
32 +
33 +               bitmap_nr = load_inode_bitmap (sb, group);
34 +               if (bitmap_nr < 0) {
35 +                       err = bitmap_nr;
36 +                       goto fail;
37 +               }
38 +
39 +               bh = EXT3_SB(sb)->s_inode_bitmap[bitmap_nr];
40 +
41 +               BUFFER_TRACE(bh, "get_write_access");
42 +               err = ext3_journal_get_write_access(handle, bh);
43 +               if (err) goto fail;
44 +
45 +               if (ext3_set_bit(ino, bh->b_data)) {
46 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
47 +                       /* Oh well, we tried. */
48 +                       goto repeat;
49 +               }
50 +
51 +               BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
52 +               err = ext3_journal_dirty_metadata(handle, bh);
53 +               if (err) goto fail;
54 +
55 +               /* We've shortcircuited the allocation system successfully,
56 +                * now finish filling in the inode.
57 +                */
58 +               goto have_bit_and_group;
59 +       }
60 +
61  repeat:
62         if (S_ISDIR(mode)) {
63                 if (test_opt (sb, OLDALLOC))
64 @@ -606,6 +641,8 @@ repeat:
65                 }
66                 goto repeat;
67         }
68 +
69 +have_bit_and_group:
70         ino += group * EXT3_INODES_PER_GROUP(sb) + 1;
71         if (ino < EXT3_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
72                 ext3_error (sb, "ext3_new_inode",
73 --- linux-2.4.22-ac1/fs/ext3/inode.c~extN-wantedi-2.4.22-rh     2003-09-26 00:57:29.000000000 +0400
74 +++ linux-2.4.22-ac1-alexey/fs/ext3/inode.c     2003-09-26 00:57:29.000000000 +0400
75 @@ -2614,7 +2614,7 @@ void ext3_truncate_thread(struct inode *
76         if (IS_ERR(handle))
77                 goto out_truncate;
78  
79 -       new_inode = ext3_new_inode(handle, old_inode, old_inode->i_mode);
80 +       new_inode = ext3_new_inode(handle, old_inode, old_inode->i_mode, 0);
81         if (IS_ERR(new_inode)) {
82                 ext3_debug("truncate inode %lu directly (no new inodes)\n",
83                            old_inode->i_ino);
84 --- linux-2.4.22-ac1/fs/ext3/ioctl.c~extN-wantedi-2.4.22-rh     2003-09-25 14:16:23.000000000 +0400
85 +++ linux-2.4.22-ac1-alexey/fs/ext3/ioctl.c     2003-09-26 00:57:29.000000000 +0400
86 @@ -23,6 +23,31 @@ int ext3_ioctl (struct inode * inode, st
87         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
88  
89         switch (cmd) {
90 +       case EXT3_IOC_CREATE_INUM: {
91 +               char name[32];
92 +               struct dentry *dchild, *dparent;
93 +               int rc = 0;
94 +
95 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
96 +                                    d_alias);
97 +               snprintf(name, sizeof name, "%lu", arg);
98 +               dchild = lookup_one_len(name, dparent, strlen(name));
99 +               if (dchild->d_inode) {
100 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
101 +                              dparent->d_name.len, dparent->d_name.name, arg,
102 +                              dchild->d_inode->i_ino);
103 +                       rc = -EEXIST;
104 +               } else {
105 +                       dchild->d_fsdata = (void *)arg;
106 +                       rc = vfs_create(inode, dchild, 0644);
107 +                       if (rc)
108 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
109 +                       else if (dchild->d_inode->i_ino != arg)
110 +                               rc = -EEXIST;
111 +               }
112 +               dput(dchild);
113 +               return rc;
114 +       }
115         case EXT3_IOC_GETFLAGS:
116                 flags = inode->u.ext3_i.i_flags & EXT3_FL_USER_VISIBLE;
117                 return put_user(flags, (int *) arg);
118 --- linux-2.4.22-ac1/fs/ext3/namei.c~extN-wantedi-2.4.22-rh     2003-09-26 00:57:28.000000000 +0400
119 +++ linux-2.4.22-ac1-alexey/fs/ext3/namei.c     2003-09-26 00:57:29.000000000 +0400
120 @@ -1534,6 +1534,19 @@ static int ext3_add_nondir(handle_t *han
121         return err;
122  }
123  
124 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
125 +                                               int mode, struct dentry *dentry)
126 +{
127 +       unsigned long inum = 0;
128 +
129 +       if (dentry->d_fsdata != NULL) {
130 +               struct dentry_params *param =
131 +                       (struct dentry_params *) dentry->d_fsdata;
132 +               inum = param->p_inum;
133 +       }
134 +       return ext3_new_inode(handle, dir, mode, inum);
135 +}
136 +
137  /*
138   * By the time this is called, we already have created
139   * the directory cache entry for the new file, but it
140 @@ -1557,7 +1570,7 @@ static int ext3_create (struct inode * d
141         if (IS_SYNC(dir))
142                 handle->h_sync = 1;
143  
144 -       inode = ext3_new_inode (handle, dir, mode);
145 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
146         err = PTR_ERR(inode);
147         if (!IS_ERR(inode)) {
148                 inode->i_op = &ext3_file_inode_operations;
149 @@ -1585,7 +1598,7 @@ static int ext3_mknod (struct inode * di
150         if (IS_SYNC(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                 init_special_inode(inode, mode, rdev);
158 @@ -1615,7 +1628,7 @@ static int ext3_mkdir(struct inode * dir
159         if (IS_SYNC(dir))
160                 handle->h_sync = 1;
161  
162 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
163 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
164         err = PTR_ERR(inode);
165         if (IS_ERR(inode))
166                 goto out_stop;
167 @@ -2010,7 +2023,7 @@ static int ext3_symlink (struct inode * 
168         if (IS_SYNC(dir))
169                 handle->h_sync = 1;
170  
171 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
172 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
173         err = PTR_ERR(inode);
174         if (IS_ERR(inode))
175                 goto out_stop;
176 --- linux-2.4.22-ac1/include/linux/dcache.h~extN-wantedi-2.4.22-rh      2003-09-26 00:57:27.000000000 +0400
177 +++ linux-2.4.22-ac1-alexey/include/linux/dcache.h      2003-09-26 00:57:29.000000000 +0400
178 @@ -63,6 +63,11 @@ static inline void intent_init(struct lo
179  
180  #define IS_ROOT(x) ((x) == (x)->d_parent)
181  
182 +struct dentry_params {
183 +       unsigned long   p_inum;
184 +       void            *p_ptr;
185 +};
186 +
187  /*
188   * "quick string" -- eases parameter passing, but more importantly
189   * saves "metadata" about the string (ie length and the hash).
190 --- linux-2.4.22-ac1/include/linux/ext3_fs.h~extN-wantedi-2.4.22-rh     2003-09-26 00:57:29.000000000 +0400
191 +++ linux-2.4.22-ac1-alexey/include/linux/ext3_fs.h     2003-09-26 00:57:29.000000000 +0400
192 @@ -203,6 +203,7 @@ struct ext3_group_desc
193  #define        EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
194  #define        EXT3_IOC_GETVERSION             _IOR('f', 3, long)
195  #define        EXT3_IOC_SETVERSION             _IOW('f', 4, long)
196 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
197  #define        EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
198  #define        EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
199  #ifdef CONFIG_JBD_DEBUG
200 @@ -676,7 +677,8 @@ extern int ext3fs_dirhash(const char *na
201                           dx_hash_info *hinfo);
202  
203  /* ialloc.c */
204 -extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int);
205 +extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int,
206 +                                     unsigned long);
207  extern void ext3_free_inode (handle_t *, struct inode *);
208  extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
209  extern unsigned long ext3_count_free_inodes (struct super_block *);
210 @@ -769,4 +771,5 @@ extern struct inode_operations ext3_fast
211  
212  #endif /* __KERNEL__ */
213  
214 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
215  #endif /* _LINUX_EXT3_FS_H */
216
217 _