void t2a()
{
- char *path="/mnt/lustre/f1a";
+ char *path="/mnt/lustre/f2a";
ENTRY("touch");
replay_barrier();
void t2b()
{
- char *path="/mnt/lustre/f1a";
+ char *path="/mnt/lustre/f2b";
ENTRY("mcreate+touch");
t_create(path);
}
-void t3()
+void n_create_delete(int nfiles)
{
char *base="/mnt/lustre/f3_";
char path[100];
char str[100];
- char buf[100];
int i;
- ENTRY("10 create/delete");
replay_barrier();
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < nfiles; i++) {
sprintf(path, "%s%d\n", base, i);
sprintf(str, "TEST#%d CONTENT\n", i);
t_echo_create(path, str);
}
mds_failover();
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < nfiles; i++) {
sprintf(path, "%s%d\n", base, i);
sprintf(str, "TEST#%d CONTENT\n", i);
- t_pread_once(path, buf, 100, 0);
- if (!strstr(buf, str)) {
- printf("f%d: content error !\n", i);
- exit(-1);
- }
+ t_grep(path, str);
}
replay_barrier();
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < nfiles; i++) {
sprintf(path, "%s%d\n", base, i);
t_unlink(path);
}
mds_failover();
- for (i = 0; i < 10; i++) {
+ for (i = 0; i < nfiles; i++) {
sprintf(path, "%s%d\n", base, i);
- if (!stat(path, NULL)) {
- printf("f%d still exist!\n", i);
- exit(-1);
- }
+ t_check_stat_fail(path);
}
LEAVE();
}
+void t3a()
+{
+ ENTRY("10 create/delete");
+ n_create_delete(10);
+ LEAVE();
+}
+
+void t3b()
+{
+ ENTRY("60 create/delete(>1'st block precreated)");
+ n_create_delete(60);
+ LEAVE();
+}
+
void t4()
{
- char *dir="/mnt/lustre/d2";
- char *path="/mnt/lustre/d2/f2";
+ char *dir="/mnt/lustre/d4";
+ char *path="/mnt/lustre/d4/f1";
ENTRY("mkdir + contained create");
replay_barrier();
mds_failover();
t_check_stat(dir, NULL);
t_check_stat(path, NULL);
+ sleep(2); /* wait for log process thread */
+
+ replay_barrier();
t_unlink(path);
t_rmdir(dir);
+ mds_failover();
+ t_check_stat_fail(dir);
+ t_check_stat_fail(path);
LEAVE();
}
void t5()
{
- char *dir="/mnt/lustre/d3";
- char *path="/mnt/lustre/d3/f3";
+ char *dir="/mnt/lustre/d5";
+ char *path="/mnt/lustre/d5/f1";
ENTRY("mkdir |X| contained create");
t_mkdir(dir);
void t6()
{
- char *path="/mnt/lustre/f4";
+ char *path="/mnt/lustre/f6";
int fd;
ENTRY("open |X| close");
t_check_stat(path, NULL);
t_close(fd);
t_unlink(path);
+ LEAVE();
+}
+
+void t7()
+{
+ char *path="/mnt/lustre/f7";
+ char *path2="/mnt/lustre/f7-2";
+ ENTRY("create |X| rename unlink");
+
+ t_create(path);
+ replay_barrier();
+ t_rename(path, path2);
+ mds_failover();
+ t_check_stat_fail(path);
+ t_check_stat(path2, NULL);
+ t_unlink(path2);
+}
+
+void t8()
+{
+ char *path="/mnt/lustre/f8";
+ char *path2="/mnt/lustre/f8-2";
+ ENTRY("create open write rename |X| create-old-name read");
+
+ t_create(path);
+ t_echo_create(path, "old");
+ t_rename(path, path2);
+ replay_barrier();
+ t_echo_create(path, "new");
+ mds_failover();
+ t_grep(path, "new");
+ t_grep(path2, "old");
+ t_unlink(path);
+ t_unlink(path2);
+}
+
+void t9()
+{
+ char *path="/mnt/lustre/f9";
+ char *path2="/mnt/lustre/f9-2";
+ ENTRY("|X| open(O_CREAT), unlink, touch new, unlink new");
+
+ replay_barrier();
+ t_create(path);
+ t_unlink(path);
+ t_create(path2);
+ mds_failover();
+ t_check_stat_fail(path);
+ t_check_stat(path2, NULL);
+ t_unlink(path2);
+}
+
+void t10()
+{
+ char *path="/mnt/lustre/f10";
+ char *path2="/mnt/lustre/f10-2";
+ ENTRY("|X| mcreate, open write, rename");
+
+ replay_barrier();
+ t_create(path);
+ t_echo_create(path, "old");
+ t_rename(path, path2);
+ t_grep(path2, "old");
+ mds_failover();
+ t_grep(path2, "old");
+ t_unlink(path2);
}
extern int portal_debug;
t1();
t2a();
t2b();
- t3();
+ t3a();
+ t3b();
t4();
t5();
t6();
+ t7();
+ t8();
+ t9();
+ t10();
printf("liblustre is about shutdown\n");
__liblustre_cleanup_();
return 0;
}
+int t_check_stat_fail(const char *name)
+{
+ struct stat stat;
+ int rc;
+
+ rc = lstat(name, &stat);
+ if (!rc) {
+ printf("%s still exists\n", name);
+ EXIT(-1);
+ }
+
+ return 0;
+}
+
void t_echo_create(const char *path, const char *str)
{
int fd, rc;
}
}
-int t_pread_once(const char *path, char *buf, size_t size, off_t offset)
+void _t_grep(const char *path, char *str, int should_contain)
{
+ char buf[1024];
int fd;
int rc;
- memset(buf, 0, size);
-
fd = t_open_readonly(path);
- if (lseek(fd, offset, SEEK_SET) == -1) {
- printf("pread_once: seek to %lu error: %s\n",
- offset, strerror(errno));
+ if (lseek(fd, 0, SEEK_SET) == -1) {
+ printf("pread_once: seek to 0 error: %s\n", strerror(errno));
EXIT(fd);
}
- rc = read(fd, buf, size);
+ rc = read(fd, buf, 1023);
+ if (rc < 0) {
+ printf("grep: read error: %s\n", strerror(errno));
+ EXIT(-1);
+ }
close(fd);
- return rc;
+ buf[rc] = 0;
+
+ if ((strstr(buf, str) != 0) ^ should_contain) {
+ printf("grep: can't find string %s\n", str);
+ EXIT(-1);
+ }
+}
+
+void t_grep(const char *path, char *str)
+{
+ _t_grep(path, str, 1);
+}
+
+void t_grep_v(const char *path, char *str)
+{
+ _t_grep(path, str, 0);
}