Whamcloud - gitweb
b=617851
authorpschwan <pschwan>
Mon, 14 Oct 2002 21:27:48 +0000 (21:27 +0000)
committerpschwan <pschwan>
Mon, 14 Oct 2002 21:27:48 +0000 (21:27 +0000)
- Had to disable robert's semaphore changes -- they were causing deadlocks.
I'll debug this separately.
- Revamp ll_revalidate2 to return '1' any time that we have a lock (or a pinned
dentry, which may not always be the right thing)
- Don't LBUG() if we try to rmdir a not-empty directory

lustre/ldlm/ldlm_lock.c
lustre/llite/dcache.c
lustre/llite/namei.c

index 28716b5..a17a27a 100644 (file)
@@ -330,8 +330,8 @@ struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *handle)
         }
 
         if (lock->l_random != handle->cookie) {
-                CERROR("bogus cookie: lock "LPX64", handle "LPX64"\n",
-                       lock->l_random, handle->cookie);
+                CERROR("bogus cookie: lock %p has "LPX64" vs. handle "LPX64"\n",
+                       lock, lock->l_random, handle->cookie);
                 GOTO(out2, NULL);
         }
         if (!lock->l_resource) {
index 42d2aa2..9b4bc2d 100644 (file)
@@ -31,7 +31,7 @@
 
 extern struct address_space_operations ll_aops;
 
-void ll_release(struct dentry *de) 
+void ll_release(struct dentry *de)
 {
         ENTRY;
 
@@ -63,7 +63,7 @@ void ll_intent_release(struct dentry *de)
                         ldlm_lock_decref(handle, de->d_it->it_lock_mode);
         }
         // de->d_it = NULL;
-        up(&ll_d2d(de)->lld_it_sem);
+        //up(&ll_d2d(de)->lld_it_sem);
         EXIT;
 }
 
@@ -73,18 +73,18 @@ int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it)
         struct lustre_handle lockh;
         __u64 res_id[RES_NAME_SIZE] = {0};
         struct obd_device *obddev;
+        int rc = 0;
         ENTRY;
 
-        /* right now we're only interested in IT_OPEN and IT_LOOKUP */
         if (it) {
                 CDEBUG(D_INFO, "name: %*s, intent: %s\n", de->d_name.len,
                        de->d_name.name, ldlm_it2str(it->it_op));
-                if (!(it->it_op & IT_OPEN))
-                        RETURN(0);
+                if (it->it_op == IT_RENAME)
+                        it->it_data = de;
         }
 
         if (!de->d_inode)
-                RETURN(0);
+                GOTO(out, rc = 0);
 
         obddev = class_conn2obd(&sbi->ll_mdc_conn);
         res_id[0] = de->d_inode->i_ino;
@@ -94,32 +94,37 @@ int ll_revalidate2(struct dentry *de, int flags, struct lookup_intent *it)
         if (ldlm_lock_match(obddev->obd_namespace, res_id, LDLM_MDSINTENT,
                             NULL, 0, LCK_PR, &lockh)) {
                 ldlm_lock_decref(&lockh, LCK_PR);
-                RETURN(1);
+                GOTO(out, rc = 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);
+                GOTO(out, rc = 1);
         }
 
-        /* If we're acting on an IT_OPEN intent and the file is already open,
-         * we won't get called in lookup2 if we return 0, so return 1.
+        /* If the dentry is busy, we won't get called in lookup2 if we
+         * return 0, so return 1.
          *
          * This is a temporary fix for bug 618962, but is one of the causes of
          * 619078. */
         CDEBUG(D_INFO, "d_count: %d\n", atomic_read(&de->d_count));
-        if (atomic_read(&de->d_count) > 0)
-                RETURN(1);
+        if (it && atomic_read(&de->d_count) > 0) {
+                CERROR("returning 1 for %*s during %s because d_count is %d\n",
+                       de->d_name.len, de->d_name.name, ldlm_it2str(it->it_op),
+                       atomic_read(&de->d_count));
+                GOTO(out, rc = 1);
+        }
 
+ out:
         if (ll_d2d(de) == NULL) {
                 CERROR("allocating fsdata\n");
                 ll_set_dd(de);
         }
-        down(&ll_d2d(de)->lld_it_sem);
-        //  de->d_it = it;        
+        //down(&ll_d2d(de)->lld_it_sem);
+        //  de->d_it = it;
 
-        RETURN(0);
+        RETURN(rc);
 }
 
 int ll_set_dd(struct dentry *de)
index 98797e8..86deb38 100644 (file)
@@ -287,16 +287,14 @@ static struct dentry *ll_lookup2(struct inode *dir, struct dentry *dentry,
         dentry->d_op = &ll_d_ops;
         d_add(dentry, inode);
 
-        if (ll_d2d(dentry) == NULL) {
+        if (ll_d2d(dentry) == NULL)
                 ll_set_dd(dentry);
-        }
-        down(&ll_d2d(dentry)->lld_it_sem);
+        // down(&ll_d2d(dentry)->lld_it_sem);
         // dentry->d_it = it;        
 
         if (it->it_op == IT_LOOKUP)
                 ll_intent_release(dentry);
 
-
         return NULL;
 
  drop_req:
@@ -726,7 +724,7 @@ static int ll_rmdir(struct inode *dir, struct dentry *dentry)
 
         if (!dentry->d_it || dentry->d_it->it_disposition == 0) {
                 if (!ext2_empty_dir(inode))
-                        LBUG();
+                        RETURN(-ENOTEMPTY);
                 err = ll_common_unlink(dir, dentry, S_IFDIR);
         } else
                 err = dentry->d_it->it_status;