diff --git a/ompi/mca/common/ompio/common_ompio_buffer.h b/ompi/mca/common/ompio/common_ompio_buffer.h index 1d1d89eb42e..3a968ded346 100644 --- a/ompi/mca/common/ompio/common_ompio_buffer.h +++ b/ompi/mca/common/ompio/common_ompio_buffer.h @@ -29,6 +29,7 @@ _tbuf = mca_common_ompio_alloc_buf (_fh, _tmp_buf_size==0 ? _max_data : _tmp_buf_size); \ if ( NULL == _tbuf ) { \ opal_output(1, "common_ompio: error allocating memory\n"); \ + opal_convertor_cleanup (_convertor); \ return OMPI_ERR_OUT_OF_RESOURCE; \ } \ if (NULL != _decoded_iov) { \ @@ -43,6 +44,7 @@ _tbuf = mca_common_ompio_alloc_buf (_fh, _tmp_buf_size==0 ? _max_data : _tmp_buf_size); \ if ( NULL == _tbuf ) { \ opal_output(1, "common_ompio: error allocating memory\n"); \ + opal_convertor_cleanup (_convertor); \ return OMPI_ERR_OUT_OF_RESOURCE; \ } \ if (NULL != _decoded_iov) { \ diff --git a/ompi/mca/common/ompio/common_ompio_file_read.c b/ompi/mca/common/ompio/common_ompio_file_read.c index 15a62f455c1..7dd180d2df5 100644 --- a/ompi/mca/common/ompio/common_ompio_file_read.c +++ b/ompi/mca/common/ompio/common_ompio_file_read.c @@ -205,6 +205,7 @@ int mca_common_ompio_file_read_pipelined (ompio_file_t *fh, void *buf, tbuf2 = mca_common_ompio_alloc_buf (fh, bytes_per_cycle); if (NULL == tbuf2) { opal_output(1, "common_ompio: error allocating memory\n"); + opal_convertor_cleanup (&convertor); return OMPI_ERR_OUT_OF_RESOURCE; } unpackbuf = tbuf2; diff --git a/ompi/mca/fbtl/posix/fbtl_posix_ipreadv.c b/ompi/mca/fbtl/posix/fbtl_posix_ipreadv.c index 7b2ab311b91..3a31d33fbe4 100644 --- a/ompi/mca/fbtl/posix/fbtl_posix_ipreadv.c +++ b/ompi/mca/fbtl/posix/fbtl_posix_ipreadv.c @@ -56,8 +56,8 @@ ssize_t mca_fbtl_posix_ipreadv (ompio_file_t *fh, data->prd_req_type = FBTL_POSIX_AIO_READ; data->prd_req_chunks = ompi_fbtl_posix_max_prd_active_reqs; data->prd_total_len = 0; - data->prd_aio.aio_reqs = (struct aiocb *) malloc (sizeof(struct aiocb) * - fh->f_num_of_io_entries); + data->prd_aio.aio_reqs = (struct aiocb *) calloc (fh->f_num_of_io_entries, + sizeof(struct aiocb)); if (NULL == data->prd_aio.aio_reqs) { opal_output(1, "mca_fbtl_posix_ipreadv: could not allocate memory\n"); free(data); diff --git a/ompi/mca/fbtl/posix/fbtl_posix_ipwritev.c b/ompi/mca/fbtl/posix/fbtl_posix_ipwritev.c index 49ef459cf18..272c717ed00 100644 --- a/ompi/mca/fbtl/posix/fbtl_posix_ipwritev.c +++ b/ompi/mca/fbtl/posix/fbtl_posix_ipwritev.c @@ -55,8 +55,8 @@ ssize_t mca_fbtl_posix_ipwritev (ompio_file_t *fh, data->prd_req_type = FBTL_POSIX_AIO_WRITE; data->prd_req_chunks = ompi_fbtl_posix_max_prd_active_reqs; data->prd_total_len = 0; - data->prd_aio.aio_reqs = (struct aiocb *) malloc (sizeof(struct aiocb) * - fh->f_num_of_io_entries); + data->prd_aio.aio_reqs = (struct aiocb *) calloc (fh->f_num_of_io_entries, + sizeof(struct aiocb)); if (NULL == data->prd_aio.aio_reqs) { opal_output (1,"mca_fbtl_posix_ipwritev: could not allocate memory\n"); free(data); diff --git a/ompi/mca/io/ompio/io_ompio_file_open.c b/ompi/mca/io/ompio/io_ompio_file_open.c index 30b3052295c..76e4eb6c497 100644 --- a/ompi/mca/io/ompio/io_ompio_file_open.c +++ b/ompi/mca/io/ompio/io_ompio_file_open.c @@ -427,6 +427,7 @@ static void mca_io_ompio_file_get_eof_offset (ompio_file_t *fh, } offset = prev_offset; + assert(index_in_file_view > 0); blocklen = fh->f_fview.f_decoded_iov[index_in_file_view-1].iov_len; while (offset <= in_offset && k <= blocklen) { prev_offset = offset; diff --git a/ompi/mca/io/ompio/io_ompio_file_read.c b/ompi/mca/io/ompio/io_ompio_file_read.c index 8f0583bb0b3..39a11965711 100644 --- a/ompi/mca/io/ompio/io_ompio_file_read.c +++ b/ompi/mca/io/ompio/io_ompio_file_read.c @@ -362,13 +362,18 @@ int mca_io_ompio_file_read_all_begin (ompi_file_t *fh, data = (mca_common_ompio_data_t *) fh->f_io_selected_data; fp = &data->ompio_fh; - if ( true == fp->f_split_coll_in_use ) { - printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); - return MPI_ERR_OTHER; + + OPAL_THREAD_LOCK(&fh->f_lock); + if (true == fp->f_split_coll_in_use) { + printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); + OPAL_THREAD_UNLOCK(&fh->f_lock); + return MPI_ERR_OTHER; } - /* No need for locking fh->f_lock, that is done in file_iread_all */ - ret = mca_io_ompio_file_iread_all ( fh, buf, count, datatype, &fp->f_split_coll_req ); fp->f_split_coll_in_use = true; + OPAL_THREAD_UNLOCK(&fh->f_lock); + + /* No need for locking fh->f_lock for the operation itself, that is done in io_ompio_file_iread_all */ + ret = mca_io_ompio_file_iread_all ( fh, buf, count, datatype, &fp->f_split_coll_req ); return ret; } @@ -402,14 +407,17 @@ int mca_io_ompio_file_read_at_all_begin (ompi_file_t *fh, data = (mca_common_ompio_data_t *) fh->f_io_selected_data; fp = &data->ompio_fh; - if ( true == fp->f_split_coll_in_use ) { - printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); - return MPI_ERR_REQUEST; - } OPAL_THREAD_LOCK(&fh->f_lock); + if (true == fp->f_split_coll_in_use) { + printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); + OPAL_THREAD_UNLOCK(&fh->f_lock); + return MPI_ERR_OTHER; + } + + fp->f_split_coll_in_use = true; ret = mca_common_ompio_file_iread_at_all ( fp, offset, buf, count, datatype, &fp->f_split_coll_req ); OPAL_THREAD_UNLOCK(&fh->f_lock); - fp->f_split_coll_in_use = true; + return ret; } diff --git a/ompi/mca/io/ompio/io_ompio_file_write.c b/ompi/mca/io/ompio/io_ompio_file_write.c index b8609b34771..8efa2a5a3ec 100644 --- a/ompi/mca/io/ompio/io_ompio_file_write.c +++ b/ompi/mca/io/ompio/io_ompio_file_write.c @@ -370,13 +370,18 @@ int mca_io_ompio_file_write_all_begin (ompi_file_t *fh, data = (mca_common_ompio_data_t *) fh->f_io_selected_data; fp = &data->ompio_fh; - if ( true == fp->f_split_coll_in_use ) { - printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); - return MPI_ERR_OTHER; + + OPAL_THREAD_LOCK(&fh->f_lock); + if (true == fp->f_split_coll_in_use) { + printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); + OPAL_THREAD_UNLOCK(&fh->f_lock); + return MPI_ERR_OTHER; } - /* No need for locking fh->f_lock, that is done in file_iwrite_all */ - ret = mca_io_ompio_file_iwrite_all ( fh, buf, count, datatype, &fp->f_split_coll_req ); fp->f_split_coll_in_use = true; + OPAL_THREAD_UNLOCK(&fh->f_lock); + + /* No need for locking fh->f_lock the operation itself, that is done in io_ompio_file_iwrite_all */ + ret = mca_io_ompio_file_iwrite_all ( fh, buf, count, datatype, &fp->f_split_coll_req ); return ret; } @@ -412,14 +417,15 @@ int mca_io_ompio_file_write_at_all_begin (ompi_file_t *fh, data = (mca_common_ompio_data_t *) fh->f_io_selected_data; fp = &data->ompio_fh; - if ( true == fp->f_split_coll_in_use ) { - printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); - return MPI_ERR_REQUEST; - } OPAL_THREAD_LOCK(&fh->f_lock); + if (true == fp->f_split_coll_in_use) { + printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n"); + OPAL_THREAD_UNLOCK(&fh->f_lock); + return MPI_ERR_OTHER; + } + fp->f_split_coll_in_use = true; ret = mca_common_ompio_file_iwrite_at_all ( fp, offset, buf, count, datatype, &fp->f_split_coll_req ); OPAL_THREAD_UNLOCK(&fh->f_lock); - fp->f_split_coll_in_use = true; return ret; }