Whamcloud - gitweb
land v0.9.1 on HEAD, in preparation for a 1.0.x branch
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-wantedi-2.6.patch
1  fs/ext3/ialloc.c        |   35 ++++++++++++++++++++++++++++++++++-
2  fs/ext3/ioctl.c         |   25 +++++++++++++++++++++++++
3  fs/ext3/namei.c         |   21 +++++++++++++++++----
4  include/linux/dcache.h  |    5 +++++
5  include/linux/ext3_fs.h |    5 ++++-
6  5 files changed, 85 insertions(+), 6 deletions(-)
7
8 --- linux-2.6.0-test5/fs/ext3/ialloc.c~ext3-wantedi-2.6 2003-06-24 18:05:25.000000000 +0400
9 +++ linux-2.6.0-test5-alexey/fs/ext3/ialloc.c   2003-09-28 13:40:23.000000000 +0400
10 @@ -420,7 +420,8 @@ static int find_group_other(struct super
11   * For other inodes, search forward from the parent directory's block
12   * group to find a free inode.
13   */
14 -struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
15 +struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode,
16 +                               unsigned long goal)
17  {
18         struct super_block *sb;
19         struct buffer_head *bitmap_bh = NULL;
20 @@ -448,6 +449,38 @@ struct inode *ext3_new_inode(handle_t *h
21  
22         es = EXT3_SB(sb)->s_es;
23         sbi = EXT3_SB(sb);
24 +       if (goal) {
25 +               group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
26 +               ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
27 +               gdp = ext3_get_group_desc(sb, group, &bh2);
28 +
29 +               err = -EIO;
30 +               bitmap_bh = read_inode_bitmap (sb, group);
31 +               if (!bitmap_bh)
32 +                       goto fail;
33 +
34 +               BUFFER_TRACE(bh, "get_write_access");
35 +               err = ext3_journal_get_write_access(handle, bitmap_bh);
36 +               if (err) goto fail;
37 +
38 +               if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
39 +                                       ino, bitmap_bh->b_data)) {
40 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
41 +                       /* Oh well, we tried. */
42 +                       goto continue_allocation;
43 +               }
44 +
45 +               BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
46 +               err = ext3_journal_dirty_metadata(handle, bitmap_bh);
47 +               if (err) goto fail;
48 +
49 +               /* We've shortcircuited the allocation system successfully,
50 +                * now finish filling in the inode.
51 +                */
52 +               goto got;
53 +       }
54 +
55 +continue_allocation:
56         if (S_ISDIR(mode)) {
57                 if (test_opt (sb, OLDALLOC))
58                         group = find_group_dir(sb, dir);
59 --- linux-2.6.0-test5/fs/ext3/ioctl.c~ext3-wantedi-2.6  2003-06-24 18:05:25.000000000 +0400
60 +++ linux-2.6.0-test5-alexey/fs/ext3/ioctl.c    2003-09-28 13:45:54.000000000 +0400
61 @@ -24,6 +24,31 @@ int ext3_ioctl (struct inode * inode, st
62         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
63  
64         switch (cmd) {
65 +       case EXT3_IOC_CREATE_INUM: {
66 +               char name[32];
67 +               struct dentry *dchild, *dparent;
68 +               int rc = 0;
69 +
70 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
71 +                                    d_alias);
72 +               snprintf(name, sizeof name, "%lu", arg);
73 +               dchild = lookup_one_len(name, dparent, strlen(name));
74 +               if (dchild->d_inode) {
75 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
76 +                              dparent->d_name.len, dparent->d_name.name, arg,
77 +                              dchild->d_inode->i_ino);
78 +                       rc = -EEXIST;
79 +               } else {
80 +                       dchild->d_fsdata = (void *)arg;
81 +                       rc = vfs_create(inode, dchild, 0644, NULL);
82 +                       if (rc)
83 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
84 +                       else if (dchild->d_inode->i_ino != arg)
85 +                               rc = -EEXIST;
86 +               }
87 +               dput(dchild);
88 +               return rc;
89 +       }
90         case EXT3_IOC_GETFLAGS:
91                 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
92                 return put_user(flags, (int *) arg);
93 --- linux-2.6.0-test5/fs/ext3/namei.c~ext3-wantedi-2.6  2003-09-19 18:01:48.000000000 +0400
94 +++ linux-2.6.0-test5-alexey/fs/ext3/namei.c    2003-09-28 13:40:23.000000000 +0400
95 @@ -1617,6 +1617,19 @@ static int ext3_add_nondir(handle_t *han
96         return err;
97  }
98  
99 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
100 +                                               int mode, struct dentry *dentry)
101 +{
102 +       unsigned long inum = 0;
103 +
104 +       if (dentry->d_fsdata != NULL) {
105 +               struct dentry_params *param =
106 +                       (struct dentry_params *) dentry->d_fsdata;
107 +               inum = param->p_inum;
108 +       }
109 +       return ext3_new_inode(handle, dir, mode, inum);
110 +}
111 +
112  /*
113   * By the time this is called, we already have created
114   * the directory cache entry for the new file, but it
115 @@ -1640,7 +1653,7 @@ static int ext3_create (struct inode * d
116         if (IS_DIRSYNC(dir))
117                 handle->h_sync = 1;
118  
119 -       inode = ext3_new_inode (handle, dir, mode);
120 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
121         err = PTR_ERR(inode);
122         if (!IS_ERR(inode)) {
123                 inode->i_op = &ext3_file_inode_operations;
124 @@ -1670,7 +1683,7 @@ static int ext3_mknod (struct inode * di
125         if (IS_DIRSYNC(dir))
126                 handle->h_sync = 1;
127  
128 -       inode = ext3_new_inode (handle, dir, mode);
129 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
130         err = PTR_ERR(inode);
131         if (!IS_ERR(inode)) {
132                 init_special_inode(inode, inode->i_mode, rdev);
133 @@ -1702,7 +1715,7 @@ static int ext3_mkdir(struct inode * dir
134         if (IS_DIRSYNC(dir))
135                 handle->h_sync = 1;
136  
137 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
138 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
139         err = PTR_ERR(inode);
140         if (IS_ERR(inode))
141                 goto out_stop;
142 @@ -2094,7 +2107,7 @@ static int ext3_symlink (struct inode * 
143         if (IS_DIRSYNC(dir))
144                 handle->h_sync = 1;
145  
146 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
147 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
148         err = PTR_ERR(inode);
149         if (IS_ERR(inode))
150                 goto out_stop;
151 --- linux-2.6.0-test5/include/linux/dcache.h~ext3-wantedi-2.6   2003-09-28 13:40:22.000000000 +0400
152 +++ linux-2.6.0-test5-alexey/include/linux/dcache.h     2003-09-28 13:40:23.000000000 +0400
153 @@ -25,6 +25,11 @@ struct vfsmount;
154  
155  #define IS_ROOT(x) ((x) == (x)->d_parent)
156  
157 +struct dentry_params {
158 +       unsigned long   p_inum;
159 +       void            *p_ptr;
160 +};
161 +
162  /*
163   * "quick string" -- eases parameter passing, but more importantly
164   * saves "metadata" about the string (ie length and the hash).
165 --- linux-2.6.0-test5/include/linux/ext3_fs.h~ext3-wantedi-2.6  2003-09-19 18:01:10.000000000 +0400
166 +++ linux-2.6.0-test5-alexey/include/linux/ext3_fs.h    2003-09-28 13:40:23.000000000 +0400
167 @@ -203,6 +203,7 @@ struct ext3_group_desc
168  #define        EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
169  #define        EXT3_IOC_GETVERSION             _IOR('f', 3, long)
170  #define        EXT3_IOC_SETVERSION             _IOW('f', 4, long)
171 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
172  #define        EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
173  #define        EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
174  #ifdef CONFIG_JBD_DEBUG
175 @@ -707,7 +708,8 @@ extern int ext3fs_dirhash(const char *na
176                           dx_hash_info *hinfo);
177  
178  /* ialloc.c */
179 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
180 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
181 +                                     unsigned long);
182  extern void ext3_free_inode (handle_t *, struct inode *);
183  extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
184  extern unsigned long ext3_count_free_inodes (struct super_block *);
185 @@ -792,4 +794,5 @@ extern struct inode_operations ext3_fast
186  
187  #endif /* __KERNEL__ */
188  
189 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
190  #endif /* _LINUX_EXT3_FS_H */
191
192 _