Whamcloud - gitweb
Branch: HEAD
[fs/lustre-release.git] / lustre / 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: linux-2.6.7/fs/ext3/ialloc.c
9 ===================================================================
10 --- linux-2.6.7.orig/fs/ext3/ialloc.c   2005-03-24 00:27:43.282608616 +0800
11 +++ linux-2.6.7/fs/ext3/ialloc.c        2005-03-24 00:27:43.888516504 +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,38 @@
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 +               gdp = ext3_get_group_desc(sb, group, &bh2);
30 +
31 +               err = -EIO;
32 +               bitmap_bh = read_inode_bitmap (sb, group);
33 +               if (!bitmap_bh)
34 +                       goto fail;
35 +
36 +               BUFFER_TRACE(bh, "get_write_access");
37 +               err = ext3_journal_get_write_access(handle, bitmap_bh);
38 +               if (err) goto fail;
39 +
40 +               if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
41 +                                       ino, bitmap_bh->b_data)) {
42 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
43 +                       /* Oh well, we tried. */
44 +                       goto continue_allocation;
45 +               }
46 +
47 +               BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
48 +               err = ext3_journal_dirty_metadata(handle, bitmap_bh);
49 +               if (err) goto fail;
50 +
51 +               /* We've shortcircuited the allocation system successfully,
52 +                * now finish filling in the inode.
53 +                */
54 +               goto got;
55 +       }
56 +
57 +continue_allocation:
58         if (S_ISDIR(mode)) {
59                 if (test_opt (sb, OLDALLOC))
60                         group = find_group_dir(sb, dir);
61 Index: linux-2.6.7/fs/ext3/ioctl.c
62 ===================================================================
63 --- linux-2.6.7.orig/fs/ext3/ioctl.c    2004-06-16 13:19:13.000000000 +0800
64 +++ linux-2.6.7/fs/ext3/ioctl.c 2005-03-24 00:31:16.113253440 +0800
65 @@ -9,6 +9,7 @@
66  
67  #include <linux/fs.h>
68  #include <linux/jbd.h>
69 +#include <linux/namei.h>
70  #include <linux/ext3_fs.h>
71  #include <linux/ext3_jbd.h>
72  #include <linux/time.h>
73 @@ -24,6 +25,31 @@
74         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
75  
76         switch (cmd) {
77 +       case EXT3_IOC_CREATE_INUM: {
78 +               char name[32];
79 +               struct dentry *dchild, *dparent;
80 +               int rc = 0;
81 +
82 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
83 +                                    d_alias);
84 +               snprintf(name, sizeof name, "%lu", arg);
85 +               dchild = lookup_one_len(name, dparent, strlen(name));
86 +               if (dchild->d_inode) {
87 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
88 +                              dparent->d_name.len, dparent->d_name.name, arg,
89 +                              dchild->d_inode->i_ino);
90 +                       rc = -EEXIST;
91 +               } else {
92 +                       dchild->d_fsdata = (void *)arg;
93 +                       rc = vfs_create(inode, dchild, 0644, NULL);
94 +                       if (rc)
95 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
96 +                       else if (dchild->d_inode->i_ino != arg)
97 +                               rc = -EEXIST;
98 +               }
99 +               dput(dchild);
100 +               return rc;
101 +       }
102         case EXT3_IOC_GETFLAGS:
103                 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
104                 return put_user(flags, (int __user *) arg);
105 Index: linux-2.6.7/fs/ext3/namei.c
106 ===================================================================
107 --- linux-2.6.7.orig/fs/ext3/namei.c    2005-03-24 00:27:43.536570008 +0800
108 +++ linux-2.6.7/fs/ext3/namei.c 2005-03-24 00:27:43.893515744 +0800
109 @@ -1939,6 +1939,19 @@
110         return err;
111  }
112  
113 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
114 +                                               int mode, struct dentry *dentry)
115 +{
116 +       unsigned long inum = 0;
117 +
118 +       if (dentry->d_fsdata != NULL) {
119 +               struct dentry_params *param =
120 +                       (struct dentry_params *) dentry->d_fsdata;
121 +               inum = param->p_inum;
122 +       }
123 +       return ext3_new_inode(handle, dir, mode, inum);
124 +}
125 +
126  /*
127   * By the time this is called, we already have created
128   * the directory cache entry for the new file, but it
129 @@ -1963,7 +1976,7 @@
130         if (IS_DIRSYNC(dir))
131                 handle->h_sync = 1;
132  
133 -       inode = ext3_new_inode (handle, dir, mode);
134 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
135         err = PTR_ERR(inode);
136         if (!IS_ERR(inode)) {
137                 inode->i_op = &ext3_file_inode_operations;
138 @@ -1994,7 +2007,7 @@
139         if (IS_DIRSYNC(dir))
140                 handle->h_sync = 1;
141  
142 -       inode = ext3_new_inode (handle, dir, mode);
143 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
144         err = PTR_ERR(inode);
145         if (!IS_ERR(inode)) {
146                 init_special_inode(inode, inode->i_mode, rdev);
147 @@ -2027,7 +2040,7 @@
148         if (IS_DIRSYNC(dir))
149                 handle->h_sync = 1;
150  
151 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
152 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
153         err = PTR_ERR(inode);
154         if (IS_ERR(inode))
155                 goto out_stop;
156 @@ -2439,7 +2452,7 @@
157         if (IS_DIRSYNC(dir))
158                 handle->h_sync = 1;
159  
160 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
161 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
162         err = PTR_ERR(inode);
163         if (IS_ERR(inode))
164                 goto out_stop;
165 Index: linux-2.6.7/include/linux/ext3_fs.h
166 ===================================================================
167 --- linux-2.6.7.orig/include/linux/ext3_fs.h    2005-03-24 00:27:43.542569096 +0800
168 +++ linux-2.6.7/include/linux/ext3_fs.h 2005-03-24 00:27:43.893515744 +0800
169 @@ -203,6 +203,7 @@
170  #define        EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
171  #define        EXT3_IOC_GETVERSION             _IOR('f', 3, long)
172  #define        EXT3_IOC_SETVERSION             _IOW('f', 4, long)
173 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
174  #define        EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
175  #define        EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
176  #ifdef CONFIG_JBD_DEBUG
177 @@ -708,7 +709,8 @@
178                           dx_hash_info *hinfo);
179  
180  /* ialloc.c */
181 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
182 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
183 +                                     unsigned long);
184  extern void ext3_free_inode (handle_t *, struct inode *);
185  extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
186  extern unsigned long ext3_count_free_inodes (struct super_block *);
187 @@ -793,4 +795,5 @@
188  
189  #endif /* __KERNEL__ */
190  
191 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
192  #endif /* _LINUX_EXT3_FS_H */