1
1

Merge pull request #1782 from edgargabriel/getview-preallocate-fixes

io/ompio: fix the preallocate function
Этот коммит содержится в:
Edgar Gabriel 2016-06-14 11:59:47 -05:00 коммит произвёл GitHub
родитель eb37574afc 1ddfd6cdca
Коммит 2886d93fb8

Просмотреть файл

@ -431,16 +431,29 @@ mca_io_ompio_file_preallocate (ompi_file_t *fh,
tmp = diskspace; tmp = diskspace;
data->ompio_fh.f_comm->c_coll.coll_bcast (&tmp, ret = data->ompio_fh.f_comm->c_coll.coll_bcast (&tmp,
1, 1,
OMPI_OFFSET_DATATYPE, OMPI_OFFSET_DATATYPE,
OMPIO_ROOT, OMPIO_ROOT,
data->ompio_fh.f_comm, data->ompio_fh.f_comm,
data->ompio_fh.f_comm->c_coll.coll_bcast_module); data->ompio_fh.f_comm->c_coll.coll_bcast_module);
if ( OMPI_SUCCESS != ret ) {
return OMPI_ERROR;
}
if (tmp != diskspace) { if (tmp != diskspace) {
return OMPI_ERROR; return OMPI_ERROR;
} }
ret = data->ompio_fh.f_fs->fs_file_get_size (&data->ompio_fh,
&current_size);
if ( OMPI_SUCCESS != ret ) {
return OMPI_ERROR;
}
if ( current_size > diskspace ) {
return OMPI_SUCCESS;
}
/* ROMIO explanation /* ROMIO explanation
On file systems with no preallocation function, we have to On file systems with no preallocation function, we have to
@ -450,8 +463,8 @@ mca_io_ompio_file_preallocate (ompi_file_t *fh,
preallocation is needed. preallocation is needed.
*/ */
if (OMPIO_ROOT == data->ompio_fh.f_rank) { if (OMPIO_ROOT == data->ompio_fh.f_rank) {
ret = data->ompio_fh.f_fs->fs_file_get_size (&data->ompio_fh, OMPI_MPI_OFFSET_TYPE prev_offset;
&current_size); ompio_io_ompio_file_get_position (&data->ompio_fh, &prev_offset );
size = diskspace; size = diskspace;
if (size > current_size) { if (size > current_size) {
@ -463,7 +476,8 @@ mca_io_ompio_file_preallocate (ompi_file_t *fh,
buf = (char *) malloc (OMPIO_PREALLOC_MAX_BUF_SIZE); buf = (char *) malloc (OMPIO_PREALLOC_MAX_BUF_SIZE);
if (NULL == buf) { if (NULL == buf) {
opal_output(1, "OUT OF MEMORY\n"); opal_output(1, "OUT OF MEMORY\n");
return OMPI_ERR_OUT_OF_RESOURCE; ret = OMPI_ERR_OUT_OF_RESOURCE;
goto exit;
} }
written = 0; written = 0;
@ -474,11 +488,11 @@ mca_io_ompio_file_preallocate (ompi_file_t *fh,
} }
ret = mca_io_ompio_file_read (fh, buf, len, MPI_BYTE, status); ret = mca_io_ompio_file_read (fh, buf, len, MPI_BYTE, status);
if (ret != OMPI_SUCCESS) { if (ret != OMPI_SUCCESS) {
return OMPI_ERROR; goto exit;
} }
ret = mca_io_ompio_file_write (fh, buf, len, MPI_BYTE, status); ret = mca_io_ompio_file_write (fh, buf, len, MPI_BYTE, status);
if (ret != OMPI_SUCCESS) { if (ret != OMPI_SUCCESS) {
return OMPI_ERROR; goto exit;
} }
written += len; written += len;
} }
@ -495,20 +509,25 @@ mca_io_ompio_file_preallocate (ompi_file_t *fh,
} }
ret = mca_io_ompio_file_write (fh, buf, len, MPI_BYTE, status); ret = mca_io_ompio_file_write (fh, buf, len, MPI_BYTE, status);
if (ret != OMPI_SUCCESS) { if (ret != OMPI_SUCCESS) {
return OMPI_ERROR; goto exit;
} }
written += len; written += len;
} }
} }
if (NULL != buf) {
free (buf);
buf = NULL;
}
}
ret = data->ompio_fh.f_fs->fs_file_set_size (&data->ompio_fh, diskspace);
fh->f_comm->c_coll.coll_barrier (fh->f_comm, // This operation should not affect file pointer position.
fh->f_comm->c_coll.coll_barrier_module); ompi_io_ompio_set_explicit_offset ( &data->ompio_fh, prev_offset);
}
exit:
free ( buf );
fh->f_comm->c_coll.coll_bcast ( &ret, 1, MPI_INT, OMPIO_ROOT, fh->f_comm,
fh->f_comm->c_coll.coll_bcast_module);
if ( diskspace > current_size ) {
data->ompio_fh.f_fs->fs_file_set_size (&data->ompio_fh, diskspace);
}
return ret; return ret;
} }