1 fs/ext3/ialloc.c | 40 ++++++++++++++++++++++++++++++++++++++--
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(-)
9 Index: linux-2.4.21-chaos/fs/ext3/namei.c
10 ===================================================================
11 --- linux-2.4.21-chaos.orig/fs/ext3/namei.c 2003-12-12 16:18:41.000000000 +0300
12 +++ linux-2.4.21-chaos/fs/ext3/namei.c 2003-12-12 16:18:53.000000000 +0300
13 @@ -1534,6 +1534,19 @@
17 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
18 + int mode, struct dentry *dentry)
20 + unsigned long inum = 0;
22 + if (dentry->d_fsdata != NULL) {
23 + struct dentry_params *param =
24 + (struct dentry_params *) dentry->d_fsdata;
25 + inum = param->p_inum;
27 + return ext3_new_inode(handle, dir, mode, inum);
31 * By the time this is called, we already have created
32 * the directory cache entry for the new file, but it
37 - inode = ext3_new_inode (handle, dir, mode);
38 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
41 inode->i_op = &ext3_file_inode_operations;
46 - inode = ext3_new_inode (handle, dir, mode);
47 + inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
50 init_special_inode(inode, inode->i_mode, rdev);
55 - inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
56 + inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
64 - inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
65 + inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
69 Index: linux-2.4.21-chaos/fs/ext3/ialloc.c
70 ===================================================================
71 --- linux-2.4.21-chaos.orig/fs/ext3/ialloc.c 2003-12-12 16:18:52.000000000 +0300
72 +++ linux-2.4.21-chaos/fs/ext3/ialloc.c 2003-12-12 16:18:53.000000000 +0300
74 * For other inodes, search forward from the parent directory's block
75 * group to find a free inode.
77 -struct inode * ext3_new_inode (handle_t *handle, struct inode * dir, int mode)
78 +struct inode * ext3_new_inode(handle_t *handle, const struct inode * dir,
79 + int mode, unsigned long goal)
81 struct super_block * sb;
82 struct buffer_head * bh;
84 init_rwsem(&ei->truncate_sem);
88 + es = EXT3_SB(sb)->s_es;
91 + i = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
92 + j = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
93 + gdp = ext3_get_group_desc(sb, i, &bh2);
95 + bitmap_nr = load_inode_bitmap (sb, i);
96 + if (bitmap_nr < 0) {
101 + bh = EXT3_SB(sb)->s_inode_bitmap[bitmap_nr];
103 + BUFFER_TRACE(bh, "get_write_access");
104 + err = ext3_journal_get_write_access(handle, bh);
105 + if (err) goto fail;
107 + if (ext3_set_bit(j, bh->b_data)) {
108 + printk(KERN_ERR "goal inode %lu unavailable\n", goal);
109 + /* Oh well, we tried. */
113 + BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
114 + err = ext3_journal_dirty_metadata(handle, bh);
115 + if (err) goto fail;
117 + /* We've shortcircuited the allocation system successfully,
118 + * now finish filling in the inode.
120 + goto have_bit_and_group;
130 + have_bit_and_group:
131 j += i * EXT3_INODES_PER_GROUP(sb) + 1;
132 if (j < EXT3_FIRST_INO(sb) || j > le32_to_cpu(es->s_inodes_count)) {
133 ext3_error (sb, "ext3_new_inode",
134 Index: linux-2.4.21-chaos/fs/ext3/inode.c
135 ===================================================================
136 --- linux-2.4.21-chaos.orig/fs/ext3/inode.c 2003-12-12 16:18:52.000000000 +0300
137 +++ linux-2.4.21-chaos/fs/ext3/inode.c 2003-12-12 16:18:53.000000000 +0300
138 @@ -2233,7 +2233,7 @@
142 - new_inode = ext3_new_inode(handle, old_inode, old_inode->i_mode);
143 + new_inode = ext3_new_inode(handle, old_inode, old_inode->i_mode, 0);
144 if (IS_ERR(new_inode)) {
145 ext3_debug("truncate inode %lu directly (no new inodes)\n",
147 Index: linux-2.4.21-chaos/fs/ext3/ioctl.c
148 ===================================================================
149 --- linux-2.4.21-chaos.orig/fs/ext3/ioctl.c 2003-12-12 16:18:40.000000000 +0300
150 +++ linux-2.4.21-chaos/fs/ext3/ioctl.c 2003-12-12 16:18:53.000000000 +0300
152 ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
155 + case EXT3_IOC_CREATE_INUM: {
157 + struct dentry *dchild, *dparent;
160 + dparent = list_entry(inode->i_dentry.next, struct dentry,
162 + snprintf(name, sizeof name, "%lu", arg);
163 + dchild = lookup_one_len(name, dparent, strlen(name));
164 + if (dchild->d_inode) {
165 + printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
166 + dparent->d_name.len, dparent->d_name.name, arg,
167 + dchild->d_inode->i_ino);
170 + dchild->d_fsdata = (void *)arg;
171 + rc = vfs_create(inode, dchild, 0644);
173 + printk(KERN_ERR "vfs_create: %d\n", rc);
174 + else if (dchild->d_inode->i_ino != arg)
180 case EXT3_IOC_GETFLAGS:
181 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
182 return put_user(flags, (int *) arg);
183 Index: linux-2.4.21-chaos/include/linux/ext3_fs.h
184 ===================================================================
185 --- linux-2.4.21-chaos.orig/include/linux/ext3_fs.h 2003-12-12 16:18:52.000000000 +0300
186 +++ linux-2.4.21-chaos/include/linux/ext3_fs.h 2003-12-12 16:18:53.000000000 +0300
188 #define EXT3_IOC_SETFLAGS _IOW('f', 2, long)
189 #define EXT3_IOC_GETVERSION _IOR('f', 3, long)
190 #define EXT3_IOC_SETVERSION _IOW('f', 4, long)
191 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
192 #define EXT3_IOC_GETVERSION_OLD _IOR('v', 1, long)
193 #define EXT3_IOC_SETVERSION_OLD _IOW('v', 2, long)
194 #ifdef CONFIG_JBD_DEBUG
196 dx_hash_info *hinfo);
199 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
200 +extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int,
202 extern void ext3_free_inode (handle_t *, struct inode *);
203 extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
204 extern unsigned long ext3_count_free_inodes (struct super_block *);
207 #endif /* __KERNEL__ */
209 +#define EXT3_IOC_CREATE_INUM _IOW('f', 5, long)
210 #endif /* _LINUX_EXT3_FS_H */
211 Index: linux-2.4.21-chaos/include/linux/dcache.h
212 ===================================================================
213 --- linux-2.4.21-chaos.orig/include/linux/dcache.h 2003-12-12 16:18:06.000000000 +0300
214 +++ linux-2.4.21-chaos/include/linux/dcache.h 2003-12-12 16:18:53.000000000 +0300
217 #define IS_ROOT(x) ((x) == (x)->d_parent)
219 +struct dentry_params {
220 + unsigned long p_inum;
225 * "quick string" -- eases parameter passing, but more importantly
226 * saves "metadata" about the string (ie length and the hash).