Whamcloud - gitweb
bc184c5d310513076c3ef78f137d8a29b04e8407
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-osd-iop-common.patch
1 diff -rupN linux-2.6.18-128.1.6_1//fs/ext4/ext4.h linux-2.6.18-128.1.6_2//fs/ext4/ext4.h
2 --- linux-2.6.18-128.1.6_1//fs/ext4/ext4.h      2009-08-24 15:54:11.000000000 +0530
3 +++ linux-2.6.18-128.1.6_2//fs/ext4/ext4.h      2009-08-24 15:54:52.000000000 +0530
4 @@ -1144,6 +1144,18 @@ extern int ext4_fiemap(struct inode *, s
5  extern int ext4_ext_migrate(struct inode *, struct file *, unsigned int,
6                        unsigned long);
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 dentry *dentry,
16 +                                           struct ext4_dir_entry_2
17 +                                           ** 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.18-128.1.6_1//fs/ext4/inode.c linux-2.6.18-128.1.6_2//fs/ext4/inode.c
24 --- linux-2.6.18-128.1.6_1//fs/ext4/inode.c     2009-08-24 15:54:11.000000000 +0530
25 +++ linux-2.6.18-128.1.6_2//fs/ext4/inode.c     2009-08-24 15:54:52.000000000 +0530
26 @@ -2891,6 +2891,7 @@ bad_inode:
27         iput(inode);
28         return ERR_PTR(ret);
29  }
30 +EXPORT_SYMBOL(ext4_iget);
31  
32  static int ext4_inode_blocks_set(handle_t *handle,
33                                 struct ext4_inode *raw_inode,
34 diff -rupN linux-2.6.18-128.1.6_1//fs/ext4/namei.c linux-2.6.18-128.1.6_2//fs/ext4/namei.c
35 --- linux-2.6.18-128.1.6_1//fs/ext4/namei.c     2009-08-24 15:54:11.000000000 +0530
36 +++ linux-2.6.18-128.1.6_2//fs/ext4/namei.c     2009-08-24 15:55:18.000000000 +0530
37 @@ -24,6 +24,7 @@
38   *     Theodore Ts'o, 2002
39   */
40  
41 +#include <linux/module.h>
42  #include <linux/fs.h>
43  #include <linux/pagemap.h>
44  #include <linux/jbd2.h>
45 @@ -878,8 +879,8 @@ static inline int search_dirblock(struct
46   * The returned buffer_head has ->b_count elevated.  The caller is expected
47   * to brelse() it when appropriate.
48   */
49 -static struct buffer_head * ext4_find_entry (struct dentry *dentry,
50 -                                       struct ext4_dir_entry_2 ** res_dir)
51 +struct buffer_head * ext4_find_entry (struct dentry *dentry,
52 +                                     struct ext4_dir_entry_2 ** res_dir)
53  {
54         struct super_block * sb;
55         struct buffer_head * bh_use[NAMEI_RA_SIZE];
56 @@ -986,6 +987,7 @@ cleanup_and_exit:
57                 brelse (bh_use[ra_ptr]);
58         return ret;
59  }
60 +EXPORT_SYMBOL(ext4_find_entry);
61  
62  static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry,
63                        struct ext4_dir_entry_2 **res_dir, int *err)
64 @@ -1506,8 +1508,8 @@ static int make_indexed_dir(handle_t *ha
65   * may not sleep between calling this and putting something into
66   * the entry, as someone else might have used it while you slept.
67   */
68 -static int ext4_add_entry (handle_t *handle, struct dentry *dentry,
69 -       struct inode *inode)
70 +int ext4_add_entry (handle_t *handle, struct dentry *dentry,
71 +                   struct inode *inode)
72  {
73         struct inode *dir = dentry->d_parent->d_inode;
74         unsigned long offset;
75 @@ -1553,6 +1555,7 @@ static int ext4_add_entry (handle_t *han
76         de->rec_len = ext4_rec_len_to_disk(blocksize);
77         return add_dirent_to_buf(handle, dentry, inode, de, bh);
78  }
79 +EXPORT_SYMBOL(ext4_add_entry);
80  
81  /*
82   * Returns 0 for success, or a negative error value
83 @@ -1693,10 +1696,10 @@ cleanup:
84   * ext4_delete_entry deletes a directory entry by merging it with the
85   * previous entry
86   */
87 -static int ext4_delete_entry (handle_t *handle,
88 -                             struct inode * dir,
89 -                             struct ext4_dir_entry_2 * de_del,
90 -                             struct buffer_head * bh)
91 +int ext4_delete_entry (handle_t *handle,
92 +                      struct inode * dir,
93 +                      struct ext4_dir_entry_2 * de_del,
94 +                      struct buffer_head * bh)
95  {
96         struct ext4_dir_entry_2 * de, * pde;
97         int i;
98 @@ -1727,7 +1730,7 @@ static int ext4_delete_entry (handle_t *
99         }
100         return -ENOENT;
101  }
102 -
103 +EXPORT_SYMBOL(ext4_delete_entry);
104  /*
105   * DIR_NLINK feature is set if 1) nlinks > EXT4_LINK_MAX or 2) nlinks == 2,
106   * since this indicates that nlinks count was previously 1.
107 @@ -1790,6 +1793,26 @@ static struct inode * ext4_new_inode_wan
108         return ext4_new_inode(handle, dir, mode, inum);
109  }
110  
111 +struct inode * ext4_create_inode(handle_t *handle, struct inode * dir, int mode)
112 +{
113 +       struct inode *inode;
114 +
115 +       inode = ext4_new_inode(handle, dir, mode, 0);
116 +       if (!IS_ERR(inode)) {
117 +               if (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode)) {
118 +#ifdef CONFIG_LDISKFS_FS_XATTR
119 +                       inode->i_op = &ext4_special_inode_operations;
120 +#endif
121 +               } else {
122 +                       inode->i_op = &ext4_file_inode_operations;
123 +                       inode->i_fop = &ext4_file_operations;
124 +                       ext4_set_aops(inode);
125 +               }
126 +       }
127 +       return inode;
128 +}
129 +EXPORT_SYMBOL(ext4_create_inode);
130 +
131  /*
132   * By the time this is called, we already have created
133   * the directory cache entry for the new file, but it
134 @@ -1864,38 +1887,25 @@ retry:
135         return err;
136  }
137  
138 -static int ext4_mkdir(struct inode * dir, struct dentry * dentry, int mode)
139 -{
140 -       handle_t *handle;
141 -       struct inode * inode;
142 +/* Initialize @inode as a subdirectory of @dir, and add the
143 + * "." and ".." entries into the first directory block. */
144 +int ext4_add_dot_dotdot(handle_t *handle, struct inode * dir,
145 +                        struct inode *inode)
146 + {
147         struct buffer_head * dir_block;
148         struct ext4_dir_entry_2 * de;
149 -       int err, retries = 0;
150 -
151 -       if (EXT4_DIR_LINK_MAX(dir))
152 -               return -EMLINK;
153 -
154 -retry:
155 -       handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
156 -                                       EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
157 -                                       2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
158 -       if (IS_ERR(handle))
159 -               return PTR_ERR(handle);
160 -
161 -       if (IS_DIRSYNC(dir))
162 -               handle->h_sync = 1;
163 -
164 -       inode = ext4_new_inode_wantedi (handle, dir, S_IFDIR | mode, dentry);
165 -       err = PTR_ERR(inode);
166 -       if (IS_ERR(inode))
167 -               goto out_stop;
168 +       int err = 0;
169  
170         inode->i_op = &ext4_dir_inode_operations;
171         inode->i_fop = &ext4_dir_operations;
172         inode->i_size = EXT4_I(inode)->i_disksize = inode->i_sb->s_blocksize;
173         dir_block = ext4_bread (handle, inode, 0, 1, &err);
174 -       if (!dir_block)
175 -               goto out_clear_inode;
176 +       if (!dir_block) {
177 +               clear_nlink(inode);
178 +               ext4_mark_inode_dirty(handle, inode);
179 +               iput (inode);
180 +               goto get_out;
181 +       }
182         BUFFER_TRACE(dir_block, "get_write_access");
183         ext4_journal_get_write_access(handle, dir_block);
184         de = (struct ext4_dir_entry_2 *) dir_block->b_data;
185 @@ -1907,7 +1917,7 @@ retry:
186         de = ext4_next_entry(de);
187         de->inode = cpu_to_le32(dir->i_ino);
188         de->rec_len = ext4_rec_len_to_disk(inode->i_sb->s_blocksize -
189 -                                               EXT4_DIR_REC_LEN(1));
190 +                                             EXT4_DIR_REC_LEN(1));
191         de->name_len = 2;
192         strcpy (de->name, "..");
193         ext4_set_de_type(dir->i_sb, de, S_IFDIR);
194 @@ -1916,9 +1926,41 @@ retry:
195         ext4_journal_dirty_metadata(handle, dir_block);
196         brelse (dir_block);
197         ext4_mark_inode_dirty(handle, inode);
198 +get_out:
199 +       return err;
200 +}
201 +EXPORT_SYMBOL(ext4_add_dot_dotdot);
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_wantedi (handle, dir, S_IFDIR | mode, dentry);
223 +       err = PTR_ERR(inode);
224 +       if (IS_ERR(inode))
225 +               goto out_stop;
226 +
227 +       err = ext4_add_dot_dotdot(handle, dir, inode);
228 +       if (err)
229 +               goto out_stop;
230 +
231         err = ext4_add_entry (handle, dentry, inode);
232         if (err) {
233 -out_clear_inode:
234                 clear_nlink(inode);
235                 ext4_mark_inode_dirty(handle, inode);
236                 iput (inode);
237