Skip to content

Commit f5b3a41

Browse files
Al Virokdave
authored andcommitted
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 <[email protected]> Reviewed-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 9bc2cef commit f5b3a41

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

fs/btrfs/inode.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3604,18 +3604,15 @@ static int btrfs_read_locked_inode(struct inode *inode)
36043604
filled = true;
36053605

36063606
path = btrfs_alloc_path();
3607-
if (!path) {
3608-
ret = -ENOMEM;
3609-
goto make_bad;
3610-
}
3607+
if (!path)
3608+
return -ENOMEM;
36113609

36123610
memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
36133611

36143612
ret = btrfs_lookup_inode(NULL, root, path, &location, 0);
36153613
if (ret) {
3616-
if (ret > 0)
3617-
ret = -ENOENT;
3618-
goto make_bad;
3614+
btrfs_free_path(path);
3615+
return ret;
36193616
}
36203617

36213618
leaf = path->nodes[0];
@@ -3768,10 +3765,6 @@ static int btrfs_read_locked_inode(struct inode *inode)
37683765

37693766
btrfs_sync_inode_flags_to_i_flags(inode);
37703767
return 0;
3771-
3772-
make_bad:
3773-
btrfs_free_path(path);
3774-
return ret;
37753768
}
37763769

37773770
/*
@@ -5702,11 +5695,15 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
57025695
if (new)
57035696
*new = 1;
57045697
} else {
5705-
make_bad_inode(inode);
5706-
unlock_new_inode(inode);
5707-
iput(inode);
5708-
ASSERT(ret < 0);
5709-
inode = ERR_PTR(ret < 0 ? ret : -ESTALE);
5698+
iget_failed(inode);
5699+
/*
5700+
* ret > 0 can come from btrfs_search_slot called by
5701+
* btrfs_read_locked_inode, this means the inode item
5702+
* was not found.
5703+
*/
5704+
if (ret > 0)
5705+
ret = -ENOENT;
5706+
inode = ERR_PTR(ret);
57105707
}
57115708
}
57125709

0 commit comments

Comments
 (0)