aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.com>2011-07-12 14:25:31 -0400
committerMark Fasheh <mfasheh@suse.com>2011-07-14 17:14:45 -0400
commit1748f843a0190ef4332d03a64263f383af72682b (patch)
treecf577aabbd13a639e2fdf4e6edb017f2276aa9c4
parent0eb0e19cde6f01397ef8c0e094e44beb75c62a1e (diff)
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: Mark Fasheh <mfasheh@suse.com>
-rw-r--r--fs/btrfs/inode.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a0faf7d7f0e0..88829993db6c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2518,7 +2518,9 @@ static void btrfs_read_locked_inode(struct inode *inode)
2518 filled = true; 2518 filled = true;
2519 2519
2520 path = btrfs_alloc_path(); 2520 path = btrfs_alloc_path();
2521 BUG_ON(!path); 2521 if (!path)
2522 goto make_bad;
2523
2522 path->leave_spinning = 1; 2524 path->leave_spinning = 1;
2523 memcpy(&location, &BTRFS_I(inode)->location, sizeof(location)); 2525 memcpy(&location, &BTRFS_I(inode)->location, sizeof(location));
2524 2526
@@ -3973,6 +3975,7 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
3973 struct btrfs_root *root, int *new) 3975 struct btrfs_root *root, int *new)
3974{ 3976{
3975 struct inode *inode; 3977 struct inode *inode;
3978 int bad_inode = 0;
3976 3979
3977 inode = btrfs_iget_locked(s, location->objectid, root); 3980 inode = btrfs_iget_locked(s, location->objectid, root);
3978 if (!inode) 3981 if (!inode)
@@ -3982,10 +3985,19 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
3982 BTRFS_I(inode)->root = root; 3985 BTRFS_I(inode)->root = root;
3983 memcpy(&BTRFS_I(inode)->location, location, sizeof(*location)); 3986 memcpy(&BTRFS_I(inode)->location, location, sizeof(*location));
3984 btrfs_read_locked_inode(inode); 3987 btrfs_read_locked_inode(inode);
3985 inode_tree_add(inode); 3988 if (!is_bad_inode(inode)) {
3986 unlock_new_inode(inode); 3989 inode_tree_add(inode);
3987 if (new) 3990 unlock_new_inode(inode);
3988 *new = 1; 3991 if (new)
3992 *new = 1;
3993 } else {
3994 bad_inode = 1;
3995 }
3996 }
3997
3998 if (bad_inode) {
3999 iput(inode);
4000 inode = ERR_PTR(-ESTALE);
3989 } 4001 }
3990 4002
3991 return inode; 4003 return inode;