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(-)
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.
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,
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
22 es = EXT3_SB(sb)->s_es;
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);
30 + bitmap_bh = read_inode_bitmap (sb, group);
34 + BUFFER_TRACE(bh, "get_write_access");
35 + err = ext3_journal_get_write_access(handle, bitmap_bh);
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;
45 + BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
46 + err = ext3_journal_dirty_metadata(handle, bitmap_bh);
49 + /* We've shortcircuited the allocation system successfully,
50 + * now finish filling in the inode.
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);
65 + case EXT3_IOC_CREATE_INUM: {
67 + struct dentry *dchild, *dparent;
70 + dparent = list_entry(inode->i_dentry.next, struct dentry,
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);
80 + dchild->d_fsdata = (void *)arg;
81 + rc = vfs_create(inode, dchild, 0644, NULL);
83 + printk(KERN_ERR "vfs_create: %d\n", rc);
84 + else if (dchild->d_inode->i_ino != arg)
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
99 +static struct inode * ext3_new_inode_wantedi(handle_t *handle, struct inode *dir,
100 + int mode, struct dentry *dentry)
102 + unsigned long inum = 0;
104 + if (dentry->d_fsdata != NULL) {
105 + struct dentry_params *param =
106 + (struct dentry_params *) dentry->d_fsdata;
107 + inum = param->p_inum;
109 + return ext3_new_inode(handle, dir, mode, inum);
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
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
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
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);
142 @@ -2094,7 +2107,7 @@ static int ext3_symlink (struct inode *
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);
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;
155 #define IS_ROOT(x) ((x) == (x)->d_parent)
157 +struct dentry_params {
158 + unsigned long p_inum;
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);
179 -extern struct inode * ext3_new_inode (handle_t *, struct inode *, int);
180 +extern struct inode * ext3_new_inode (handle_t *, struct inode *, int,
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
187 #endif /* __KERNEL__ */
189 +#define EXT3_IOC_CREATE_INUM _IOW('f', 5, long)
190 #endif /* _LINUX_EXT3_FS_H */