Whamcloud - gitweb
Land first part of new dcache handling (bug 16654).
[fs/lustre-release.git] / lustre / llite / dcache.c
index 40be3e6..2ef00a9 100644 (file)
@@ -77,7 +77,6 @@ static void ll_release(struct dentry *de)
         EXIT;
 }
 
-#ifdef DCACHE_LUSTRE_INVALID
 /* Compare if two dentries are the same.  Don't match if the existing dentry
  * is marked DCACHE_LUSTRE_INVALID.  Returns 1 if different, 0 if the same.
  *
@@ -98,15 +97,22 @@ int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name)
 
         /* XXX: d_name must be in-dentry structure */
         dchild = container_of(d_name, struct dentry, d_name); /* ugh */
-        if (dchild->d_flags & DCACHE_LUSTRE_INVALID) {
-                CDEBUG(D_DENTRY,"INVALID dentry %p not matched, was bug 3784\n",
-                       dchild);
+
+        CDEBUG(D_DENTRY,"found name %.*s(%p) - flags %d/%x - refc %d\n",
+               name->len, name->name, dchild,
+               d_mountpoint(dchild), dchild->d_flags & DCACHE_LUSTRE_INVALID,
+               atomic_read(&dchild->d_count));
+
+         /* mountpoint is always valid */
+        if (d_mountpoint(dchild))
+                RETURN(0);
+
+        if (dchild->d_flags & DCACHE_LUSTRE_INVALID)
                 RETURN(1);
-        }
+
 
         RETURN(0);
 }
-#endif
 
 /* should NOT be called with the dcache lock, see fs/dcache.c */
 static int ll_ddelete(struct dentry *de)
@@ -277,17 +283,6 @@ restart:
                                "ino=%lu\n", dentry, inode, inode->i_ino);
                         lustre_dump_dentry(dentry, 1);
                         libcfs_debug_dumpstack(NULL);
-                } else if (d_mountpoint(dentry)) {
-                        /* For mountpoints we skip removal of the dentry
-                           which happens solely because we have a lock on it
-                           obtained when this dentry was not a mountpoint yet */
-                        CDEBUG(D_DENTRY, "Skippind mountpoint dentry removal "
-                                         "%.*s (%p) parent %p\n",
-                                          dentry->d_name.len,
-                                          dentry->d_name.name,
-                                          dentry, dentry->d_parent);
-
-                        continue;
                 }
 
                 if (ll_drop_dentry(dentry))
@@ -329,7 +324,7 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry)
                 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);
+                                 inode, NULL);
         }
 
         /* drop lookup or getattr locks immediately */
@@ -393,17 +388,20 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags,
                 GOTO(out_sa, rc);
         }
 
-        exp = ll_i2mdexp(de->d_inode);
-
         /* Never execute intents for mount points.
          * Attributes will be fixed up in ll_inode_revalidate_it */
         if (d_mountpoint(de))
                 GOTO(out_sa, rc = 1);
 
-        /* Root of the lustre tree. Always valid.
-         * Attributes will be fixed up in ll_inode_revalidate_it */
-        if (de == de->d_sb->s_root)
-                GOTO(out_sa, rc = 1);
+        /* need to get attributes in case root got changed from other client */
+        if (de == de->d_sb->s_root) {
+                rc = __ll_inode_revalidate_it(de, it, MDS_INODELOCK_LOOKUP);
+                if (rc == 0)
+                        rc = 1;
+                GOTO(out_sa, rc);
+        }
+
+        exp = ll_i2mdexp(de->d_inode);
 
         OBD_FAIL_TIMEOUT(OBD_FAIL_MDC_REVALIDATE_PAUSE, 5);
         ll_frob_intent(&it, &lookup_it);
@@ -470,11 +468,11 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags,
 
 do_lock:
         it->it_create_mode &= ~current->fs->umask;
-        it->it_flags |= O_CHECK_STALE;
+        it->it_create_mode |= M_CHECK_STALE;
         rc = md_intent_lock(exp, op_data, NULL, 0, it,
                             lookup_flags,
                             &req, ll_md_blocking_ast, 0);
-        it->it_flags &= ~O_CHECK_STALE;
+        it->it_create_mode &= ~M_CHECK_STALE;
         ll_finish_md_op_data(op_data);
         if (it->it_op == IT_GETATTR && !first)
                 /* If there are too many locks on client-side, then some
@@ -493,15 +491,7 @@ do_lock:
         }
 
         if (rc < 0) {
-                if (-ESTALE == rc) {
-                        if (it_disposition(it, DISP_OPEN_OPEN) &&
-                            !it_open_error(DISP_OPEN_OPEN, it))
-                                /* server have valid open - close file first*/
-                                ll_release_openhandle(de, it);
-                        /* release intent reference to avoid having stale 'it'
-                         * in namedata for old VFS intent */
-                        ll_intent_drop_lock(it);
-                } else {
+                if (rc != -ESTALE) {
                         CDEBUG(D_INFO, "ll_intent_lock: rc %d : it->it_status "
                                "%d\n", rc, it->d.lustre.it_status);
                 }
@@ -719,7 +709,7 @@ out_sa:
 }
 
 #ifdef HAVE_VFS_INTENT_PATCHES
-static int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
+int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
 {
         int rc;
         ENTRY;
@@ -762,16 +752,20 @@ int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
                                                (struct ptlrpc_request *)
                                                   it->d.lustre.it_data);
                         } else {
-                                struct file *filp;
-
-                                nd->intent.open.file->private_data = it;
-                                filp = lookup_instantiate_filp(nd, dentry,NULL);
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17))
 /* 2.6.1[456] have a bug in open_namei() that forgets to check
  * nd->intent.open.file for error, so we need to return it as lookup's result
  * instead */
-                                if (IS_ERR(filp))
-                                        rc = 0;
+                                struct file *filp;
+
+                                nd->intent.open.file->private_data = it;
+                                filp = lookup_instantiate_filp(nd, dentry,NULL);
+                                if (IS_ERR(filp)) {
+                                        rc = PTR_ERR(filp);
+                                }
+#else
+                                nd->intent.open.file->private_data = it;
+                                (void)lookup_instantiate_filp(nd, dentry,NULL);
 #endif
                         }
 #else
@@ -806,9 +800,7 @@ struct dentry_operations ll_d_ops = {
         .d_revalidate = ll_revalidate_nd,
         .d_release = ll_release,
         .d_delete = ll_ddelete,
-#ifdef DCACHE_LUSTRE_INVALID
         .d_compare = ll_dcompare,
-#endif
 #if 0
         .d_pin = ll_pin,
         .d_unpin = ll_unpin,