Whamcloud - gitweb
- using TASK_INTERRUPTIBLE in OBD_SLEEP_ON at Andreas' suggestion.
[fs/lustre-release.git] / lustre / llite / dcache.c
index 096d91e..c8570be 100644 (file)
@@ -139,15 +139,6 @@ void ll_intent_release(struct lookup_intent *it)
         EXIT;
 }
 
-void ll_intent_free(struct lookup_intent *it)
-{
-        if (it->d.fs_data) {
-                OBD_SLAB_FREE(it->d.fs_data, ll_intent_slab,
-                               sizeof(struct lustre_intent_data));
-                it->d.fs_data = NULL;
-        }
-}
-
 void ll_unhash_aliases(struct inode *inode)
 {
         struct list_head *tmp, *head;
@@ -277,7 +268,7 @@ int ll_intent_alloc(struct lookup_intent *it)
                 return 0;
         }
         OBD_SLAB_ALLOC(it->d.fs_data, ll_intent_slab, SLAB_KERNEL,
-                        sizeof(struct lustre_intent_data));
+                       sizeof(struct lustre_intent_data));
         if (!it->d.fs_data) {
                 CERROR("Failed to allocate memory for lustre specific intent "
                        "data\n");
@@ -285,10 +276,18 @@ int ll_intent_alloc(struct lookup_intent *it)
         }
 
         it->it_op_release = ll_intent_release;
-
         return 0;
 }
 
+void ll_intent_free(struct lookup_intent *it)
+{
+        if (it->d.fs_data) {
+                OBD_SLAB_FREE(it->d.fs_data, ll_intent_slab,
+                              sizeof(struct lustre_intent_data));
+                it->d.fs_data = NULL;
+        }
+}
+
 static inline int 
 ll_special_name(struct dentry *de)
 {
@@ -313,7 +312,7 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd,
         struct it_cb_data icbd;
         struct lustre_id pid;
         struct lustre_id cid;
-        int orig_it, rc = 0;
+        int gns_it, rc = 0;
         ENTRY;
 
         CDEBUG(D_VFSTRACE, "VFS Op:name=%s (%p), intent=%s\n", de->d_name.name,
@@ -352,8 +351,10 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd,
                 nd->mnt->mnt_last_used = jiffies;
 
         OBD_FAIL_TIMEOUT(OBD_FAIL_MDC_REVALIDATE_PAUSE, 5);
-        orig_it = it ? it->it_op : IT_OPEN;
+
+        gns_it = it ? it->it_op : IT_OPEN;
         ll_frob_intent(&it, &lookup_it);
+
         LASSERT(it != NULL);
 
         if (it->it_op == IT_GETATTR) { /* We need to check for LOOKUP lock as
@@ -389,7 +390,7 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd,
                 ll_intent_release(&lookup_it);
         }
 
-#if 1
+        /* open lock stuff */
         if ((it->it_op == IT_OPEN) && de->d_inode) {
                 struct inode *inode = de->d_inode;
                 struct ll_inode_info *lli = ll_i2info(inode);
@@ -445,7 +446,6 @@ int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd,
                         ldlm_lock_decref(&lockh, lockmode);
                 }
         }
-#endif
 
 do_lock:
         rc = md_intent_lock(exp, &pid, de->d_name.name, de->d_name.len,
@@ -499,16 +499,6 @@ out:
                 return 0;
         }
 
-        CDEBUG(D_DENTRY, "revalidated dentry %*s (%p) parent %p "
-               "inode %p refc %d\n", de->d_name.len,
-               de->d_name.name, de, de->d_parent, de->d_inode,
-               atomic_read(&de->d_count));
-
-        ll_lookup_finish_locks(it, de);
-        de->d_flags &= ~DCACHE_LUSTRE_INVALID;
-        if (it == &lookup_it)
-                ll_intent_release(it);
-
         /* 
          * if we found that this is possible GNS mount and dentry is still valid
          * and may be used by system, we drop the lock and return 0, that means
@@ -516,16 +506,29 @@ out:
          * lookup control path, which is always made with parent's i_sem taken.
          * --umka
          */
-        if (!((de->d_inode->i_mode & S_ISUID) && S_ISDIR(de->d_inode->i_mode)) ||
-            !(flags & LOOKUP_CONTINUE || (orig_it & (IT_CHDIR | IT_OPEN))))
-               return rc;
-           
-       /* special "." and ".." has to be always revalidated */
-        if (rc && !ll_special_name(de) && nd != NULL && !(nd->flags & LOOKUP_LAST)) {
-                ll_intent_drop_lock(it);
-                return 0;
+        if (rc &&
+            !(!((de->d_inode->i_mode & S_ISUID) && S_ISDIR(de->d_inode->i_mode)) ||
+              !(flags & LOOKUP_CONTINUE || (gns_it & (IT_CHDIR | IT_OPEN))))) {
+                /* 
+                 * special "." and ".." has to be always revalidated because
+                 * they never should be passed to lookup()
+                 */
+                if (!ll_special_name(de)) {
+                        ll_intent_drop_lock(it);
+                        ll_intent_free(it);
+                        ll_unhash_aliases(de->d_inode);
+                        return 0;
+                }
         }
 
+        CDEBUG(D_DENTRY, "revalidated dentry %*s (%p) parent %p "
+               "inode %p refc %d\n", de->d_name.len,
+               de->d_name.name, de, de->d_parent, de->d_inode,
+               atomic_read(&de->d_count));
+
+        ll_lookup_finish_locks(it, de);
+        de->d_flags &= ~DCACHE_LUSTRE_INVALID;
+        ll_intent_release(it);
         return rc;
 do_lookup:
         it = &lookup_it;
@@ -537,7 +540,8 @@ do_lookup:
                             de->d_name.len, NULL, 0, NULL,
                             it, 0, &req, ll_mdc_blocking_ast);
         if (rc >= 0) {
-                struct mds_body *mds_body = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*mds_body));
+                struct mds_body *mds_body = lustre_msg_buf(req->rq_repmsg, 1,
+                                                           sizeof(*mds_body));
 
                 /* See if we got same inode, if not - return error */
                 if (id_equal_stc(&cid, &mds_body->id1))