Skip to content
Snippets Groups Projects
Commit 6e07cfd7 authored by jacob's avatar jacob
Browse files

b=2368

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
parent cd7b140d
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
#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)");
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment