Whamcloud - gitweb
b=22790 strip the .patch off of the dpatch name
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext3-wantedi-2.6-suse.patch
1 diff -urp linux-2.6.5-7.282.orig/fs/ext3/ialloc.c linux-2.6.5-7.282/fs/ext3/ialloc.c
2 --- linux-2.6.5-7.282.orig/fs/ext3/ialloc.c     2006-08-30 17:12:13.000000000 +0300
3 +++ linux-2.6.5-7.282/fs/ext3/ialloc.c  2007-02-16 07:43:08.000000000 +0200
4 @@ -420,7 +420,8 @@ static int find_group_other(struct super
5   * For other inodes, search forward from the parent directory's block
6   * group to find a free inode.
7   */
8 -struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode)
9 +struct inode *ext3_new_inode(handle_t *handle, struct inode * dir, int mode,
10 +                               unsigned long goal)
11  {
12         struct super_block *sb;
13         struct buffer_head *bitmap_bh = NULL;
14 @@ -448,6 +449,41 @@ struct inode *ext3_new_inode(handle_t *h
15  
16         sbi = EXT3_SB(sb);
17         es = sbi->s_es;
18 +       if (goal) {
19 +               group = (goal - 1) / EXT3_INODES_PER_GROUP(sb);
20 +               ino = (goal - 1) % EXT3_INODES_PER_GROUP(sb);
21 +               err = -EIO;
22 +
23 +               gdp = ext3_get_group_desc(sb, group, &bh2);
24 +               if (!gdp)
25 +                       goto fail;
26 +
27 +               bitmap_bh = read_inode_bitmap (sb, group);
28 +               if (!bitmap_bh)
29 +                       goto fail;
30 +
31 +               BUFFER_TRACE(bh, "get_write_access");
32 +               err = ext3_journal_get_write_access(handle, bitmap_bh);
33 +               if (err) goto fail;
34 +
35 +               if (ext3_set_bit_atomic(sb_bgl_lock(sbi, group),
36 +                                       ino, bitmap_bh->b_data)) {
37 +                       printk(KERN_ERR "goal inode %lu unavailable\n", goal);
38 +                       /* Oh well, we tried. */
39 +                       goto continue_allocation;
40 +               }
41 +
42 +               BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
43 +               err = ext3_journal_dirty_metadata(handle, bitmap_bh);
44 +               if (err) goto fail;
45 +
46 +               /* We've shortcircuited the allocation system successfully,
47 +                * now finish filling in the inode.
48 +                */
49 +               goto got;
50 +       }
51 +
52 +continue_allocation:
53         if (S_ISDIR(mode)) {
54                 if (test_opt (sb, OLDALLOC))
55                         group = find_group_dir(sb, dir);
56 diff -urp linux-2.6.5-7.282.orig/fs/ext3/ioctl.c linux-2.6.5-7.282/fs/ext3/ioctl.c
57 --- linux-2.6.5-7.282.orig/fs/ext3/ioctl.c      2006-08-30 17:12:13.000000000 +0300
58 +++ linux-2.6.5-7.282/fs/ext3/ioctl.c   2007-02-16 07:43:08.000000000 +0200
59 @@ -25,6 +25,31 @@ int ext3_ioctl (struct inode * inode, st
60         ext3_debug ("cmd = %u, arg = %lu\n", cmd, arg);
61  
62         switch (cmd) {
63 +       case EXT3_IOC_CREATE_INUM: {
64 +               char name[32];
65 +               struct dentry *dchild, *dparent;
66 +               int rc = 0;
67 +
68 +               dparent = list_entry(inode->i_dentry.next, struct dentry,
69 +                                    d_alias);
70 +               snprintf(name, sizeof name, "%lu", arg);
71 +               dchild = lookup_one_len(name, dparent, strlen(name));
72 +               if (dchild->d_inode) {
73 +                       printk(KERN_ERR "%*s/%lu already exists (ino %lu)\n",
74 +                              dparent->d_name.len, dparent->d_name.name, arg,
75 +                              dchild->d_inode->i_ino);
76 +                       rc = -EEXIST;
77 +               } else {
78 +                       dchild->d_fsdata = (void *)arg;
79 +                       rc = vfs_create(inode, dchild, 0644, NULL);
80 +                       if (rc)
81 +                               printk(KERN_ERR "vfs_create: %d\n", rc);
82 +                       else if (dchild->d_inode->i_ino != arg)
83 +                               rc = -EEXIST;
84 +               }
85 +               dput(dchild);
86 +               return rc;
87 +       }
88         case EXT3_IOC_GETFLAGS:
89                 flags = ei->i_flags & EXT3_FL_USER_VISIBLE;
90                 return put_user(flags, (int *) arg);
91 diff -urp linux-2.6.5-7.282.orig/fs/ext3/namei.c linux-2.6.5-7.282/fs/ext3/namei.c
92 --- linux-2.6.5-7.282.orig/fs/ext3/namei.c      2006-08-30 17:12:34.000000000 +0300
93 +++ linux-2.6.5-7.282/fs/ext3/namei.c   2007-02-16 07:46:13.000000000 +0200
94 @@ -144,6 +144,14 @@ struct dx_map_entry
95         u32 offs;
96  };
97  
98 +#define LVFS_DENTRY_PARAM_MAGIC                20070216UL
99 +struct lvfs_dentry_params
100 +{
101 +       unsigned long   p_inum;
102 +       void            *p_ptr; 
103 +       u32             magic;
104 +};
105 +
106  #ifdef CONFIG_EXT3_INDEX
107  static inline unsigned dx_get_block (struct dx_entry *entry);
108  static void dx_set_block (struct dx_entry *entry, unsigned value);
109 @@ -1625,6 +1633,20 @@ static int ext3_add_nondir(handle_t *han
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 lvfs_dentry_params *param = dentry->d_fsdata;
120 +
121 +               if (param->magic == LVFS_DENTRY_PARAM_MAGIC)
122 +                       inum = param->p_inum;
123 +       }
124 +       return ext3_new_inode(handle, dir, mode, inum);
125 +}
126 +
127  /*
128   * By the time this is called, we already have created
129   * the directory cache entry for the new file, but it
130 @@ -1649,7 +1671,7 @@ retry:
131         if (IS_DIRSYNC(dir))
132                 handle->h_sync = 1;
133  
134 -       inode = ext3_new_inode (handle, dir, mode);
135 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
136         err = PTR_ERR(inode);
137         if (!IS_ERR(inode)) {
138                 inode->i_op = &ext3_file_inode_operations;
139 @@ -1682,7 +1704,7 @@ retry:
140         if (IS_DIRSYNC(dir))
141                 handle->h_sync = 1;
142  
143 -       inode = ext3_new_inode (handle, dir, mode);
144 +       inode = ext3_new_inode_wantedi (handle, dir, mode, dentry);
145         err = PTR_ERR(inode);
146         if (!IS_ERR(inode)) {
147                 init_special_inode(inode, inode->i_mode, rdev);
148 @@ -1718,7 +1740,7 @@ retry:
149         if (IS_DIRSYNC(dir))
150                 handle->h_sync = 1;
151  
152 -       inode = ext3_new_inode (handle, dir, S_IFDIR | mode);
153 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
154         err = PTR_ERR(inode);
155         if (IS_ERR(inode))
156                 goto out_stop;
157 @@ -2113,7 +2135,7 @@ retry:
158         if (IS_DIRSYNC(dir))
159                 handle->h_sync = 1;
160  
161 -       inode = ext3_new_inode (handle, dir, S_IFLNK|S_IRWXUGO);
162 +       inode = ext3_new_inode_wantedi (handle, dir, S_IFLNK|S_IRWXUGO, dentry);
163         err = PTR_ERR(inode);
164         if (IS_ERR(inode))
165                 goto out_stop;
166 diff -urp linux-2.6.5-7.282.orig/include/linux/ext3_fs.h linux-2.6.5-7.282/include/linux/ext3_fs.h
167 --- linux-2.6.5-7.282.orig/include/linux/ext3_fs.h      2006-08-30 17:12:13.000000000 +0300
168 +++ linux-2.6.5-7.282/include/linux/ext3_fs.h   2007-02-16 07:43:08.000000000 +0200
169 @@ -203,6 +203,7 @@ struct ext3_group_desc
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 @@ -712,7 +713,8 @@ extern int ext3fs_dirhash(const char *na
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 @@ -797,4 +799,5 @@ extern struct inode_operations ext3_fast
188  
189  #endif /* __KERNEL__ */
190  
191 +#define EXT3_IOC_CREATE_INUM                   _IOW('f', 5, long)
192  #endif /* _LINUX_EXT3_FS_H */