Whamcloud - gitweb
Set the ino earlier - it appears that the second RPC reply does not set it.
[fs/lustre-release.git] / lustre / llite / dcache.c
index 5d1c29d..a0274d6 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <linux/obd_support.h>
 #include <linux/lustre_lite.h>
+#include <linux/lustre_dlm.h>
 
 extern struct address_space_operations ll_aops;
 
@@ -28,10 +29,16 @@ void ll_intent_release(struct dentry *de)
                 EXIT;
                 return;
         }
-
         if (de->d_it->it_lock_mode) {
                 handle = (struct lustre_handle *)de->d_it->it_lock_handle;
-                ldlm_lock_decref(handle, de->d_it->it_lock_mode);
+                if (de->d_it->it_op == IT_SETATTR) {
+                        int rc;
+                        ldlm_lock_decref(handle, de->d_it->it_lock_mode);
+                        rc = ldlm_cli_cancel(handle);
+                        if (rc < 0)
+                                CERROR("ldlm_cli_cancel: %d\n", rc);
+                } else
+                        ldlm_lock_decref(handle, de->d_it->it_lock_mode);
         }
         de->d_it = NULL;
         EXIT;
@@ -39,8 +46,35 @@ void ll_intent_release(struct dentry *de)
 
 int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it)
 {
+        struct ll_sb_info *sbi = ll_s2sbi(de->d_sb);
+        struct lustre_handle lockh;
+        __u64 res_id[RES_NAME_SIZE] = {0};
+        struct obd_device *obddev;
         ENTRY;
 
+        if (it)
+                RETURN(0); /* lookups will have NULL it */
+
+        if (!de->d_inode)
+                RETURN(0);
+
+        obddev = class_conn2obd(&sbi->ll_mdc_conn);
+        res_id[0] = de->d_inode->i_ino;
+
+        CDEBUG(D_INFO, "trying to match res "LPU64"\n", res_id[0]);
+
+        if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_MDSINTENT,
+                            NULL, 0, LCK_PR, &lockh)) {
+                ldlm_lock_decref(&lockh, LCK_PR);
+                RETURN(1);
+        }
+
+        if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_MDSINTENT,
+                            NULL, 0, LCK_PW, &lockh)) {
+                ldlm_lock_decref(&lockh, LCK_PW);
+                RETURN(1);
+        }
+
         RETURN(0);
 }