Exemplo n.º 1
0
void t4()
{
        char *path = "/mnt/lustre/rp_ost_t4_file";
        char namebuf[1024];
        char str[1024];
        int count = 10, i;
        ENTRY("|X| 10 open(CREAT)s (ping involved)");

        printf("create %d files\n", count);
        for (i = 0; i < count; i++) {
                sprintf(namebuf, "%s%02d", path, i);
                sprintf(str, "%s-%08d-%08x-AAAAA", "content", i, i);
                t_echo_create(namebuf, str);
        }
        replay_barrier();
        mds_failover();

        printf("read & verify\n");
        for (i = 0; i < count; i++) {
                sprintf(namebuf, "%s%02d", path, i);
                sprintf(str, "%s-%08d-%08x-AAAAA", "content", i, i);
                t_grep(namebuf, str);
                t_unlink(namebuf);
        }
}
Exemplo n.º 2
0
void n_create_delete(int nfiles)
{
        char *base="/mnt/lustre/f3_";
        char path[100];
        char str[100];
        int i;

        replay_barrier();
        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 < nfiles; i++) {
                sprintf(path, "%s%d\n", base, i);
                sprintf(str, "TEST#%d CONTENT\n", i);
                t_grep(path, str);
        }
        replay_barrier();
        for (i = 0; i < nfiles; i++) {
                sprintf(path, "%s%d\n", base, i);
                t_unlink(path);
        }
        mds_failover();
        for (i = 0; i < nfiles; i++) {
                sprintf(path, "%s%d\n", base, i);
                t_check_stat_fail(path);
        }
        LEAVE();
}
Exemplo n.º 3
0
int t54(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        struct flock lock;
        int fd, err;

        ENTER("fcntl should return 0 when succeed in getting flock");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t54_file", lustre_path);

        t_echo_create(file, "fcntl should return 0 when succeed");

        fd = open(file, O_RDWR);
        if (fd < 0) {
                printf("\nerror open file: %s\n", strerror(errno));
                return(-1);
        }
        lock.l_type   = F_WRLCK;
        lock.l_start  = 0;
        lock.l_whence = 0;
        lock.l_len    = 1;
        if ((err = t_fcntl(fd, F_SETLKW, &lock)) != 0) {
                fprintf(stderr, "fcntl returned: %d (%s)\n",
                        err, strerror(err));
                close(fd);
                t_unlink(file);
                return (-1);
        }

        lock.l_type   = F_UNLCK;
        t_fcntl(fd, F_SETLKW, &lock);
        close(fd);
        t_unlink(file);
        LEAVE();
}
Exemplo n.º 4
0
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);
}
Exemplo n.º 5
0
/*
 * truncate(2) checks.
 */
int t51(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        int fd;
        long long size;
        int result;

        ENTER("truncate() should truncate file to proper length");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t51_file", lustre_path);

        for (size = 0; size < T51_NR * T51_STEP; size += T51_STEP) {
                t_echo_create(file, "");
                if (truncate(file, size) != 0) {
                        printf("\nerror truncating file: %s\n",strerror(errno));
                        return(-1);
                }
                result = check_file_size(file, size);
                if (result != 0)
                        return result;
                t_unlink(file);

                t_echo_create(file, "");
                fd = open(file, O_RDWR|O_CREAT, (mode_t)0666);
                if (fd < 0) {
                        printf("\nerror open file: %s\n", strerror(errno));
                        return(-1);
                }
                if (ftruncate(fd, size) != 0) {
                        printf("\nerror ftruncating file:%s\n",strerror(errno));
                        return(-1);
                }
                close(fd);
                result = check_file_size(file, size);
                if (result != 0)
                        return result;
                t_unlink(file);
                if (size % (T51_STEP * (T51_NR / 75)) == 0) {
                        printf(".");
                        fflush(stdout);
                }
        }
        printf("\n");
        LEAVE();
}
Exemplo n.º 6
0
int t16(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        ENTER("small-write-read");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t16_file", lustre_path);

        t_echo_create(file, "aaaaaaaaaaaaaaaaaaaaaa");
        t_grep(file, "aaaaaaaaaaaaaaaaaaaaaa");
        t_unlink(file);
        LEAVE();
}
Exemplo n.º 7
0
void t2()
{
        char *path = "/mnt/lustre/rp_ost_t2_file";
        char *str = "xxxxjoiwlsdf98lsjdfsjfoajflsjfajfoaidfojaj08eorje;";
        ENTRY("empty replay");

        replay_barrier();
        mds_failover();

        t_echo_create(path, str);
        t_grep(path, str);
        t_unlink(path);
}
Exemplo n.º 8
0
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);
}
Exemplo n.º 9
0
void t3()
{
        char *path = "/mnt/lustre/rp_ost_t3_file";
        char *str = "xxxxjoiwlsdf98lsjdfsjfoajflsjfajfoaidfojaj08eorje;";
        ENTRY("touch");

        printf("touch to create a file\n");
        t_echo_create(path, str);
        replay_barrier();
        mds_failover();

        printf("read & verify\n");
        t_grep(path, str);
        t_unlink(path);
        /* XXX have problem without this, seems server side problem XXX */
        sleep(5);
}
Exemplo n.º 10
0
/*
 * check atime update during read
 */
