Skip to content

Commit dfd1ed9

Browse files
committed
io/ompio: fix for CID 1645290
move the lock protection to include setting the flag indicating that a split collective is already ongoing. Unify the handling for write_all_begin, write_at_all_begin, read_all_begin, read_at_all_begin (even if coverty only complained about one of them). Signed-off-by: Edgar Gabriel <Edgar.Gabriel@amd.com>
1 parent b8d45a2 commit dfd1ed9

File tree

2 files changed

+34
-20
lines changed

2 files changed

+34
-20
lines changed

ompi/mca/io/ompio/io_ompio_file_read.c

Lines changed: 18 additions & 10 deletions
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

Lines changed: 16 additions & 10 deletions
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)