Fix missing static function declaration
[ext4-patch-queue.git] / convert-ext4_dx_find_entry-to-use-the-ERR_PTR-convention
blob7149c36932bda0e24def445c1dcd3166fce5e41a
1 ext4: convert ext4_dx_find_entry() 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 | 46 ++++++++++++++++++++--------------------------
8  1 file changed, 20 insertions(+), 26 deletions(-)
10 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
11 index 90a3cdc..1421ec1 100644
12 --- a/fs/ext4/namei.c
13 +++ b/fs/ext4/namei.c
14 @@ -270,8 +270,7 @@ static int ext4_htree_next_block(struct inode *dir, __u32 hash,
15                                  __u32 *start_hash);
16  static struct buffer_head * ext4_dx_find_entry(struct inode *dir,
17                 const struct qstr *d_name,
18 -               struct ext4_dir_entry_2 **res_dir,
19 -               int *err);
20 +               struct ext4_dir_entry_2 **res_dir);
21  static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
22                              struct inode *inode);
24 @@ -1258,17 +1257,13 @@ static struct buffer_head * ext4_find_entry (struct inode *dir,
25                 goto restart;
26         }
27         if (is_dx(dir)) {
28 -               bh = ext4_dx_find_entry(dir, d_name, res_dir, &err);
29 +               bh = ext4_dx_find_entry(dir, d_name, res_dir);
30                 /*
31                  * On success, or if the error was file not found,
32                  * return.  Otherwise, fall back to doing a search the
33                  * old fashioned way.
34                  */
35 -               if (err == -ENOENT)
36 -                       return NULL;
37 -               if (err && err != ERR_BAD_DX_DIR)
38 -                       return ERR_PTR(err);
39 -               if (bh)
40 +               if (!IS_ERR(bh) || PTR_ERR(bh) != ERR_BAD_DX_DIR)
41                         return bh;
42                 dxtrace(printk(KERN_DEBUG "ext4_find_entry: dx failed, "
43                                "falling back\n"));
44 @@ -1366,34 +1361,32 @@ cleanup_and_exit:
45  }
47  static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct qstr *d_name,
48 -                      struct ext4_dir_entry_2 **res_dir, int *err)
49 +                      struct ext4_dir_entry_2 **res_dir)
50  {
51         struct super_block * sb = dir->i_sb;
52         struct dx_hash_info     hinfo;
53         struct dx_frame frames[2], *frame;
54         struct buffer_head *bh;
55         ext4_lblk_t block;
56 -       int retval;
57 +       int err = 0, retval;
59 -       if (!(frame = dx_probe(d_name, dir, &hinfo, frames, err)))
60 -               return NULL;
61 +       frame = dx_probe(d_name, dir, &hinfo, frames, &err);
62 +       if (err)
63 +               return ERR_PTR(err);
64         do {
65                 block = dx_get_block(frame->at);
66                 bh = ext4_read_dirblock(dir, block, DIRENT);
67 -               if (IS_ERR(bh)) {
68 -                       *err = PTR_ERR(bh);
69 +               if (IS_ERR(bh))
70                         goto errout;
71 -               }
73                 retval = search_dirblock(bh, dir, d_name,
74                                          block << EXT4_BLOCK_SIZE_BITS(sb),
75                                          res_dir);
76 -               if (retval == 1) {      /* Success! */
77 -                       dx_release(frames);
78 -                       return bh;
79 -               }
80 +               if (retval == 1)
81 +                       goto success;
82                 brelse(bh);
83                 if (retval == -1) {
84 -                       *err = ERR_BAD_DX_DIR;
85 +                       bh = ERR_PTR(ERR_BAD_DX_DIR);
86                         goto errout;
87                 }
89 @@ -1402,18 +1395,19 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q
90                                                frames, NULL);
91                 if (retval < 0) {
92                         ext4_warning(sb,
93 -                            "error reading index page in directory #%lu",
94 -                            dir->i_ino);
95 -                       *err = retval;
96 +                            "error %d reading index page in directory #%lu",
97 +                            retval, dir->i_ino);
98 +                       bh = ERR_PTR(retval);
99                         goto errout;
100                 }
101         } while (retval == 1);
103 -       *err = -ENOENT;
104 +       bh = NULL;
105  errout:
106         dxtrace(printk(KERN_DEBUG "%s not found\n", d_name->name));
107 -       dx_release (frames);
108 -       return NULL;
109 +success:
110 +       dx_release(frames);
111 +       return bh;
114  static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
115 -- 
116 2.1.0