Whamcloud - gitweb
LU-2675 obd: decruft md_enqueue() and md_intent_lock()
[fs/lustre-release.git] / lustre / llite / namei.c
index d041fea..69da17e 100644 (file)
@@ -121,44 +121,51 @@ static int ll_set_inode(struct inode *inode, void *opaque)
 }
 
 
-/*
- * Get an inode by inode number (already instantiated by the intent lookup).
- * Returns inode or NULL
+/**
+ * Get an inode by inode number(@hash), which is already instantiated by
+ * the intent lookup).
  */
 struct inode *ll_iget(struct super_block *sb, ino_t hash,
                       struct lustre_md *md)
 {
-        struct inode         *inode;
-        ENTRY;
+       struct inode    *inode;
+       int             rc = 0;
+
+       ENTRY;
 
         LASSERT(hash != 0);
         inode = iget5_locked(sb, hash, ll_test_inode, ll_set_inode, md);
+       if (inode == NULL)
+               RETURN(ERR_PTR(-ENOMEM));
+
+       if (inode->i_state & I_NEW) {
+               rc = ll_read_inode2(inode, md);
+               if (rc == 0 && S_ISREG(inode->i_mode) &&
+                   ll_i2info(inode)->lli_clob == NULL) {
+                       CDEBUG(D_INODE, "%s: apply lsm %p to inode "DFID"\n",
+                               ll_get_fsname(sb, NULL, 0), md->lsm,
+                               PFID(ll_inode2fid(inode)));
+                       rc = cl_file_inode_init(inode, md);
+               }
+               if (rc != 0) {
+                       make_bad_inode(inode);
+                       unlock_new_inode(inode);
+                       iput(inode);
+                       inode = ERR_PTR(rc);
+               } else {
+                       unlock_new_inode(inode);
+               }
+       } else if (!(inode->i_state & (I_FREEING | I_CLEAR))) {
+               rc = ll_update_inode(inode, md);
+               CDEBUG(D_VFSTRACE, "got inode: "DFID"(%p): rc = %d\n",
+                      PFID(&md->body->fid1), inode, rc);
+               if (rc != 0) {
+                       make_bad_inode(inode);
+                       iput(inode);
+                       inode = ERR_PTR(rc);
+               }
+       }
 
-        if (inode) {
-                if (inode->i_state & I_NEW) {
-                        int rc = 0;
-
-                        ll_read_inode2(inode, md);
-                        if (S_ISREG(inode->i_mode) &&
-                            ll_i2info(inode)->lli_clob == NULL) {
-                               CDEBUG(D_INODE,
-                                       "%s: apply lsm %p to inode "DFID".\n",
-                                       ll_get_fsname(sb, NULL, 0), md->lsm,
-                                       PFID(ll_inode2fid(inode)));
-                                rc = cl_file_inode_init(inode, md);
-                       }
-                        if (rc != 0) {
-                                make_bad_inode(inode);
-                                unlock_new_inode(inode);
-                                iput(inode);
-                                inode = ERR_PTR(rc);
-                        } else
-                                unlock_new_inode(inode);
-                } else if (!(inode->i_state & (I_FREEING | I_CLEAR)))
-                        ll_update_inode(inode, md);
-                       CDEBUG(D_VFSTRACE, "got inode: "DFID"(%p)\n",
-                              PFID(&md->body->fid1), inode);
-        }
         RETURN(inode);
 }
 
@@ -564,8 +571,8 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
         if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent)))
                it->it_create_mode &= ~current_umask();
 
-        rc = md_intent_lock(ll_i2mdexp(parent), op_data, NULL, 0, it,
-                            lookup_flags, &req, ll_md_blocking_ast, 0);
+       rc = md_intent_lock(ll_i2mdexp(parent), op_data, it, &req,
+                           &ll_md_blocking_ast, 0);
         ll_finish_md_op_data(op_data);
         if (rc < 0)
                 GOTO(out, retval = ERR_PTR(rc));