Esempio n. 1
0
int t10(char *name)
{
        char dir1[MAX_PATH_LENGTH] = "";
        char dir2[MAX_PATH_LENGTH] = "";
        char path1[MAX_PATH_LENGTH] = "";
        char path2[MAX_PATH_LENGTH] = "";
        char rename1[MAX_PATH_LENGTH] = "";
        char rename2[MAX_PATH_LENGTH] = "";
        char rename3[MAX_PATH_LENGTH] = "";

        ENTER("rename");
        snprintf(dir1, MAX_PATH_LENGTH, "%s/test_t10_dir1", lustre_path);
        snprintf(dir2, MAX_PATH_LENGTH, "%s/test_t10_dir2", lustre_path);
        snprintf(path1, MAX_PATH_LENGTH, "%s/test_t10_reg1", lustre_path);
        snprintf(path2, MAX_PATH_LENGTH, "%s/test_t10_reg2", lustre_path);
        snprintf(rename1, MAX_PATH_LENGTH, "%s/test_t10_dir1/rename1", lustre_path);
        snprintf(rename2, MAX_PATH_LENGTH, "%s/test_t10_dir2/rename2", lustre_path);
        snprintf(rename3, MAX_PATH_LENGTH, "%s/test_t10_dir2/rename3", lustre_path);

        t_mkdir(dir1);
        t_mkdir(dir2);
        t_touch(path1);
        t_touch(path2);
        t_rename(path1, rename1);
        t_rename(path2, rename2);
        t_rename(rename1, rename2);
        t_rename(dir1, rename3);
        t_unlink(rename2);
        t_rmdir(rename3);
        t_rmdir(dir2);
        LEAVE();
}
Esempio n. 2
0
int t18b(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        int i;
        struct stat statbuf[3];
        ENTER("utime should change mtime/atime/ctime");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t18b_file", lustre_path);
        t_touch(file);

        for (i = 0; i < 3; i++) {
                t_utime(file, NULL);
                if(stat(file, &statbuf[i]) != 0) {
                        printf("Error stat\n");
                        return(1);
                }
                printf("atime %lu, mtime %lu, ctime %lu\n",
                       statbuf[i].st_atime, statbuf[i].st_mtime,
                       statbuf[i].st_ctime);
                sleep(2);
        }

        for (i = 1; i < 3; i++) {
                if ((statbuf[i].st_atime <= statbuf[i-1].st_atime) ||
                    (statbuf[i].st_mtime <= statbuf[i-1].st_mtime) ||
                    (statbuf[i].st_ctime <= statbuf[i-1].st_ctime)) {
                        printf("time error\n");
                        return(-1);
                }
        }
        t_unlink(file);
        LEAVE();
}
Esempio n. 3
0
int t13(char *name)
{
        char dir[MAX_PATH_LENGTH] = "";
        char path[1024];
        char buf[1024];
        const int nfiles = 20;
        char *prefix = "test13_filename_prefix_";
        int fd, i;
        ENTER("multiple entries directory readdir");
        snprintf(dir, MAX_PATH_LENGTH, "%s/test_t13_dir/", lustre_path);

        t_mkdir(dir);
        printf("Creating %d files...\n", nfiles);
        for (i = 0; i < nfiles; i++) {
                sprintf(path, "%s%s%05d", dir, prefix, i);
                t_touch(path);
        }
        fd = t_opendir(dir);
        t_ls(fd, buf, sizeof(buf));
        t_close(fd);
        printf("Cleanup...\n");
        for (i = 0; i < nfiles; i++) {
                sprintf(path, "%s%s%05d", dir, prefix, i);
                t_unlink(path);
        }
        t_rmdir(dir);
        LEAVE();
}
Esempio n. 4
0
int t11(char *name)
{
        char *base=lustre_path;
        char path[MAX_PATH_LENGTH], path2[MAX_PATH_LENGTH];
        int i, j, level = 5, nreg = 5;
        ENTER("deep tree");

        safe_strncpy(path, base, MAX_PATH_LENGTH);

        for (i = 0; i < level; i++) {
                for (j = 0; j < nreg; j++) {
                        sprintf(path2, "%s/file%d", path, j);
                        t_touch(path2);
                }

                strcat(path, "/dir");
                t_mkdir(path);
        }

        for (i = level; i > 0; i--) {
                safe_strncpy(path, base, MAX_PATH_LENGTH);
                for (j = 1; j < i; j++)
                        strcat(path, "/dir");

                for (j = 0; j < nreg; j++) {
                        sprintf(path2, "%s/file%d", path, j);
                        t_unlink(path2);
                }

                strcat(path, "/dir");
                t_rmdir(path);
        }

        LEAVE();
}
Esempio n. 5
0
int t6b(char *name)
{
        char path[MAX_PATH_LENGTH] = "";
        char path2[MAX_PATH_LENGTH] = "";
        char cwd[MAX_PATH_LENGTH] = "";
        char *tmp;
        int fd;

        ENTER("symlink + chdir and open");
        snprintf(path, MAX_PATH_LENGTH, "%s/test_t6b", lustre_path);
        snprintf(path2, MAX_PATH_LENGTH, "%s/test_t6b_link", lustre_path);

        t_mkdir(path);
        t_symlink(path, path2);
        t_check_stat(path2, NULL);

        tmp = getcwd(cwd, MAX_PATH_LENGTH);
        if (tmp == NULL) {
                fprintf(stderr, "current path too long to fit in "
                        "MAX_PATH_LENGTH?\n");
                LEAVE();
        }
        t_chdir(path2);
        t_chdir(cwd);
        t_rmdir(path);
        t_touch(path);

        fd = t_open(path2);
        t_close(fd);

        t_unlink(path2);
        t_unlink(path);
        LEAVE();
}
Esempio n. 6
0
int t3(char *name)
{
        char path[MAX_PATH_LENGTH] = "";

        ENTER("regular stat");
        snprintf(path, MAX_PATH_LENGTH, "%s/test_t3", lustre_path);

        t_touch(path);
        t_check_stat(path, NULL);
        t_unlink(path);
        LEAVE();
}
Esempio n. 7
0
void t2a()
{
        char *path="/mnt/lustre/f2a";
        ENTRY("touch");

        replay_barrier();
        t_touch(path);
        mds_failover();
        t_check_stat(path, NULL);
        t_unlink(path);
        LEAVE();
}
Esempio n. 8
0
/* XXX Now libsysio don't support mcreate */
void t_create(const char *path)
{
        return t_touch(path);
#if 0
        int rc;

        rc = mknod(path, S_IFREG | 0644, 0);
        if (rc) {
                printf("mknod(%s) error: %s\n", path, strerror(errno));
                exit(-1);
        }
#endif
}
Esempio n. 9
0
int t15(char *name)
{
        char file[MAX_PATH_LENGTH] = "";
        int fd;
        ENTER("open-stat-close");
        snprintf(file, MAX_PATH_LENGTH, "%s/test_t15_file", lustre_path);

        t_touch(file);
        fd = t_open(file);
        t_check_stat(file, NULL);
        t_close(fd);
        t_unlink(file);
        LEAVE();
}
Esempio n. 10
0
int t1(char *name)
{
        char path[MAX_PATH_LENGTH] = "";

        ENTER("touch+unlink");
        snprintf(path, MAX_PATH_LENGTH, "%s/test_t1", lustre_path);

        if (opt_verbose)
                printf("touch+unlink %s\n", path);

        t_touch(path);
        t_unlink(path);
        LEAVE();
}
Esempio n. 11
0
int t6(char *name)
{
        char path[MAX_PATH_LENGTH] = "";
        char path2[MAX_PATH_LENGTH] = "";

        ENTER("symlink");
        snprintf(path, MAX_PATH_LENGTH, "%s/test_t6", lustre_path);
        snprintf(path2, MAX_PATH_LENGTH, "%s/test_t6_link", lustre_path);

        t_touch(path);
        t_symlink(path, path2);
        t_check_stat(path2, NULL);
        t_unlink(path2);
        t_unlink(path);
        LEAVE();
}
Esempio n. 12
0
void t1()
{
        const int bufsize = 4096;
        char *path = "/mnt/lustre/rp_ost_t1_file";
        char buf[bufsize];
        int fd, i, j;
        ENTRY("open-write-close-open-failover-read (no ping involved)");

        printf("create/open file...\n");
        t_touch(path);
        fd = t_open(path);
        printf("write file...\n");
        for (i = 0; i < 20; i++) {
                memset(buf, i, bufsize);
                if (write(fd, buf, bufsize) != bufsize) {
                        perror("write error");
                        exit(-1);
                }
        }
        printf("close/reopen...\n");
        t_close(fd);
        fd = t_open(path);
        lseek(fd, 0, SEEK_SET);

        printf("OST failover...\n");
        replay_barrier();
        mds_failover();

        printf("read & verify...\n");
        for (i = 0; i < 20; i++) {
                memset(buf, -1, bufsize);
                if (read(fd, buf, bufsize) != bufsize) {
                        perror("read error after failover");
                        exit(-1);
                }
                for (j = 0; j < bufsize; j++) {
                        if (buf[j] != i) {
                                printf("verify error after failover\n");
                                exit(-1);
                        }
                }
        }

        t_close(fd);
        t_unlink(path);
        LEAVE();
}
Esempio n. 13
0
void t0()
{
        const int bufsize = 4096;
        char *path = "/mnt/lustre/rp_ost_t0_file";
        char buf[bufsize];
        int fd, i, j, rc;
        ENTRY("open-failover-write-verification (no ping involved)");

        printf("create/open file...\n");
        t_touch(path);
        fd = t_open(path);
        printf("OST failover...\n");
        replay_barrier();
        mds_failover();

        printf("write file...\n");
        for (i = 0; i < 20; i++) {
                memset(buf, i, bufsize);
                if ((rc = write(fd, buf, bufsize)) != bufsize) {
                        perror("write error after failover");
                        printf("i = %d, rc = %d\n", i, rc);
                        exit(-1);
                }
        }

        /* verify */
        printf("read & verify...\n");
        lseek(fd, 0, SEEK_SET);
        for (i = 0; i < 20; i++) {
                memset(buf, -1, bufsize);
                if ((rc = read(fd, buf, bufsize)) != bufsize) {
                        perror("read error rc");
                        printf("i = %d, rc = %d\n", i, rc);
                        exit(-1);
                }
                for (j = 0; j < bufsize; j++) {
                        if (buf[j] != i) {
                                printf("verify error!\n");
                                exit(-1);
                        }
                }
        }
        t_close(fd);
        t_unlink(path);
        LEAVE();
}
Esempio n. 14
0
int t8(char *name)
{
        char path[MAX_PATH_LENGTH] = "";

        ENTER("chmod");
        snprintf(path, MAX_PATH_LENGTH, "%s/test_t8", lustre_path);

        /* Check file. */
        t_touch(path);
        t_chmod_raw(path, 0700);
        t_check_stat(path, NULL);
        t_unlink(path);

        /* Check dir. */
        t_mkdir(path);
        t_chmod_raw(path, 0700);
        t_check_stat(path, NULL);
        t_rmdir(path);

        LEAVE();
}
Esempio n. 15
0
/* pos:   i/o start from
 * xfer:  npages per transfer
 */
