Whamcloud - gitweb
smash the HEAD with the contents of b_cmd. HEAD_PRE_CMD_SMASH and
[fs/lustre-release.git] / lustre / llite / dcache.c
index 544d2cf..b604792 100644 (file)
@@ -49,27 +49,11 @@ static void ll_release(struct dentry *de)
         EXIT;
 }
 
-/* should NOT be called with the dcache lock, see fs/dcache.c */
-static int ll_ddelete(struct dentry *de)
-{
-        ENTRY;
-        LASSERT(de);
-        CDEBUG(D_DENTRY, "%s dentry %*s (%p, parent %p, inode %p) %s%s\n",
-               (de->d_flags & DCACHE_LUSTRE_INVALID ? "keeping" : "deleting"),
-               de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
-               d_unhashed(de) ? "" : "hashed,",
-               list_empty(&de->d_subdirs) ? "" : "subdirs");
-        RETURN(0);
-}
-
 void ll_set_dd(struct dentry *de)
 {
         ENTRY;
         LASSERT(de != NULL);
 
-        CDEBUG(D_DENTRY, "ldd on 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));
         lock_kernel();
         if (de->d_fsdata == NULL) {
                 OBD_ALLOC(de->d_fsdata, sizeof(struct ll_dentry_data));
@@ -109,47 +93,43 @@ void ll_intent_release(struct lookup_intent *it)
 
 void ll_unhash_aliases(struct inode *inode)
 {
-        struct list_head *tmp, *head;
+       struct list_head *tmp, *head;
         struct ll_sb_info *sbi;
         ENTRY;
 
-        if (inode == NULL) {
-                CERROR("unexpected NULL inode, tell phil\n");
-                return;
-        }
+        sbi = ll_i2sbi(inode);
 
         CDEBUG(D_INODE, "marking dentries for ino %lu/%u(%p) invalid\n",
                inode->i_ino, inode->i_generation, inode);
 
-        sbi = ll_i2sbi(inode);
+        if (inode == NULL) {
+                CERROR("unexpected NULL inode, tell phil\n");
+                return;
+        }
         head = &inode->i_dentry;
 restart:
-        spin_lock(&dcache_lock);
-        tmp = head;
-        while ((tmp = tmp->next) != head) {
-                struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
-                if (atomic_read(&dentry->d_count) == 0) {
-                        CDEBUG(D_DENTRY, "deleting dentry %*s (%p) parent %p "
-                               "inode %p\n", dentry->d_name.len,
-                               dentry->d_name.name, dentry, dentry->d_parent,
-                               dentry->d_inode);
-                        dget_locked(dentry);
-                        __d_drop(dentry);
-                        spin_unlock(&dcache_lock);
-                        dput(dentry);
-                        goto restart;
-                } else if (!(dentry->d_flags & DCACHE_LUSTRE_INVALID)) {
-                        CDEBUG(D_DENTRY, "unhashing dentry %*s (%p) parent %p "
-                               "inode %p refc %d\n", dentry->d_name.len,
-                               dentry->d_name.name, dentry, dentry->d_parent,
-                               dentry->d_inode, atomic_read(&dentry->d_count));
+       spin_lock(&dcache_lock);
+       tmp = head;
+       while ((tmp = tmp->next) != head) {
+               struct dentry *dentry = list_entry(tmp, struct dentry, d_alias);
+                CDEBUG(D_INODE, "invalidate 0x%p: %*s -> %lu/%lu\n",
+                       dentry, dentry->d_name.len, dentry->d_name.name,
+                       (unsigned long) dentry->d_inode->i_ino,
+                       (unsigned long) dentry->d_inode->i_generation);
+               if (!atomic_read(&dentry->d_count)) {
+                       dget_locked(dentry);
+                       __d_drop(dentry);
+                       spin_unlock(&dcache_lock);
+                       dput(dentry);
+                       goto restart;
+               } else {
                         hlist_del_init(&dentry->d_hash);
                         dentry->d_flags |= DCACHE_LUSTRE_INVALID;
                         hlist_add_head(&dentry->d_hash,
                                        &sbi->ll_orphan_dentry_list);
                 }
-        }
-        spin_unlock(&dcache_lock);
+       }
+       spin_unlock(&dcache_lock);
         EXIT;
 }
 
@@ -170,7 +150,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);
 }
@@ -236,6 +217,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);
@@ -254,7 +240,7 @@ 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,
+                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
@@ -268,17 +254,16 @@ int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
                         it = &lookup_it;
                         GOTO(out, rc = 0);
                 }
-
+                        
                 if (req)
                         ptlrpc_req_finished(req);
                 req = NULL;
                 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);
-        /* If req is NULL, then mdc_intent_lock only tried to do a lock match;
+        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 md_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)
                 GOTO(out, rc);
@@ -310,13 +295,8 @@ int ll_revalidate_it(struct dentry *de, int flags, struct lookup_intent *it)
                 ptlrpc_req_finished(req);
         if (rc == 0) {
                 ll_unhash_aliases(de->d_inode);
-                /* done in ll_unhash_aliases()
-                dentry->d_flags |= DCACHE_LUSTRE_INVALID; */
+                de->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;
         }
@@ -422,6 +402,24 @@ static int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd)
 }
 #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,7 +427,7 @@ struct dentry_operations ll_d_ops = {
         .d_revalidate_it = ll_revalidate_it,
 #endif
         .d_release = ll_release,
-        .d_delete = ll_ddelete,
+        .d_iput = ll_dentry_iput,
 #if 0
         .d_pin = ll_pin,
         .d_unpin = ll_unpin,