Whamcloud - gitweb
Land first part of new dcache handling (bug 16654).
[fs/lustre-release.git] / lustre / llite / namei.c
index ad0a8d6..a0befa4 100644 (file)
@@ -376,9 +376,6 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
                 dget_locked(dentry);
                 lock_dentry(dentry);
                 __d_drop(dentry);
-#ifdef DCACHE_LUSTRE_INVALID
-                dentry->d_flags &= ~DCACHE_LUSTRE_INVALID;
-#endif
                 unlock_dentry(dentry);
                 ll_dops_init(dentry, 0);
                 d_rehash_cond(dentry, 0); /* avoid taking dcache_lock inside */
@@ -396,6 +393,9 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
                         "refc %d\n", last_discon, last_discon->d_inode,
                         atomic_read(&last_discon->d_count));
                 dget_locked(last_discon);
+                lock_dentry(last_discon);
+                last_discon->d_flags |= DCACHE_LUSTRE_INVALID;
+                unlock_dentry(last_discon);
                 spin_unlock(&dcache_lock);
                 spin_unlock(&ll_lookup_lock);
                 ll_dops_init(last_discon, 1);
@@ -404,7 +404,7 @@ static struct dentry *ll_find_alias(struct inode *inode, struct dentry *de)
                 iput(inode);
                 return last_discon;
         }
-
+        de->d_flags |= DCACHE_LUSTRE_INVALID;
         ll_d_add(de, inode);
 
         spin_unlock(&dcache_lock);
@@ -428,6 +428,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request,
          * when I return */
         if (!it_disposition(it, DISP_LOOKUP_NEG)) {
                 struct dentry *save = *de;
+                __u32 bits;
 
                 rc = ll_prep_inode(&inode, request, (*de)->d_sb);
                 if (rc)
@@ -436,7 +437,7 @@ int ll_lookup_it_finish(struct ptlrpc_request *request,
                 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
                        inode, inode->i_ino, inode->i_generation);
                 md_set_lock_data(sbi->ll_md_exp,
-                                 &it->d.lustre.it_lock_handle, inode);
+                                 &it->d.lustre.it_lock_handle, inode, &bits);
 
                 /* We used to query real size from OSTs here, but actually
                    this is not needed. For stat() calls size would be updated
@@ -460,6 +461,12 @@ int ll_lookup_it_finish(struct ptlrpc_request *request,
                                         lld->lld_sa_generation = 0;
                         }
                 }
+                /* we have lookup look - unhide dentry */
+                if (bits & MDS_INODELOCK_LOOKUP) {
+                        lock_dentry(*de);
+                        (*de)->d_flags &= ~(DCACHE_LUSTRE_INVALID);
+                        unlock_dentry(*de);
+                }
         } else {
                 ll_dops_init(*de, 1);
                 /* Check that parent has UPDATE lock. If there is none, we
@@ -470,6 +477,12 @@ int ll_lookup_it_finish(struct ptlrpc_request *request,
                         ll_d_add(*de, NULL);
                         spin_unlock(&dcache_lock);
                 } else {
+                        /* negative lookup - and don't have update lock to
+                         * parent */
+                        lock_dentry(*de);
+                        (*de)->d_flags |= DCACHE_LUSTRE_INVALID;
+                        unlock_dentry(*de);
+
                         (*de)->d_inode = NULL;
                         /* We do not want to hash the dentry if don`t have a
                          * lock, but if this dentry is later used in d_move,
@@ -737,7 +750,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name,
         CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n",
                inode, inode->i_ino, inode->i_generation);
         md_set_lock_data(sbi->ll_md_exp,
-                         &it->d.lustre.it_lock_handle, inode);
+                         &it->d.lustre.it_lock_handle, inode, NULL);
         EXIT;
  out:
         ptlrpc_req_finished(request);