static int pages_io(int xfer, loff_t pos)
{
        char path[MAX_PATH_LENGTH] = "";

        int check_sum[_npages] = {0,}, *buf;
        int fd, rc, i, j, data_error = 0;
        struct timeval tw1, tw2, tr1, tr2;
        double tw, tr;
        loff_t ret;

        snprintf(path, MAX_PATH_LENGTH, "%s/test_t50", lustre_path);

        memset(buf_alloc, 0, buf_size);

        /* create sample data */
        for (i = 0, buf = buf_alloc; i < _npages; i++) {
                for (j = 0; j < CFS_PAGE_SIZE/sizeof(int); j++, buf++) {
                        *buf = rand();
                }
        }

        /* compute checksum */
        for (i = 0, buf = buf_alloc; i < _npages; i++) {
                for (j = 0; j < CFS_PAGE_SIZE/sizeof(int); j++, buf++) {
                        check_sum[i] += *buf;
                }
        }

        unlink(path);
        t_touch(path);

        fd = t_open(path);

        /* write */
        ret = lseek(fd, pos, SEEK_SET);
        if (ret != pos) {
                perror("write seek");
                return 1;
        }
        gettimeofday(&tw1, NULL);
        for (i = 0, buf = buf_alloc; i < _npages;
             i += xfer, buf += xfer * CFS_PAGE_SIZE / sizeof(int)) {
                rc = write(fd, buf, CFS_PAGE_SIZE * xfer);
                if (rc != CFS_PAGE_SIZE * xfer) {
                        printf("write error (i %d, rc %d): %s\n", i, rc,
                               strerror(errno));
                        return(1);
                }
        }
        gettimeofday(&tw2, NULL);

        memset(buf_alloc, 0, buf_size);

        /* read */
        ret = lseek(fd, pos, SEEK_SET);
        if (ret != pos) {
                perror("read seek");
                return 1;
        }
        gettimeofday(&tr1, NULL);
        for (i = 0, buf = buf_alloc; i < _npages;
             i += xfer, buf += xfer * CFS_PAGE_SIZE / sizeof(int)) {
                rc = read(fd, buf, CFS_PAGE_SIZE * xfer);
                if (rc != CFS_PAGE_SIZE * xfer) {
                        printf("read error (i %d, rc %d): %s\n", i, rc,
                               strerror(errno));
                        return(1);
                }
        }
        gettimeofday(&tr2, NULL);

        /* compute checksum */
        for (i = 0, buf = buf_alloc; i < _npages; i++) {
                int sum = 0;
                for (j = 0; j < CFS_PAGE_SIZE/sizeof(int); j++, buf++) {
                        sum += *buf;
                }
                if (sum != check_sum[i]) {
                        data_error = 1;
                        printf("chunk %d checksum error expected %#x got %#x\n",
                                i, check_sum[i], sum);
                }
        }

        t_close(fd);
        t_unlink(path);
        tw = (tw2.tv_sec - tw1.tv_sec) * 1000000 + (tw2.tv_usec - tw1.tv_usec);
        tr = (tr2.tv_sec - tr1.tv_sec) * 1000000 + (tr2.tv_usec - tr1.tv_usec);
        printf(" (R:%.3fM/s, W:%.3fM/s)\n",
                (_npages * CFS_PAGE_SIZE) / (tw / 1000000.0) / (1024 * 1024),
                (_npages * CFS_PAGE_SIZE) / (tr / 1000000.0) / (1024 * 1024));

        if (data_error)
                return 1;

        return 0;
}
Esempio n. 16
0
int t14(char *name)
{
        char dir[MAX_PATH_LENGTH] = "";
        char path[1024];
        char buf[1024];
        const int nfiles = 256;
        char *prefix = "test14_filename_long_prefix_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA___";
        cfs_dirent_t *ent;
        int fd, i, rc, pos, index;
        loff_t base = 0;
        ENTER(">1 block(4k) directory readdir");
        snprintf(dir, MAX_PATH_LENGTH, "%s/test_t14_dir/", lustre_path);

        rc = mkdir(dir, 0755);
        if (rc < 0 && errno != EEXIST) {
                printf("mkdir(%s) error: %s\n", dir, strerror(errno));
                exit(1);
        }
        printf("Creating %d files...\n", nfiles);
        for (i = 0; i < nfiles; i++) {
                sprintf(path, "%s%s%05d", dir, prefix, i);
                t_touch(path);
        }
        fd = t_opendir(dir);
        printf("Listing...\n");
        index = 0;
        while ((rc = getdirentries64(fd, buf, 1024, &base)) > 0) {
                pos = 0;
                while (pos < rc) {
                        char *item;

                        ent = (void *) buf + pos;
                        item = (char *) ent->d_name;
                        if (!strcmp(item, ".") || !strcmp(item, ".."))
                                goto iter;
                        if (strstr(item, prefix) != item) {
                                printf("found bad name %s\n", item);
                                return(-1);
                        }
                        printf("[%03d]: %s\t",
                                index++, item + strlen(prefix));
iter:
                        pos += ent->d_reclen;
                }
        }
        printf("\n");
        if (rc < 0) {
                printf("getdents error %d\n", rc);
                return(-1);
        }
        if (index != nfiles) {
                printf("get %d files != %d\n", index, nfiles);
                return(-1);
        }
        t_close(fd);
        printf("Cleanup...\n");
        for (i = 0; i < nfiles; i++) {
                sprintf(path, "%s%s%05d", dir, prefix, i);
                t_unlink(path);
        }
        t_rmdir(dir);
        LEAVE();
}