From 6e07cfd791a80eb1cb50f9db9ec2a8f36d1c816a Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 8 Jan 2004 23:13:30 +0000 Subject: [PATCH] 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 --- lustre/mds/mds_unlink_open.c | 7 ++++++- lustre/tests/multiop.c | 8 ++++++++ lustre/tests/replay-single.sh | 24 ++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/lustre/mds/mds_unlink_open.c b/lustre/mds/mds_unlink_open.c index f6280ce..330ef32 100644 --- a/lustre/mds/mds_unlink_open.c +++ b/lustre/mds/mds_unlink_open.c @@ -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); diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index 07605be..2be0b93 100755 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE /* pull in O_DIRECTORY in bits/fcntl.h */ #include #include #include @@ -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)"); diff --git a/lustre/tests/replay-single.sh b/lustre/tests/replay-single.sh index 9292b0a..034ee8a 100755 --- a/lustre/tests/replay-single.sh +++ b/lustre/tests/replay-single.sh @@ -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 -- 1.8.3.1