Whamcloud - gitweb
b=22771 Patch to disable mbcache
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-osd-iop-common-sles11.patch
1 diff -rupN linux-2.6.27.21-0.1_1//fs/ext4/ext4.h linux-2.6.27.21-0.1_2//fs/ext4/ext4.h
2 --- linux-2.6.27.21-0.1_1//fs/ext4/ext4.h       2009-08-24 15:32:00.000000000 +0530
3 +++ linux-2.6.27.21-0.1_2//fs/ext4/ext4.h       2009-08-24 15:32:55.000000000 +0530
4 @@ -1171,6 +1171,18 @@ extern int ext4_fiemap(struct inode *, s
5  /* migrate.c */
6  extern int ext4_ext_migrate(struct inode *);
7  /* namei.c */
8 +extern struct inode *ext4_create_inode(handle_t *handle,
9 +                                         struct inode * dir, int mode);
10 +extern int ext4_add_entry(handle_t *handle, struct dentry *dentry,
11 +                            struct inode *inode);
12 +extern int ext4_delete_entry(handle_t *handle, struct inode * dir,
13 +                               struct ext4_dir_entry_2 * de_del,
14 +                               struct buffer_head * bh);
15 +extern struct buffer_head * ext4_find_entry (struct inode *dir,
16 +                                           const struct qstr *d_name,
17 +                                           struct ext4_dir_entry_2 ** res_dir);
18 +extern int ext4_add_dot_dotdot(handle_t *handle, struct inode *dir,
19 +                                 struct inode *inode);
20  extern int ext4_orphan_add(handle_t *, struct inode *);
21  extern int ext4_orphan_del(handle_t *, struct inode *);
22  extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
23 diff -rupN linux-2.6.27.21-0.1_1//fs/ext4/namei.c linux-2.6.27.21-0.1_2//fs/ext4/namei.c
24 --- linux-2.6.27.21-0.1_1//fs/ext4/namei.c      2009-08-24 15:32:00.000000000 +0530
25 +++ linux-2.6.27.21-0.1_2//fs/ext4/namei.c      2009-08-24 15:43:56.000000000 +0530
26 @@ -24,6 +24,7 @@
27   *     Theodore Ts'o, 2002
28   */
29  
30 +#include <linux/module.h>
31  #include <linux/fs.h>
32  #include <linux/pagemap.h>
33  #include <linux/jbd2.h>
34 @@ -882,9 +883,9 @@ static inline int search_dirblock(struct
35   * The returned buffer_head has ->b_count elevated.  The caller is expected
36   * to brelse() it when appropriate.
37   */
38 -static struct buffer_head * ext4_find_entry (struct inode *dir,
39 -                                       const struct qstr *d_name,
40 -                                       struct ext4_dir_entry_2 ** res_dir)
41 +struct buffer_head * ext4_find_entry (struct inode *dir,
42 +                                     const struct qstr *d_name,
43 +                                     struct ext4_dir_entry_2 ** res_dir)
44  {
45         struct super_block *sb;
46         struct buffer_head *bh_use[NAMEI_RA_SIZE];
47 @@ -991,6 +992,7 @@ cleanup_and_exit:
48                 brelse(bh_use[ra_ptr]);
49         return ret;
50  }
51 +EXPORT_SYMBOL(ext4_find_entry);
52  
53  static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name,
54                        struct ext4_dir_entry_2 **res_dir, int *err)
55 @@ -1511,8 +1513,8 @@ static int make_indexed_dir(handle_t *ha
56   * may not sleep between calling this and putting something into
57   * the entry, as someone else might have used it while you slept.
58   */
59 -static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
60 -                         struct inode *inode)
61 +int ext4_add_entry(handle_t *handle, struct dentry *dentry,
62 +                  struct inode *inode)
63  {
64         struct inode *dir = dentry->d_parent->d_inode;
65         struct buffer_head *bh;
66 @@ -1557,6 +1559,7 @@ static int ext4_add_entry(handle_t *hand
67         de->rec_len = ext4_rec_len_to_disk(blocksize);
68         return add_dirent_to_buf(handle, dentry, inode, de, bh);
69  }
70 +EXPORT_SYMBOL(ext4_add_entry);
71  
72  /*
73   * Returns 0 for success, or a negative error value
74 @@ -1699,10 +1702,10 @@ cleanup:
75   * ext4_delete_entry deletes a directory entry by merging it with the
76   * previous entry
77   */
78 -static int ext4_delete_entry(handle_t *handle,
79 -                            struct inode *dir,
80 -                            struct ext4_dir_entry_2 *de_del,
81 -                            struct buffer_head *bh)
82 +int ext4_delete_entry(handle_t *handle,
83 +                     struct inode *dir,
84 +                     struct ext4_dir_entry_2 *de_del,
85 +                     struct buffer_head *bh)
86  {
87         struct ext4_dir_entry_2 *de, *pde;
88         int i;
89 @@ -1733,7 +1736,7 @@ static int ext4_delete_entry(handle_t *h
90         }
91         return -ENOENT;
92  }
93 -
94 +EXPORT_SYMBOL(ext4_delete_entry);
95  /*
96   * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2,
97   * since this indicates that nlinks count was previously 1.
98 @@ -1796,6 +1799,26 @@ static unsigned ext4_dentry_goal(struct
99         return inum;
100  }
101  
102 +struct inode * ext4_create_inode(handle_t *handle, struct inode * dir, int mode)
103 +{
104 +       struct inode *inode;
105 +
106 +       inode = ext4_new_inode(handle, dir, mode);
107 +       if (!IS_ERR(inode)) {
108 +               if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) {
109 +#ifdef CONFIG_LDISKFS_FS_XATTR
110 +                       inode->i_op = &ext4_special_inode_operations;
111 +#endif
112 +               } else {
113 +                       inode->i_op = &ext4_file_inode_operations;
114 +                       inode->i_fop = &ext4_file_operations;
115 +                       ext4_set_aops(inode);
116 +               }
117 +       }
118 +       return inode;
119 +}
120 +EXPORT_SYMBOL(ext4_create_inode);
121 +
122  /*
123   * By the time this is called, we already have created
124   * the directory cache entry for the new file, but it
125 @@ -1872,51 +1895,43 @@ retry:
126         return err;
127  }
128  
129 -static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
130 +/* Initialize @inode as a subdirectory of @dir, and add the
131 + * "." and ".." entries into the first directory block. */
132 +int ext4_add_dot_dotdot(handle_t *handle, struct inode * dir,
133 +                       struct inode *inode)
134  {
135 -       handle_t *handle;
136 -       struct inode *inode;
137 -       struct buffer_head *dir_block;
138 -       struct ext4_dir_entry_2 *de;
139 -       int err, retries = 0;
140 -
141 -       if (EXT4_DIR_LINK_MAX(dir))
142 -               return -EMLINK;
143 +       struct buffer_head * dir_block;
144 +       struct ext4_dir_entry_2 * de;
145 +       int err = 0;
146  
147 -retry:
148 -       handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
149 -                                       EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
150 -                                       2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
151         if (IS_ERR(handle))
152                 return PTR_ERR(handle);
153  
154         if (IS_DIRSYNC(dir))
155                 handle->h_sync = 1;
156  
157 -       inode = ext4_new_inode_goal(handle, dir, S_IFDIR | mode,
158 -                                   ext4_dentry_goal(dir->i_sb, dentry));
159 -       err = PTR_ERR(inode);
160 -       if (IS_ERR(inode))
161 -               goto out_stop;
162 -
163         inode->i_op = &ext4_dir_inode_operations;
164         inode->i_fop = &ext4_dir_operations;
165         inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
166 -       dir_block = ext4_bread(handle, inode, 0, 1, &err);
167 -       if (!dir_block)
168 -               goto out_clear_inode;
169 +       dir_block = ext4_bread (handle, inode, 0, 1, &err);
170 +       if (!dir_block) {
171 +               clear_nlink(inode);
172 +               ext4_mark_inode_dirty(handle, inode);
173 +               iput (inode);
174 +               goto get_out;
175 +       }
176         BUFFER_TRACE(dir_block, "get_write_access");
177         ext4_journal_get_write_access(handle, dir_block);
178         de = (struct ext4_dir_entry_2 *) dir_block->b_data;
179         de->inode = cpu_to_le32(inode->i_ino);
180         de->name_len = 1;
181         de->rec_len = ext4_rec_len_to_disk(EXT4_DIR_REC_LEN(de->name_len));
182 -       strcpy(de->name, ".");
183 +       strcpy (de->name, ".");
184         ext4_set_de_type(dir->i_sb, de, S_IFDIR);
185         de = ext4_next_entry(de);
186         de->inode = cpu_to_le32(dir->i_ino);
187         de->rec_len = ext4_rec_len_to_disk(inode->i_sb->s_blocksize -
188 -                                               EXT4_DIR_REC_LEN(1));
189 +                                             EXT4_DIR_REC_LEN(1));
190         de->name_len = 2;
191         strcpy(de->name, "..");
192         ext4_set_de_type(dir->i_sb, de, S_IFDIR);
193 @@ -1925,9 +1940,43 @@ retry:
194         ext4_journal_dirty_metadata(handle, dir_block);
195         brelse(dir_block);
196         ext4_mark_inode_dirty(handle, inode);
197 +get_out:
198 +       return err;
199 +}
200 +EXPORT_SYMBOL(ext4_add_dot_dotdot);
201 +
202 +
203 +static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
204 +{
205 +       handle_t *handle;
206 +       struct inode *inode;
207 +       int err, retries = 0;
208 +
209 +       if (EXT4_DIR_LINK_MAX(dir))
210 +               return -EMLINK;
211 +
212 +retry:
213 +       handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
214 +                                       EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
215 +                                       2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
216 +       if (IS_ERR(handle))
217 +               return PTR_ERR(handle);
218 +
219 +       if (IS_DIRSYNC(dir))
220 +               handle->h_sync = 1;
221 +
222 +       inode = ext4_new_inode_goal(handle, dir, S_IFDIR | mode,
223 +                                   ext4_dentry_goal(dir->i_sb, dentry));
224 +       err = PTR_ERR(inode);
225 +       if (IS_ERR(inode))
226 +               goto out_stop;
227 +
228 +       err = ext4_add_dot_dotdot(handle, dir, inode);
229 +       if (err)
230 +               goto out_stop;
231 +
232         err = ext4_add_entry(handle, dentry, inode);
233         if (err) {
234 -out_clear_inode:
235                 clear_nlink(inode);
236                 ext4_mark_inode_dirty(handle, inode);
237                 iput(inode);