@@ -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