Commit 401bd723 authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Luis Henriques

ext4: convert do_split() to use the ERR_PTR convention

commit f8b3b59d upstream.
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
[ luis: backported to 3.16: useful for:
  6050d47a "ext4: bail out from make_indexed_dir() on first error" ]
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 01eca100
...@@ -1526,7 +1526,7 @@ static struct ext4_dir_entry_2* dx_pack_dirents(char *base, unsigned blocksize) ...@@ -1526,7 +1526,7 @@ static struct ext4_dir_entry_2* dx_pack_dirents(char *base, unsigned blocksize)
*/ */
static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
struct buffer_head **bh,struct dx_frame *frame, struct buffer_head **bh,struct dx_frame *frame,
struct dx_hash_info *hinfo, int *error) struct dx_hash_info *hinfo)
{ {
unsigned blocksize = dir->i_sb->s_blocksize; unsigned blocksize = dir->i_sb->s_blocksize;
unsigned count, continued; unsigned count, continued;
...@@ -1548,8 +1548,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, ...@@ -1548,8 +1548,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
if (IS_ERR(bh2)) { if (IS_ERR(bh2)) {
brelse(*bh); brelse(*bh);
*bh = NULL; *bh = NULL;
*error = PTR_ERR(bh2); return (struct ext4_dir_entry_2 *) bh2;
return NULL;
} }
BUFFER_TRACE(*bh, "get_write_access"); BUFFER_TRACE(*bh, "get_write_access");
...@@ -1609,8 +1608,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, ...@@ -1609,8 +1608,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data2, blocksize, 1)); dxtrace(dx_show_leaf (hinfo, (struct ext4_dir_entry_2 *) data2, blocksize, 1));
/* Which block gets the new entry? */ /* Which block gets the new entry? */
if (hinfo->hash >= hash2) if (hinfo->hash >= hash2) {
{
swap(*bh, bh2); swap(*bh, bh2);
de = de2; de = de2;
} }
...@@ -1630,8 +1628,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, ...@@ -1630,8 +1628,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir,
brelse(bh2); brelse(bh2);
*bh = NULL; *bh = NULL;
ext4_std_error(dir->i_sb, err); ext4_std_error(dir->i_sb, err);
*error = err; return ERR_PTR(err);
return NULL;
} }
int ext4_find_dest_de(struct inode *dir, struct inode *inode, int ext4_find_dest_de(struct inode *dir, struct inode *inode,
...@@ -1852,8 +1849,8 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, ...@@ -1852,8 +1849,8 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
ext4_handle_dirty_dx_node(handle, dir, frame->bh); ext4_handle_dirty_dx_node(handle, dir, frame->bh);
ext4_handle_dirty_dirent_node(handle, dir, bh); ext4_handle_dirty_dirent_node(handle, dir, bh);
de = do_split(handle,dir, &bh, frame, &hinfo, &retval); de = do_split(handle,dir, &bh, frame, &hinfo);
if (!de) { if (IS_ERR(de)) {
/* /*
* Even if the block split failed, we have to properly write * Even if the block split failed, we have to properly write
* out all the changes we did so far. Otherwise we can end up * out all the changes we did so far. Otherwise we can end up
...@@ -1861,7 +1858,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, ...@@ -1861,7 +1858,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
*/ */
ext4_mark_inode_dirty(handle, dir); ext4_mark_inode_dirty(handle, dir);
dx_release(frames); dx_release(frames);
return retval; return PTR_ERR(de);
} }
dx_release(frames); dx_release(frames);
...@@ -2084,9 +2081,11 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, ...@@ -2084,9 +2081,11 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry,
goto cleanup; goto cleanup;
} }
} }
de = do_split(handle, dir, &bh, frame, &hinfo, &err); de = do_split(handle, dir, &bh, frame, &hinfo);
if (!de) if (IS_ERR(de)) {
err = PTR_ERR(de);
goto cleanup; goto cleanup;
}
err = add_dirent_to_buf(handle, dentry, inode, de, bh); err = add_dirent_to_buf(handle, dentry, inode, de, bh);
goto cleanup; goto cleanup;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment