Commit f5b3a417 authored by Al Viro's avatar Al Viro Committed by David Sterba

btrfs: simplify btrfs_iget

Don't open-code iget_failed(), don't bother with btrfs_free_path(NULL),
move handling of positive return values of btrfs_lookup_inode() from
btrfs_read_locked_inode() to btrfs_iget() and kill now obviously
pointless ASSERT() in there.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 9bc2ceff
...@@ -3604,18 +3604,15 @@ static int btrfs_read_locked_inode(struct inode *inode) ...@@ -3604,18 +3604,15 @@ static int btrfs_read_locked_inode(struct inode *inode)
filled = true; filled = true;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
if (!path) { if (!path)
ret = -ENOMEM; return -ENOMEM;
goto make_bad;
}
memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
ret = btrfs_lookup_inode(NULL, root, path, &location, 0); ret = btrfs_lookup_inode(NULL, root, path, &location, 0);
if (ret) { if (ret) {
if (ret > 0) btrfs_free_path(path);
ret = -ENOENT; return ret;
goto make_bad;
} }
leaf = path->nodes[0]; leaf = path->nodes[0];
...@@ -3768,10 +3765,6 @@ static int btrfs_read_locked_inode(struct inode *inode) ...@@ -3768,10 +3765,6 @@ static int btrfs_read_locked_inode(struct inode *inode)
btrfs_sync_inode_flags_to_i_flags(inode); btrfs_sync_inode_flags_to_i_flags(inode);
return 0; return 0;
make_bad:
btrfs_free_path(path);
return ret;
} }
/* /*
...@@ -5702,11 +5695,15 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, ...@@ -5702,11 +5695,15 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
if (new) if (new)
*new = 1; *new = 1;
} else { } else {
make_bad_inode(inode); iget_failed(inode);
unlock_new_inode(inode); /*
iput(inode); * ret > 0 can come from btrfs_search_slot called by
ASSERT(ret < 0); * btrfs_read_locked_inode, this means the inode item
inode = ERR_PTR(ret < 0 ? ret : -ESTALE); * was not found.
*/
if (ret > 0)
ret = -ENOENT;
inode = ERR_PTR(ret);
} }
} }
......
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