Whamcloud - gitweb
b=3643
[fs/lustre-release.git] / lustre / llite / dcache.c
index 544d2cf..a338e40 100644 (file)
@@ -155,8 +155,8 @@ restart:
 
 extern struct dentry *ll_find_alias(struct inode *, struct dentry *);
 
-static int revalidate_it_finish(struct ptlrpc_request *request, int offset,
-                                struct lookup_intent *it,
+static int revalidate_it_finish(struct ptlrpc_request *request, 
+                                int offset, struct lookup_intent *it,
                                 struct dentry *de)
 {
         struct ll_sb_info *sbi;
@@ -170,7 +170,8 @@ static int revalidate_it_finish(struct ptlrpc_request *request, int offset,
                 RETURN(-ENOENT);
 
         sbi = ll_i2sbi(de->d_inode);
-        rc = ll_prep_inode(sbi->ll_osc_exp, &de->d_inode, request, offset,NULL);
+        rc = ll_prep_inode(sbi->ll_osc_exp, sbi->ll_mdc_exp,
+                           &de->d_inode, request, offset, NULL);
 
         RETURN(rc);
 }
@@ -184,7 +185,7 @@ void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry)
                 struct inode *inode = dentry->d_inode;
                 CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n",
                        inode, inode->i_ino, inode->i_generation);
-                mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode);
+                mdc_set_lock_data(NULL, &it->d.lustre.it_lock_handle, inode);
         }
 
         /* drop lookup or getattr locks immediately */
@@ -218,7 +219,8 @@ void ll_frob_intent(struct lookup_intent **itp, struct lookup_intent *deft)
         it->it_op_release = ll_intent_release;
 }
 
-int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
+int ll_revalidate_it(struct dentry *de, int flags, struct nameidata *nd,
+                     struct lookup_intent *it)
 {
         int rc;
         struct ll_fid pfid, cfid;
@@ -236,6 +238,11 @@ int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
         if (de->d_inode == NULL)
                 RETURN(0);
 
+        CDEBUG(D_INODE, "revalidate 0x%p: %*s -> %lu/%lu\n",
+                        de, de->d_name.len, de->d_name.name,
+                        (unsigned long) de->d_inode->i_ino,
+                        (unsigned long) de->d_inode->i_generation);
+
         exp = ll_i2mdcexp(de->d_inode);
         ll_inode2fid(&pfid, de->d_parent->d_inode);
         ll_inode2fid(&cfid, de->d_inode);
@@ -247,6 +254,9 @@ int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
         if (d_mountpoint(de))
                 RETURN(1);
 
+        if (nd != NULL)
+                nd->mnt->mnt_last_used = jiffies;
+
         ll_frob_intent(&it, &lookup_it);
         LASSERT(it);
 
@@ -254,9 +264,9 @@ int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
 
         if (it->it_op == IT_GETATTR) { /* We need to check for LOOKUP lock
                                           as well */
-                rc = mdc_intent_lock(exp, &ctxt, &pfid, de->d_name.name,
-                                     de->d_name.len, NULL, 0, &cfid, &lookup_it,
-                                     flags, &req, ll_mdc_blocking_ast);
+                rc = md_intent_lock(exp, &ctxt, &pfid, de->d_name.name,
+                                    de->d_name.len, NULL, 0, &cfid, &lookup_it,
+                                    flags, &req, ll_mdc_blocking_ast);
                 /* If there was no lookup lock, no point in even checking for
                    UPDATE lock */
                 if (!rc) {
@@ -275,9 +285,9 @@ int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
                 ll_lookup_finish_locks(&lookup_it, de);
         }
 
-        rc = mdc_intent_lock(exp, &ctxt, &pfid, de->d_name.name, de->d_name.len,
-                             NULL, 0,
-                             &cfid, it, flags, &req, ll_mdc_blocking_ast);
+        rc = md_intent_lock(exp, &ctxt, &pfid, de->d_name.name, de->d_name.len,
+                            NULL, 0, &cfid, it, flags, &req,
+                            ll_mdc_blocking_ast);
         /* If req is NULL, then mdc_intent_lock only tried to do a lock match;
          * if all was well, it will return 1 if it found locks, 0 otherwise. */
         if (req == NULL && rc >= 0)
@@ -305,22 +315,28 @@ int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
         __d_rehash(de, 0);
         spin_unlock(&dcache_lock);
 
+        GOTO(out, rc);
  out:
         if (req != NULL && rc == 1)
                 ptlrpc_req_finished(req);
         if (rc == 0) {
                 ll_unhash_aliases(de->d_inode);
-                /* done in ll_unhash_aliases()
-                dentry->d_flags |= DCACHE_LUSTRE_INVALID; */
-        } else {
-                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;
+                return rc;
         }
-        RETURN(rc);
+
+        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 (!((de->d_inode->i_mode & S_ISUID) &&S_ISDIR(de->d_inode->i_mode)) ||
+            !(flags & LOOKUP_CONTINUE || (it->it_op & (IT_CHDIR | IT_OPEN))))
+                return rc;
+
+        if (nd)
+                (void)ll_dir_process_mount_object(de, nd->mnt);
+        return rc;
 }
 
 /*static*/ void ll_pin(struct dentry *de, struct vfsmount *mnt, int flag)
@@ -414,14 +430,33 @@ static int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
         ENTRY;
 
         if (nd && nd->flags & LOOKUP_LAST && !(nd->flags & LOOKUP_LINK_NOTLAST))
-                rc = ll_revalidate_it(dentry, nd->flags, &nd->intent);
+                rc = ll_revalidate_it(dentry, nd->flags, nd, &nd->intent);
         else
-                rc = ll_revalidate_it(dentry, 0, NULL);
+                rc = ll_revalidate_it(dentry, 0, nd, NULL);
 
         RETURN(rc);
 }
 #endif
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
+static void ll_dentry_iput(struct dentry *dentry, struct inode *inode)
+{
+        struct ll_sb_info *sbi = ll_i2sbi(inode);
+        struct ll_fid parent, child;
+
+        LASSERT(dentry->d_parent && dentry->d_parent->d_inode);
+        ll_inode2fid(&parent, dentry->d_parent->d_inode);
+        ll_inode2fid(&child, inode);
+        md_change_cbdata_name(sbi->ll_mdc_exp, &parent,
+                              (char *)dentry->d_name.name, 
+                              dentry->d_name.len, &child, 
+                              null_if_equal, inode);
+        iput(inode);
+}
+#else
+#error "implement ->d_iput() for 2.6"
+#endif
+
 struct dentry_operations ll_d_ops = {
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
         .d_revalidate = ll_revalidate_nd,
@@ -429,6 +464,7 @@ struct dentry_operations ll_d_ops = {
         .d_revalidate_it = ll_revalidate_it,
 #endif
         .d_release = ll_release,
+        .d_iput = ll_dentry_iput,
         .d_delete = ll_ddelete,
 #if 0
         .d_pin = ll_pin,