Whamcloud - gitweb
- merge 0.7rc1 from b_devel to HEAD (20030612 merge point)
[fs/lustre-release.git] / lustre / kernel_patches / patches / extN-wantedi.patch
1  fs/ext3/ialloc.c        |   38 ++++++++++++++++++++++++++++++++++++--
2  fs/ext3/ioctl.c         |   25 +++++++++++++++++++++++++
3  fs/ext3/namei.c         |   12 ++++++++----
4  include/linux/ext3_fs.h |    5 ++++-
5  4 files changed, 73 insertions(+), 7 deletions(-)
6
7 --- linux-2.4.20/fs/ext3/namei.c~extN-wantedi   2003-04-08 23:35:55.000000000 -0600
8 +++ linux-2.4.20-braam/fs/ext3/namei.c  2003-04-08 23:35:55.000000000 -0600
9 @@ -1555,7 +1555,8 @@ static int ext3_create (struct inode * d
10         if (IS_SYNC(dir))
11                 handle->h_sync = 1;
12  
13 -       inode = ext3_new_inode (handle, dir, mode);
14 +       inode = ext3_new_inode (handle, dir, mode,
15 +                               (unsigned long)dentry->d_fsdata);
16         err = PTR_ERR(inode);
17         if (!IS_ERR(inode)) {
18                 inode->i_op = &ext3_file_inode_operations;
19 @@ -1583,7 +1584,8 @@ static int ext3_mknod (struct inode * di
20         if (IS_SYNC(dir))
21                 handle->h_sync = 1;
22  
23 -       inode = ext3_new_inode (handle, dir, mode);
24 +       inode = ext3_new_inode (handle, dir, mode,
25 +                               (unsigned long)dentry->d_fsdata);
26         err = PTR_ERR(inode);
27         if (!IS_ERR(inode)) {
28                 init_special_inode(inode, mode, rdev);
29 @@ -1613,7 +1615,8 @@ static int ext3_mkdir(struct inode * dir
30         if (IS_SYNC(dir))
31                 handle->h_sync = 1;
32  
33 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
34 +       inode = ext3_new_inode (handle, dir, S_IFDIR | mode,
35 +                               (unsigned long)dentry->d_fsdata);
36         err = PTR_ERR(inode);
37         if (IS_ERR(inode))
38                 goto out_stop;
39 @@ -2009,7 +2012,8 @@ static int ext3_symlink (struct inode * 
40         if (IS_SYNC(dir))
41                 handle->h_sync = 1;
42  
43 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
44 +       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO,
45 +                               (unsigned long)dentry->d_fsdata);
46         err = PTR_ERR(inode);
47         if (IS_ERR(inode))
48                 goto out_stop;
49 --- linux-2.4.20/fs/ext3/ialloc.c~extN-wantedi  2003-04-08 23:35:55.000000000 -0600
50 +++ linux-2.4.20-braam/fs/ext3/ialloc.c 2003-04-08 23:35:55.000000000 -0600
51 @@ -299,7 +299,8 @@ error_return:
52   * group to find a free inode.
53   */
54  struct inode * ext3_new_inode (handle_t *handle,
55 -                               const struct inode * dir, int mode)
56 +                               const struct inode * dir, int mode,
57 +                               unsigned long goal)
58  {
59         struct super_block * sb;
60         struct buffer_head * bh;
61 @@ -323,7 +324,39 @@ struct inode * ext3_new_inode (handle_t 
62         init_rwsem(&inode->u.ext3_i.truncate_sem);
63  
64         lock_super (sb);
65 -       es = sb->u.ext3_sb.s_es;
66 +       es = EXT3_SB(sb)->s_es;
67 +
68 +       if (goal) {
69 +               i = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
70 +               j = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
71 +               gdp = ext3_get_group_desc(sb, i, &bh2);
72 +
73 +               bitmap_nr = load_inode_bitmap (sb, i);
74 +               if (bitmap_nr < 0)
75 +                       goto fail;
76 +
77 +               bh = EXT3_SB(sb)->s_inode_bitmap[bitmap_nr];
78 +
79 +               BUFFER_TRACE(bh, "get_write_access");
80 +               err = ext3_journal_get_write_access(handle, bh);
81 +               if (err) goto fail;
82 +
83 +               if (ext3_set_bit(j, bh->b_data)) {
84 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
85 +                       /* Oh well, we tried. */
86 +                       goto repeat;
87 +               }
88 +
89 +               BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
90 +               err = ext3_journal_dirty_metadata(handle, bh);
91 +               if (err) goto fail;
92 +
93 +               /* We've shortcircuited the allocation system successfully,
94 +                * now finish filling in the inode.
95 +                */
96 +               goto have_bit_and_group;
97 +       }
98 +
99  repeat:
100         gdp = NULL;
101         i = 0;
102 @@ -438,6 +471,7 @@ repeat:
103                 }
104                 goto repeat;
105         }
106 + have_bit_and_group:
107         j += i * EXT3_INODES_PER_GROUP(sb) + 1;
108         if (j < EXT3_FIRST_INO(sb) || j > le32_to_cpu(es->s_inodes_count)) {
109                 ext3_error (sb, "ext3_new_inode",
110 --- linux-2.4.20/fs/ext3/ioctl.c~extN-wantedi   2003-04-08 23:35:55.000000000 -0600
111 +++ linux-2.4.20-braam/fs/ext3/ioctl.c  2003-04-08 23:35:55.000000000 -0600
112 @@ -23,6 +23,31 @@ int ext3_ioctl (struct inode * inode, st
113         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
114  
115         switch (cmd) {
116 +       case EXT3_IOC_CREATE_INUM: {
117 +               char name[32];
118 +               struct dentry *dchild, *dparent;
119 +               int rc = 0;
120 +
121 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
122 +                                    d_alias);
123 +               snprintf(name, sizeof name, "%lu", arg);
124 +               dchild = lookup_one_len(name, dparent, strlen(name));
125 +               if (dchild->d_inode) {
126 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
127 +                              dparent->d_name.len, dparent->d_name.name, arg,
128 +                              dchild->d_inode->i_ino);
129 +                       rc = -EEXIST;
130 +               } else {
131 +                       dchild->d_fsdata = (void *)arg;
132 +                       rc = vfs_create(inode, dchild, 0644);
133 +                       if (rc)
134 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
135 +                       else if (dchild->d_inode->i_ino != arg)
136 +                               rc = -EEXIST;
137 +               }
138 +               dput(dchild);
139 +               return rc;
140 +       }
141         case EXT3_IOC_GETFLAGS:
142                 flags = inode->u.ext3_i.i_flags & EXT3_FL_USER_VISIBLE;
143                 return put_user(flags, (int *) arg);
144 --- linux-2.4.20/include/linux/ext3_fs.h~extN-wantedi   2003-04-08 23:35:55.000000000 -0600
145 +++ linux-2.4.20-braam/include/linux/ext3_fs.h  2003-04-08 23:35:55.000000000 -0600
146 @@ -201,6 +201,7 @@ struct ext3_group_desc
147  #define        EXT3_IOC_SETFLAGS               _IOW('f', 2, long)
148  #define        EXT3_IOC_GETVERSION             _IOR('f', 3, long)
149  #define        EXT3_IOC_SETVERSION             _IOW('f', 4, long)
150 +/* EXT3_IOC_CREATE_INUM at bottom of file (visible to kernel and user). */
151  #define        EXT3_IOC_GETVERSION_OLD         _IOR('v', 1, long)
152  #define        EXT3_IOC_SETVERSION_OLD         _IOW('v', 2, long)
153  #ifdef CONFIG_JBD_DEBUG
154 @@ -671,7 +672,8 @@ extern int ext3fs_dirhash(const char *na
155                           dx_hash_info *hinfo);
156  
157  /* ialloc.c */
158 -extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int);
159 +extern struct inode * ext3_new_inode (handle_t *, const struct inode *, int,
160 +                                     unsigned long);
161  extern void ext3_free_inode (handle_t *, struct inode *);
162  extern struct inode * ext3_orphan_get (struct super_block *, unsigned long);
163  extern unsigned long ext3_count_free_inodes (struct super_block *);
164 @@ -757,4 +759,5 @@ extern struct inode_operations ext3_fast
165  
166  #endif /* __KERNEL__ */
167  
168 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
169  #endif /* _LINUX_EXT3_FS_H */
170
171 _