lkml.org 
[lkml]   [2018]   [Jul]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 14/16] btrfs: simplify btrfs_iget()
    Date
    From: Al Viro <viro@zeniv.linux.org.uk>

    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>
    ---
    fs/btrfs/inode.c | 24 ++++++++----------------
    1 file changed, 8 insertions(+), 16 deletions(-)

    diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
    index 8f0b2592feb0..388b2dba68a0 100644
    --- a/fs/btrfs/inode.c
    +++ b/fs/btrfs/inode.c
    @@ -3610,18 +3610,15 @@ static int btrfs_read_locked_inode(struct inode *inode)
    filled = true;

    path = btrfs_alloc_path();
    - if (!path) {
    - ret = -ENOMEM;
    - goto make_bad;
    - }
    + if (!path)
    + return -ENOMEM;

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

    ret = btrfs_lookup_inode(NULL, root, path, &location, 0);
    if (ret) {
    - if (ret > 0)
    - ret = -ENOENT;
    - goto make_bad;
    + btrfs_free_path(path);
    + return ret;
    }

    leaf = path->nodes[0];
    @@ -3774,10 +3771,6 @@ static int btrfs_read_locked_inode(struct inode *inode)

    btrfs_sync_inode_flags_to_i_flags(inode);
    return 0;
    -
    -make_bad:
    - btrfs_free_path(path);
    - return ret;
    }

    /*
    @@ -5713,11 +5706,10 @@ struct inode *btrfs_iget(struct super_block *s, struct btrfs_key *location,
    if (new)
    *new = 1;
    } else {
    - make_bad_inode(inode);
    - unlock_new_inode(inode);
    - iput(inode);
    - ASSERT(ret < 0);
    - inode = ERR_PTR(ret < 0 ? ret : -ESTALE);
    + iget_failed(inode);
    + if (ret > 0)
    + ret = -ENOENT;
    + inode = ERR_PTR(ret);
    }
    }

    --
    2.11.0
    \
     
     \ /
      Last update: 2018-07-30 00:06    [W:4.716 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site