Whamcloud - gitweb
b=2368
authorjacob <jacob>
Thu, 8 Jan 2004 23:13:30 +0000 (23:13 +0000)
committerjacob <jacob>
Thu, 8 Jan 2004 23:13:30 +0000 (23:13 +0000)
r=phil

 - call vfs_rmdir() on directory orphans when removing them from
   PENDING
 - add a test for this case to replay-single
 - add open(O_DIRECTORY) to multiop

lustre/mds/mds_unlink_open.c
lustre/tests/multiop.c
lustre/tests/replay-single.sh

index f6280ce..330ef32 100644 (file)
@@ -199,7 +199,12 @@ static int mds_unlink_orphan(struct obd_device *obd, struct dentry *dchild,
                 handle = NULL;
                 GOTO(out_free_msg, rc);
         }
-        rc = vfs_unlink(pending_dir, dchild);
+
+        if (S_ISDIR(inode->i_mode)) {
+                rc = vfs_rmdir(pending_dir, dchild);
+        } else {
+                rc = vfs_unlink(pending_dir, dchild);
+        }
         if (rc) 
                 CERROR("error %d unlinking orphan %*s from PENDING directory\n",
                        rc, dchild->d_name.len, dchild->d_name.name);
index 07605be..2be0b93 100755 (executable)
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE /* pull in O_DIRECTORY in bits/fcntl.h */
 #include <stdio.h>
 #include <fcntl.h>
 #include <string.h>
@@ -17,6 +18,7 @@ char usage[] =
 "Usage: %s filename command-sequence\n"
 "    command-sequence items:\n"
 "        d  mkdir\n"
+"        D  open(O_DIRECTORY)\n"
 "        o  open(O_RDONLY)\n"
 "        O  open(O_CREAT|O_RDWR)\n"
 "        u  unlink\n"
@@ -74,6 +76,12 @@ int main(int argc, char **argv)
                                 exit(1);
                         }
                         break;
+               case 'D':
+                       if (open(fname, O_DIRECTORY) == -1) {
+                               perror("open(O_DIRECTORY)");
+                               exit(1);
+                       }
+                       break;
                 case 'm':
                         if (mknod(fname, S_IFREG | 0644, 0) == -1) {
                                 perror("mknod(S_IFREG|0644, 0)");
index 9292b0a..034ee8a 100755 (executable)
@@ -653,8 +653,7 @@ test_34() {
     fail_abort mds
     kill -USR1 $pid
     [ -e $DIR/$tfile ] && return 1
-    sleep 3
-    # wait for commitment of removal
+    sync
     return 0
 }
 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
@@ -687,5 +686,26 @@ test_36() {
 }
 run_test 36 "don't resend cancel"
 
+# b=2368
+# directory orphans can't be unlinked from PENDING directory
+test_37() {
+    rmdir $DIR/$tfile 2>/dev/null
+    multiop $DIR/$tfile dD_c &
+    pid=$!
+    # give multiop a chance to open
+    sleep 1 
+    rmdir $DIR/$tfile
+
+    replay_barrier mds
+    # clear the dmesg buffer so we only see errors from this recovery
+    dmesg -c >/dev/null
+    fail_abort mds
+    kill -USR1 $pid
+    dmesg | grep  "mds_unlink_orphan.*error .* unlinking orphan" && return 1
+    sync
+    return 0
+}
+run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
+
 equals_msg test complete, cleaning up
 $CLEANUP