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