Commit 6218b90e7669d83cb8ad744f3400205d260597f2

Authored by Tao Ma
1 parent 468eedde23

ocfs2: Little refactoring against ocfs2_iget.

ocfs2_iget is used to get/create inode. Only iget5_locked
will give us an inode = NULL. So move this check ahead of
ocfs2_read_locked_inode so that we don't need to check
inode before we read and unlock inode. This is also helpful
for trace event(see the next patch).

Signed-off-by: Tao Ma <boyu.mt@taobao.com>

Showing 1 changed file with 5 additions and 5 deletions Side-by-side Diff

... ... @@ -152,15 +152,15 @@
152 152 /* inode was *not* in the inode cache. 2.6.x requires
153 153 * us to do our own read_inode call and unlock it
154 154 * afterwards. */
155   - if (inode && inode->i_state & I_NEW) {
156   - mlog(0, "Inode was not in inode cache, reading it.\n");
157   - ocfs2_read_locked_inode(inode, &args);
158   - unlock_new_inode(inode);
159   - }
160 155 if (inode == NULL) {
161 156 inode = ERR_PTR(-ENOMEM);
162 157 mlog_errno(PTR_ERR(inode));
163 158 goto bail;
  159 + }
  160 + if (inode->i_state & I_NEW) {
  161 + mlog(0, "Inode was not in inode cache, reading it.\n");
  162 + ocfs2_read_locked_inode(inode, &args);
  163 + unlock_new_inode(inode);
164 164 }
165 165 if (is_bad_inode(inode)) {
166 166 iput(inode);