add patch fold-ext4_sync_fs_nojournal
[ext4-patch-queue.git] / convert-do_split-to-use-the-ERR_PTR-convention
blob78970b4621ff3051dbb27ef706550ec3f1f7784b
1 ext4: convert do_split() to use the ERR_PTR convention
3 From: Theodore Ts'o <tytso@mit.edu>
5 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
6 ---
7  fs/ext4/namei.c | 23 +++++++++++------------
8  1 file changed, 11 insertions(+), 12 deletions(-)
10 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
11 index e6d5165..dec92b6 100644
12 --- a/fs/ext4/namei.c
13 +++ b/fs/ext4/namei.c
14 @@ -1509,7 +1509,7 @@ static struct ext4_dir_entry_2* dx_pack_dirents(char *base, unsigned blocksize)
15   */
16  static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
17                         struct buffer_head **bh,struct dx_frame *frame,
18 -                       struct dx_hash_info *hinfo, int *error)
19 +                       struct dx_hash_info *hinfo)
20  {
21         unsigned blocksize = dir->i_sb->s_blocksize;
22         unsigned count, continued;
23 @@ -1532,8 +1532,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
24         if (IS_ERR(bh2)) {
25                 brelse(*bh);
26                 *bh = NULL;
27 -               *error = PTR_ERR(bh2);
28 -               return NULL;
29 +               return (struct ext4_dir_entry_2 *) bh2;
30         }
32         BUFFER_TRACE(*bh, "get_write_access");
33 @@ -1593,8 +1592,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
34         dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data2, blocksize, 1));
36         /* Which block gets the new entry? */
37 -       if (hinfo->hash >= hash2)
38 -       {
39 +       if (hinfo->hash >= hash2) {
40                 swap(*bh, bh2);
41                 de = de2;
42         }
43 @@ -1614,8 +1612,7 @@ journal_error:
44         brelse(bh2);
45         *bh = NULL;
46         ext4_std_error(dir->i_sb, err);
47 -       *error = err;
48 -       return NULL;
49 +       return ERR_PTR(err);
50  }
52  int ext4_find_dest_de(struct inode *dir, struct inode *inode,
53 @@ -1838,8 +1835,8 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
54         ext4_handle_dirty_dx_node(handle, dir, frame->bh);
55         ext4_handle_dirty_dirent_node(handle, dir, bh);
57 -       de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
58 -       if (!de) {
59 +       de = do_split(handle,dir, &bh, frame, &hinfo);
60 +       if (IS_ERR(de)) {
61                 /*
62                  * Even if the block split failed, we have to properly write
63                  * out all the changes we did so far. Otherwise we can end up
64 @@ -1847,7 +1844,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
65                  */
66                 ext4_mark_inode_dirty(handle, dir);
67                 dx_release(frames);
68 -               return retval;
69 +               return PTR_ERR(de);
70         }
71         dx_release(frames);
73 @@ -2071,9 +2068,11 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
74                         goto cleanup;
75                 }
76         }
77 -       de = do_split(handle, dir, &bh, frame, &hinfo, &err);
78 -       if (!de)
79 +       de = do_split(handle, dir, &bh, frame, &hinfo);
80 +       if (IS_ERR(de)) {
81 +               err = PTR_ERR(de);
82                 goto cleanup;
83 +       }
84         err = add_dirent_to_buf(handle, dentry, inode, de, bh);
85         goto cleanup;
87 -- 
88 2.1.0