diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-07-29 18:04:51 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-08-06 07:13:02 -0400 |
commit | f5b3a4173ff624b766c56936bb315e1517603891 (patch) | |
tree | f4bc7f312cc523b9a362c8384e00e31807c2f2e8 | |
parent | 9bc2ceff660580454f971ed3f891a2c82085433a (diff) |
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: Al Viro <viro@zeniv.linux.org.uk>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/inode.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index cd99ce8583a8..3f51ddc18f98 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -3604,18 +3604,15 @@ static int btrfs_read_locked_inode(struct inode *inode) | |||
3604 | filled = true; | 3604 | filled = true; |
3605 | 3605 | ||
3606 | path = btrfs_alloc_path(); | 3606 | path = btrfs_alloc_path(); |
3607 | if (!path) { | 3607 | if (!path) |
3608 | ret = -ENOMEM; | 3608 | return -ENOMEM; |
3609 | goto make_bad; | ||
3610 | } | ||
3611 | 3609 | ||
3612 | memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); | 3610 | memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); |
3613 | 3611 | ||
3614 | ret = btrfs_lookup_inode(NULL, root, path, &location, 0); | 3612 | ret = btrfs_lookup_inode(NULL, root, path, &location, 0); |
3615 | if (ret) { | 3613 | if (ret) { |
3616 | if (ret > 0) | 3614 | btrfs_free_path(path); |
3617 | ret = -ENOENT; | 3615 | return ret; |
3618 | goto make_bad; | ||
3619 | } | 3616 | } |
3620 | 3617 | ||
3621 | leaf = path->nodes[0]; | 3618 | leaf = path->nodes[0]; |
@@ -3768,10 +3765,6 @@ cache_acl: | |||
3768 | 3765 | ||
3769 | btrfs_sync_inode_flags_to_i_flags(inode); | 3766 | btrfs_sync_inode_flags_to_i_flags(inode); |
3770 | return 0; | 3767 | return 0; |
3771 | |||
3772 | make_bad: | ||
3773 | btrfs_free_path(path); | ||
3774 | return ret; | ||
3775 | } | 3768 | } |
3776 | 3769 | ||
3777 | /* | 3770 | /* |
@@ -5702,11 +5695,15 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, | |||
5702 | if (new) | 5695 | if (new) |
5703 | *new = 1; | 5696 | *new = 1; |
5704 | } else { | 5697 | } else { |
5705 | make_bad_inode(inode); | 5698 | iget_failed(inode); |
5706 | unlock_new_inode(inode); | 5699 | /* |
5707 | iput(inode); | 5700 | * ret > 0 can come from btrfs_search_slot called by |
5708 | ASSERT(ret < 0); | 5701 | * btrfs_read_locked_inode, this means the inode item |
5709 | inode = ERR_PTR(ret < 0 ? ret : -ESTALE); | 5702 | * was not found. |
5703 | */ | ||
5704 | if (ret > 0) | ||
5705 | ret = -ENOENT; | ||
5706 | inode = ERR_PTR(ret); | ||
5710 | } | 5707 | } |
5711 | } | 5708 | } |
5712 | 5709 | ||