int t52(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        char buf[16];
        struct stat statbuf;
        time_t atime;
        time_t diff;
        int fd, i;

        ENTER("atime should be updated during read");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t52_file", lustre_path);

        t_echo_create(file, "check atime update during read");
        fd = open(file, O_RDONLY);
        if (fd < 0) {
                printf("\nerror open file: %s\n", strerror(errno));
                return(-1);
        }
        stat(file, &statbuf);
        printf("st_atime=%s", ctime(&statbuf.st_atime));
        atime = statbuf.st_atime;
        for (i = 0; i < 3; i++) {
                ssize_t num_read;
                sleep(2);
                /* should not ignore read(2)'s return value */
                num_read = read(fd, buf, sizeof(buf));
                if (num_read < 0 ) {
                        printf("read from %s: %s\n", file, strerror(errno));
                        return -1;
                }
                stat(file, &statbuf);
                printf("st_atime=%s", ctime(&statbuf.st_atime));
                diff = statbuf.st_atime - atime;
                if (diff <= 0) {
                        printf("atime doesn't updated! failed!\n");
                        close(fd);
                        t_unlink(file);
                        return -1;
                }
                atime = statbuf.st_atime;
        }
        close(fd);
        t_unlink(file);
        LEAVE();
}
Exemplo n.º 11
0
int t19(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        int fd;
        int result;
        ENTER("open(O_TRUNC) should truncate file to 0-length");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t19_file", lustre_path);

        t_echo_create(file, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        fd = open(file, O_RDWR|O_CREAT|O_TRUNC, (mode_t)0666);
        if (fd < 0) {
                printf("error open file: %s\n", strerror(errno));
                return(-1);
        }
        close(fd);
        result = check_file_size(file, 0);
        if (result != 0)
                return result;
        t_unlink(file);
        LEAVE();
}
Exemplo n.º 12
0
int t53(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        struct utimbuf times;   /* struct. buffer for utime() */
        struct stat stat_buf;   /* struct buffer to hold file info. */
        time_t mtime, atime;

        ENTER("mtime/atime should be updated by utime() call");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t53_file", lustre_path);

        t_echo_create(file, "check mtime/atime update by utime() call");

        /* Initialize the modification and access time in the times arg */
        times.actime = NEW_TIME+10;
        times.modtime = NEW_TIME;

        /* file modification/access time */
        utime(file, &times);

        if (stat(file, &stat_buf) < 0) {
                printf("stat(2) of %s failed, error:%d %s\n",
                        file, errno, strerror(errno));
        }
        mtime = stat_buf.st_mtime;
        atime = stat_buf.st_atime;

        if ((mtime == NEW_TIME) && (atime == NEW_TIME + 10)) {
                t_unlink(file);
                LEAVE();
        }

        printf("mod time %ld, expected %ld\n", mtime, (long)NEW_TIME);
        printf("acc time %ld, expected %ld\n", atime, (long)NEW_TIME + 10);

        t_unlink(file);
        return (-1);
}