Skip to content

Commit ad35fd5

Browse files
authored
Merge pull request #13207 from edgargabriel/topic/cid-cleanups
CID fixes for ompio
2 parents bb9ca43 + dfd1ed9 commit ad35fd5

7 files changed

+42
-24
lines changed

ompi/mca/common/ompio/common_ompio_buffer.h

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
_tbuf = mca_common_ompio_alloc_buf (_fh, _tmp_buf_size==0 ? _max_data : _tmp_buf_size); \
3030
if ( NULL == _tbuf ) { \
3131
opal_output(1, "common_ompio: error allocating memory\n"); \
32+
opal_convertor_cleanup (_convertor); \
3233
return OMPI_ERR_OUT_OF_RESOURCE; \
3334
} \
3435
if (NULL != _decoded_iov) { \
@@ -43,6 +44,7 @@
4344
_tbuf = mca_common_ompio_alloc_buf (_fh, _tmp_buf_size==0 ? _max_data : _tmp_buf_size); \
4445
if ( NULL == _tbuf ) { \
4546
opal_output(1, "common_ompio: error allocating memory\n"); \
47+
opal_convertor_cleanup (_convertor); \
4648
return OMPI_ERR_OUT_OF_RESOURCE; \
4749
} \
4850
if (NULL != _decoded_iov) { \

ompi/mca/common/ompio/common_ompio_file_read.c

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ int mca_common_ompio_file_read_pipelined (ompio_file_t *fh, void *buf,
205205
tbuf2 = mca_common_ompio_alloc_buf (fh, bytes_per_cycle);
206206
if (NULL == tbuf2) {
207207
opal_output(1, "common_ompio: error allocating memory\n");
208+
opal_convertor_cleanup (&convertor);
208209
return OMPI_ERR_OUT_OF_RESOURCE;
209210
}
210211
unpackbuf = tbuf2;

ompi/mca/fbtl/posix/fbtl_posix_ipreadv.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ ssize_t mca_fbtl_posix_ipreadv (ompio_file_t *fh,
5656
data->prd_req_type = FBTL_POSIX_AIO_READ;
5757
data->prd_req_chunks = ompi_fbtl_posix_max_prd_active_reqs;
5858
data->prd_total_len = 0;
59-
data->prd_aio.aio_reqs = (struct aiocb *) malloc (sizeof(struct aiocb) *
60-
fh->f_num_of_io_entries);
59+
data->prd_aio.aio_reqs = (struct aiocb *) calloc (fh->f_num_of_io_entries,
60+
sizeof(struct aiocb));
6161
if (NULL == data->prd_aio.aio_reqs) {
6262
opal_output(1, "mca_fbtl_posix_ipreadv: could not allocate memory\n");
6363
free(data);

ompi/mca/fbtl/posix/fbtl_posix_ipwritev.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ ssize_t mca_fbtl_posix_ipwritev (ompio_file_t *fh,
5555
data->prd_req_type = FBTL_POSIX_AIO_WRITE;
5656
data->prd_req_chunks = ompi_fbtl_posix_max_prd_active_reqs;
5757
data->prd_total_len = 0;
58-
data->prd_aio.aio_reqs = (struct aiocb *) malloc (sizeof(struct aiocb) *
59-
fh->f_num_of_io_entries);
58+
data->prd_aio.aio_reqs = (struct aiocb *) calloc (fh->f_num_of_io_entries,
59+
sizeof(struct aiocb));
6060
if (NULL == data->prd_aio.aio_reqs) {
6161
opal_output (1,"mca_fbtl_posix_ipwritev: could not allocate memory\n");
6262
free(data);

ompi/mca/io/ompio/io_ompio_file_open.c

+1
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ static void mca_io_ompio_file_get_eof_offset (ompio_file_t *fh,
427427
}
428428

429429
offset = prev_offset;
430+
assert(index_in_file_view > 0);
430431
blocklen = fh->f_fview.f_decoded_iov[index_in_file_view-1].iov_len;
431432
while (offset <= in_offset && k <= blocklen) {
432433
prev_offset = offset;

ompi/mca/io/ompio/io_ompio_file_read.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,18 @@ int mca_io_ompio_file_read_all_begin (ompi_file_t *fh,
362362

363363
data = (mca_common_ompio_data_t *) fh->f_io_selected_data;
364364
fp = &data->ompio_fh;
365-
if ( true == fp->f_split_coll_in_use ) {
366-
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
367-
return MPI_ERR_OTHER;
365+
366+
OPAL_THREAD_LOCK(&fh->f_lock);
367+
if (true == fp->f_split_coll_in_use) {
368+
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
369+
OPAL_THREAD_UNLOCK(&fh->f_lock);
370+
return MPI_ERR_OTHER;
368371
}
369-
/* No need for locking fh->f_lock, that is done in file_iread_all */
370-
ret = mca_io_ompio_file_iread_all ( fh, buf, count, datatype, &fp->f_split_coll_req );
371372
fp->f_split_coll_in_use = true;
373+
OPAL_THREAD_UNLOCK(&fh->f_lock);
374+
375+
/* No need for locking fh->f_lock for the operation itself, that is done in io_ompio_file_iread_all */
376+
ret = mca_io_ompio_file_iread_all ( fh, buf, count, datatype, &fp->f_split_coll_req );
372377

373378
return ret;
374379
}
@@ -402,14 +407,17 @@ int mca_io_ompio_file_read_at_all_begin (ompi_file_t *fh,
402407
data = (mca_common_ompio_data_t *) fh->f_io_selected_data;
403408
fp = &data->ompio_fh;
404409

405-
if ( true == fp->f_split_coll_in_use ) {
406-
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
407-
return MPI_ERR_REQUEST;
408-
}
409410
OPAL_THREAD_LOCK(&fh->f_lock);
411+
if (true == fp->f_split_coll_in_use) {
412+
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
413+
OPAL_THREAD_UNLOCK(&fh->f_lock);
414+
return MPI_ERR_OTHER;
415+
}
416+
417+
fp->f_split_coll_in_use = true;
410418
ret = mca_common_ompio_file_iread_at_all ( fp, offset, buf, count, datatype, &fp->f_split_coll_req );
411419
OPAL_THREAD_UNLOCK(&fh->f_lock);
412-
fp->f_split_coll_in_use = true;
420+
413421
return ret;
414422
}
415423

ompi/mca/io/ompio/io_ompio_file_write.c

+16-10
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,18 @@ int mca_io_ompio_file_write_all_begin (ompi_file_t *fh,
370370

371371
data = (mca_common_ompio_data_t *) fh->f_io_selected_data;
372372
fp = &data->ompio_fh;
373-
if ( true == fp->f_split_coll_in_use ) {
374-
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
375-
return MPI_ERR_OTHER;
373+
374+
OPAL_THREAD_LOCK(&fh->f_lock);
375+
if (true == fp->f_split_coll_in_use) {
376+
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
377+
OPAL_THREAD_UNLOCK(&fh->f_lock);
378+
return MPI_ERR_OTHER;
376379
}
377-
/* No need for locking fh->f_lock, that is done in file_iwrite_all */
378-
ret = mca_io_ompio_file_iwrite_all ( fh, buf, count, datatype, &fp->f_split_coll_req );
379380
fp->f_split_coll_in_use = true;
381+
OPAL_THREAD_UNLOCK(&fh->f_lock);
382+
383+
/* No need for locking fh->f_lock the operation itself, that is done in io_ompio_file_iwrite_all */
384+
ret = mca_io_ompio_file_iwrite_all ( fh, buf, count, datatype, &fp->f_split_coll_req );
380385

381386
return ret;
382387
}
@@ -412,14 +417,15 @@ int mca_io_ompio_file_write_at_all_begin (ompi_file_t *fh,
412417
data = (mca_common_ompio_data_t *) fh->f_io_selected_data;
413418
fp = &data->ompio_fh;
414419

415-
if ( true == fp->f_split_coll_in_use ) {
416-
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
417-
return MPI_ERR_REQUEST;
418-
}
419420
OPAL_THREAD_LOCK(&fh->f_lock);
421+
if (true == fp->f_split_coll_in_use) {
422+
printf("Only one split collective I/O operation allowed per file handle at any given point in time!\n");
423+
OPAL_THREAD_UNLOCK(&fh->f_lock);
424+
return MPI_ERR_OTHER;
425+
}
426+
fp->f_split_coll_in_use = true;
420427
ret = mca_common_ompio_file_iwrite_at_all ( fp, offset, buf, count, datatype, &fp->f_split_coll_req );
421428
OPAL_THREAD_UNLOCK(&fh->f_lock);
422-
fp->f_split_coll_in_use = true;
423429

424430
return ret;
425431
}

0 commit comments

Comments
 (0)