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