예제 #1
0
void
PlfsUnit::readWriteTest() {
    string path = mountpoint + "/readwrite1";
    const char *pathname = path.c_str();
    Plfs_fd *fd = NULL;
    plfs_error_t ret;
    ssize_t written;

#ifdef NEGATIVE_TEST_CASES
    ret = plfs_open(&fd, pathname, O_CREAT | O_RDONLY, pid, 0666, NULL);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    CPPUNIT_ASSERT(fd);
    ret = plfs_write(fd, "HELLO WORLD.", 13, 0, pid, &written);
    CPPUNIT_ASSERT_EQUAL(PLFS_EBADF, ret);
    ret = plfs_close(fd, pid, uid, 0, NULL, &ref_count);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    fd = NULL;
#endif
    ret = plfs_open(&fd, pathname, O_CREAT | O_RDWR, pid, 0666, NULL);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    CPPUNIT_ASSERT(fd);
    for (int i = 0; i < 10; i++) {
	char rbuf[13];
	for (pid_t fpid = 0; fpid < 10; fpid ++) {
	    off_t offset=rand();
	    ret = plfs_write(fd, "HELLO WORLD.", 13, offset, fpid, &written);
	    CPPUNIT_ASSERT_EQUAL(13, (int)written);
	    ret = plfs_sync(fd);
	    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
	    ret = plfs_read(fd, rbuf, 13, offset, &written);
	    CPPUNIT_ASSERT_EQUAL(13, (int)written);
	    CPPUNIT_ASSERT(strcmp(rbuf, "HELLO WORLD.") == 0);
	}
    }
    ret = plfs_close(fd, pid, uid, 0, NULL, &ref_count);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    fd = NULL;
    for (int i = 0; i < 10; i++) {
	char rbuf[13];
	for (pid_t fpid = 0; fpid < 10; fpid ++) {
	    off_t offset=rand();
            ret = plfs_open(&fd, pathname, O_CREAT | O_RDWR, fpid, 0666, NULL);
            CPPUNIT_ASSERT_EQUAL(0, (int)ret);
            CPPUNIT_ASSERT(fd);
	    ret = plfs_write(fd, "HELLO WORLD.", 13, offset, fpid, &written);
	    CPPUNIT_ASSERT_EQUAL(13, (int)written);
	    ret = plfs_sync(fd);
	    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
	    ret = plfs_read(fd, rbuf, 13, offset, &written);
	    CPPUNIT_ASSERT_EQUAL(13, (int)written);
	    CPPUNIT_ASSERT(strcmp(rbuf, "HELLO WORLD.") == 0);
            ret = plfs_close(fd, fpid, uid, 0, NULL, &ref_count);
            CPPUNIT_ASSERT_EQUAL(0, (int)ret);
            fd = NULL;
	}
    }
    ret = plfs_unlink(pathname);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
}
예제 #2
0
void
PlfsUnit::truncateTest() {
    string path = mountpoint + "/trunctest1";
    const char *pathname = path.c_str();
    Plfs_fd *fd = NULL;
    plfs_error_t ret;
    struct stat stbuf;
    ssize_t written;

    ret = plfs_open(&fd, pathname, O_CREAT | O_RDWR, pid, 0666, NULL);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    ret = plfs_write(fd, "SIMPLE_TRUNCATE_TEST", 21, 0, pid, &written);
    CPPUNIT_ASSERT_EQUAL(21, (int)written);
    ret = plfs_trunc(fd, pathname, 15, true);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    ret = plfs_getattr(fd, pathname, &stbuf, 1);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    CPPUNIT_ASSERT(stbuf.st_size == 15);
    ret = plfs_close(fd, pid, uid, 0, NULL, &ref_count);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    ret = plfs_trunc(NULL, pathname, 5, true);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    ret = plfs_getattr(NULL, pathname, &stbuf, 1);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
    CPPUNIT_ASSERT(stbuf.st_size == 5);
    ret = plfs_unlink(pathname);
    CPPUNIT_ASSERT_EQUAL(0, (int)ret);
}
예제 #3
0
void ADIOI_PLFS_WriteContig(ADIO_File fd, void *buf, int count,
                            MPI_Datatype datatype, int file_ptr_type,
                            ADIO_Offset offset, ADIO_Status *status,
                            int *error_code)
{
    /* --BEGIN CRAY MODIFICATION-- */
    plfs_error_t err = PLFS_TBD;
    int datatype_size, rank;
    ssize_t bytes_written;
    ADIO_Offset len;
    /* --END CRAY MODIFICATION-- */
    ADIO_Offset myoff;
    static char myname[] = "ADIOI_PLFS_WRITECONTIG";
#ifdef ROMIO_CRAY
MPIIO_TIMER_START(WSYSIO);
#endif /* ROMIO_CRAY */
    MPI_Type_size(datatype, &datatype_size);
    /* --BEGIN CRAY MODIFICATION-- */
    len = (ADIO_Offset)datatype_size * (ADIO_Offset)count;
    /* --END CRAY MODIFICATION-- */
    MPI_Comm_rank( fd->comm, &rank );
    // for the romio/test/large_file we always get an offset of 0
    // maybe we need to increment fd->fp_ind ourselves?
    if (file_ptr_type == ADIO_EXPLICIT_OFFSET) {
        myoff = offset;
    } else {
        myoff = fd->fp_ind;
    }
    if (file_ptr_type == ADIO_INDIVIDUAL) {
        myoff = fd->fp_ind;
    }
    plfs_debug( "%s: offset %ld len %ld rank %d\n",
                myname, (long)myoff, (long)len, rank );
    err = plfs_write( fd->fs_ptr, buf, len, myoff, rank, &bytes_written );
#ifdef HAVE_STATUS_SET_BYTES
    if (err == PLFS_SUCCESS ) {
        MPIR_Status_set_bytes(status, datatype, (int)bytes_written);
    }
#endif
    if (err != PLFS_SUCCESS ) {
        *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
                                           myname, __LINE__, MPI_ERR_IO,
                                           "**io",
                                           "**io %s", strplfserr(err));
    } else {
        if (file_ptr_type == ADIO_INDIVIDUAL) {
            fd->fp_ind += bytes_written;
        }
        *error_code = MPI_SUCCESS;
    }
#ifdef ROMIO_CRAY
MPIIO_TIMER_END(WSYSIO);
#endif /* ROMIO_CRAY */
}
예제 #4
0
파일: aiori-PLFS.c 프로젝트: johnbent/ior
/*
 * Write or read access to file using the PLFS interface.
 */
static IOR_offset_t PLFS_Xfer(int access, void *file, IOR_size_t * buffer,
                   IOR_offset_t length, IOR_param_t * param)
{
    plfs_error_t pret;
    ssize_t bytes = 0;
    Plfs_fd *pfd = (Plfs_fd*)file;  
    if (param->open == WRITE) {
        pret = plfs_write(pfd, (char*)buffer, length, param->offset, rank, &bytes);
    } else {
        assert(param->open == READ);
        pret = plfs_read(pfd, (char*)buffer, length, param->offset, &bytes);
    }
    return (pret == 0 ? bytes : -1);
}