Commit 1748f843 authored by Mark Fasheh's avatar Mark Fasheh

btrfs: Don't BUG_ON alloc_path errors in btrfs_read_locked_inode

btrfs_iget() also needed an update so that errors from btrfs_locked_inode()
are caught and bubbled back up.
Signed-off-by: default avatarMark Fasheh <mfasheh@suse.com>
parent 0eb0e19c
...@@ -2518,7 +2518,9 @@ static void btrfs_read_locked_inode(struct inode *inode) ...@@ -2518,7 +2518,9 @@ static void btrfs_read_locked_inode(struct inode *inode)
filled = true; filled = true;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
BUG_ON(!path); if (!path)
goto make_bad;
path->leave_spinning = 1; path->leave_spinning = 1;
memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
...@@ -3973,6 +3975,7 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, ...@@ -3973,6 +3975,7 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
struct btrfs_root *root, int *new) struct btrfs_root *root, int *new)
{ {
struct inode *inode; struct inode *inode;
int bad_inode = 0;
inode = btrfs_iget_locked(s, location->objectid, root); inode = btrfs_iget_locked(s, location->objectid, root);
if (!inode) if (!inode)
...@@ -3982,10 +3985,19 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location, ...@@ -3982,10 +3985,19 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
BTRFS_I(inode)->root = root; BTRFS_I(inode)->root = root;
memcpy(&BTRFS_I(inode)->location, location, sizeof(*location)); memcpy(&BTRFS_I(inode)->location, location, sizeof(*location));
btrfs_read_locked_inode(inode); btrfs_read_locked_inode(inode);
inode_tree_add(inode); if (!is_bad_inode(inode)) {
unlock_new_inode(inode); inode_tree_add(inode);
if (new) unlock_new_inode(inode);
*new = 1; if (new)
*new = 1;
} else {
bad_inode = 1;
}
}
if (bad_inode) {
iput(inode);
inode = ERR_PTR(-ESTALE);
} }
return inode; return inode;
......
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