Whamcloud - gitweb
b=10651
[fs/lustre-release.git] / lustre / kernel_patches / patches / ext3-wantedi-2.6.15.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.15/fs/ext3/ialloc.c
9 ===================================================================
10 --- linux-2.6.15.orig/fs/ext3/ialloc.c  2006-02-19 15:23:12.000000000 +0300
11 +++ linux-2.6.15/fs/ext3/ialloc.c       2006-02-21 00:26:52.000000000 +0300
12 @@ -420,7 +420,8 @@ static int find_group_other(struct super
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 @@ struct inode *ext3_new_inode(handle_t *h
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.15/fs/ext3/ioctl.c
62 ===================================================================
63 --- linux-2.6.15.orig/fs/ext3/ioctl.c   2005-11-11 08:33:12.000000000 +0300
64 +++ linux-2.6.15/fs/ext3/ioctl.c        2006-02-21 00:26:52.000000000 +0300
65 @@ -25,6 +25,31 @@ int ext3_ioctl (struct inode * inode, st
66         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
67  
68         switch (cmd) {
69 +       case EXT3_IOC_CREATE_INUM: {
70 +               char name[32];
71 +               struct dentry *dchild, *dparent;
72 +               int rc = 0;
73 +
74 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
75 +                                    d_alias);
76 +               snprintf(name, sizeof name, "%lu", arg);
77 +               dchild = lookup_one_len(name, dparent, strlen(name));
78 +               if (dchild->d_inode) {
79 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
80 +                              dparent->d_name.len, dparent->d_name.name, arg,
81 +                              dchild->d_inode->i_ino);
82 +                       rc = -EEXIST;
83 +               } else {
84 +                       dchild->d_fsdata = (void *)arg;
85 +                       rc = vfs_create(inode, dchild, 0644, NULL);
86 +                       if (rc)
87 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
88 +                       else if (dchild->d_inode->i_ino != arg)
89 +                               rc = -EEXIST;
90 +               }
91 +               dput(dchild);
92 +               return rc;
93 +       }
94         case EXT3_IOC_GETFLAGS:
95                 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
96                 return put_user(flags, (int __user *) arg);
97 Index: linux-2.6.15/fs/ext3/namei.c
98 ===================================================================
99 --- linux-2.6.15.orig/fs/ext3/namei.c   2006-02-19 15:23:12.000000000 +0300
100 +++ linux-2.6.15/fs/ext3/namei.c        2006-02-21 00:28:17.000000000 +0300
101 @@ -1631,6 +1631,16 @@ static int ext3_add_nondir(handle_t *han
102         return err;
103  }
104  
105 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
106 +                                               int mode, struct dentry *dentry)
107 +{
108 +       unsigned long inum = 0;
109 +
110 +       if (dentry->d_fsdata != NULL)
111 +               inum = (unsigned long) dentry->d_fsdata;
112 +       return ext3_new_inode(handle, dir, mode, inum);
113 +}
114 +
115  /*
116   * By the time this is called, we already have created
117   * the directory cache entry for the new file, but it
118 @@ -1656,7 +1666,7 @@ retry:
119         if (IS_DIRSYNC(dir))
120                 handle->h_sync = 1;
121  
122 -       inode = ext3_new_inode (handle, dir, mode);
123 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
124         err = PTR_ERR(inode);
125         if (!IS_ERR(inode)) {
126                 inode->i_op = &ext3_file_inode_operations;
127 @@ -1690,7 +1700,7 @@ retry:
128         if (IS_DIRSYNC(dir))
129                 handle->h_sync = 1;
130  
131 -       inode = ext3_new_inode (handle, dir, mode);
132 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
133         err = PTR_ERR(inode);
134         if (!IS_ERR(inode)) {
135                 init_special_inode(inode, inode->i_mode, rdev);
136 @@ -1726,7 +1736,7 @@ retry:
137         if (IS_DIRSYNC(dir))
138                 handle->h_sync = 1;
139  
140 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
141 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
142         err = PTR_ERR(inode);
143         if (IS_ERR(inode))
144                 goto out_stop;
145 @@ -2131,7 +2141,7 @@ retry:
146         if (IS_DIRSYNC(dir))
147                 handle->h_sync = 1;
148  
149 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
150 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
151         err = PTR_ERR(inode);
152         if (IS_ERR(inode))
153                 goto out_stop;
154 Index: linux-2.6.15/include/linux/ext3_fs.h
155 ===================================================================
156 --- linux-2.6.15.orig/include/linux/ext3_fs.h   2005-11-11 08:33:12.000000000 +0300
157 +++ linux-2.6.15/include/linux/ext3_fs.h        2006-02-21 00:26:52.000000000 +0300
158 @@ -762,7 +762,8 @@ extern int ext3fs_dirhash(const char *na
159                           dx_hash_info *hinfo);
160  
161  /* ialloc.c */
162 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
163 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
164 +                                     unsigned long);
165  extern void ext3_free_inode (handle_t *, struct inode *);
166  extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
167  extern unsigned long ext3_count_free_inodes (struct super_block *);
168 @@ -844,4 +845,6 @@ extern struct inode_operations ext3_fast
169  
170  #endif /* __KERNEL__ */
171  
172 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
173 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
174  #endif /* _LINUX_EXT3_FS_H */