From 415e76514d0189c8261bf2a795ac26f70fe611be Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Wed, 20 Sep 2017 17:57:57 -0500 Subject: [PATCH] fbtl/posix: make the code compile Signed-off-by: Edgar Gabriel --- ompi/mca/fbtl/posix/fbtl_posix.h | 6 ++++++ ompi/mca/fbtl/posix/fbtl_posix_lock.c | 8 ++++---- ompi/mca/fbtl/posix/fbtl_posix_preadv.c | 10 ++++------ ompi/mca/fbtl/posix/fbtl_posix_pwritev.c | 11 ++++------- ompi/mca/io/ompio/io_ompio.h | 9 +++++++++ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/ompi/mca/fbtl/posix/fbtl_posix.h b/ompi/mca/fbtl/posix/fbtl_posix.h index 9111cba761..b9353a921a 100644 --- a/ompi/mca/fbtl/posix/fbtl_posix.h +++ b/ompi/mca/fbtl/posix/fbtl_posix.h @@ -58,6 +58,11 @@ ssize_t mca_fbtl_posix_ipwritev (mca_io_ompio_file_t *file, bool mca_fbtl_posix_progress ( mca_ompio_request_t *req); void mca_fbtl_posix_request_free ( mca_ompio_request_t *req); +int mca_fbtl_posix_lock ( struct flock *lock, mca_io_ompio_file_t *fh, int op, + OMPI_MPI_OFFSET_TYPE iov_offset, off_t len, int flags); +int mca_fbtl_posix_unlock ( struct flock *lock, mca_io_ompio_file_t *fh ); + + struct mca_fbtl_posix_request_data_t { int aio_req_count; /* total number of aio reqs */ int aio_open_reqs; /* number of unfinished reqs */ @@ -78,6 +83,7 @@ typedef struct mca_fbtl_posix_request_data_t mca_fbtl_posix_request_data_t; #define FBTL_POSIX_READ 1 #define FBTL_POSIX_WRITE 2 + /* * ****************************************************************** * ************ functions implemented in this module end ************ diff --git a/ompi/mca/fbtl/posix/fbtl_posix_lock.c b/ompi/mca/fbtl/posix/fbtl_posix_lock.c index cb0be53709..30551b4424 100644 --- a/ompi/mca/fbtl/posix/fbtl_posix_lock.c +++ b/ompi/mca/fbtl/posix/fbtl_posix_lock.c @@ -35,7 +35,7 @@ */ int mca_fbtl_posix_lock ( struct flock *lock, mca_io_ompio_file_t *fh, int op, - OMPI_MPI_OFFSET_TYPE iov_offset, off_t len, int flags) + OMPI_MPI_OFFSET_TYPE offset, off_t len, int flags) { off_t lmod, bmod; @@ -46,7 +46,7 @@ int mca_fbtl_posix_lock ( struct flock *lock, mca_io_ompio_file_t *fh, int op, if ( fh->f_atomicity || fh->f_flags & OMPIO_LOCK_ALWAYS ) { /* Need to lock the entire region */ - lock->l_start = (off_t) iov_offset; + lock->l_start = (off_t) offset; lock->l_len = len; } else { @@ -67,7 +67,7 @@ int mca_fbtl_posix_lock ( struct flock *lock, mca_io_ompio_file_t *fh, int op, return 0; } if ( OMPIO_LOCK_ENTIRE_REGION ) { - lock->l_start = (off_t) iov_offset; + lock->l_start = (off_t) offset; lock->l_len = len; } else { @@ -80,7 +80,7 @@ int mca_fbtl_posix_lock ( struct flock *lock, mca_io_ompio_file_t *fh, int op, */ bmod = offset % fh->f_fs_block_size; if ( !bmod ) { - lock->l_start = (off_t) iov_offset; + lock->l_start = (off_t) offset; lock->l_len = fh->f_fs_block_size - bmod; } lmod = (offset+len-1)%fh->f_fs_block_size; diff --git a/ompi/mca/fbtl/posix/fbtl_posix_preadv.c b/ompi/mca/fbtl/posix/fbtl_posix_preadv.c index 11d3de02af..cbf9d34fb9 100644 --- a/ompi/mca/fbtl/posix/fbtl_posix_preadv.c +++ b/ompi/mca/fbtl/posix/fbtl_posix_preadv.c @@ -83,24 +83,22 @@ ssize_t mca_fbtl_posix_preadv (mca_io_ompio_file_t *fh ) continue; } } - mca_fbtl_posix_lock ( &lock, fh, F_RDLCK, iov_offset, total_len, OMPIO_LOCK_SELECTIVE ); + mca_fbtl_posix_lock ( &lock, fh, F_RDLCK, iov_offset, total_length, OMPIO_LOCK_SELECTIVE ); #if defined(HAVE_PREADV) ret_code = preadv (fh->fd, iov, iov_count, iov_offset); - if ( 0 < ret_code ) { - bytes_read+=ret_code; - } #else if (-1 == lseek (fh->fd, iov_offset, SEEK_SET)) { opal_output(1, "lseek:%s", strerror(errno)); free(iov); + mca_fbtl_posix_unlock ( &lock, fh ); return OMPI_ERROR; } ret_code = readv (fh->fd, iov, iov_count); +#endif + mca_fbtl_posix_unlock ( &lock, fh ); if ( 0 < ret_code ) { bytes_read+=ret_code; } -#endif - mca_fbtl_posix_unlock ( &lock, fh ); else if ( ret_code == -1 ) { opal_output(1, "readv:%s", strerror(errno)); free(iov); diff --git a/ompi/mca/fbtl/posix/fbtl_posix_pwritev.c b/ompi/mca/fbtl/posix/fbtl_posix_pwritev.c index 9929823185..da7c31e959 100644 --- a/ompi/mca/fbtl/posix/fbtl_posix_pwritev.c +++ b/ompi/mca/fbtl/posix/fbtl_posix_pwritev.c @@ -97,25 +97,22 @@ ssize_t mca_fbtl_posix_pwritev(mca_io_ompio_file_t *fh ) */ - mca_fbtl_posix_lock ( &lock, fh, F_WRLCK, iov_offset, total_len, OMPIO_LOCK_SELECTIVE ); + mca_fbtl_posix_lock ( &lock, fh, F_WRLCK, iov_offset, total_length, OMPIO_LOCK_SELECTIVE ); #if defined (HAVE_PWRITEV) ret_code = pwritev (fh->fd, iov, iov_count, iov_offset); - if ( 0 < ret_code ) { - bytes_written += ret_code; - } - #else if (-1 == lseek (fh->fd, iov_offset, SEEK_SET)) { opal_output(1, "lseek:%s", strerror(errno)); free(iov); + mca_fbtl_posix_unlock ( &lock, fh ); return OMPI_ERROR; } ret_code = writev (fh->fd, iov, iov_count); +#endif + mca_fbtl_posix_unlock ( &lock, fh ); if ( 0 < ret_code ) { bytes_written += ret_code; } -#endif - mca_fbtl_posix_unlock ( &lock, fh ); else if (-1 == ret_code ) { opal_output(1, "writev:%s", strerror(errno)); free (iov); diff --git a/ompi/mca/io/ompio/io_ompio.h b/ompi/mca/io/ompio/io_ompio.h index ee310c9802..07554b21cf 100644 --- a/ompi/mca/io/ompio/io_ompio.h +++ b/ompi/mca/io/ompio/io_ompio.h @@ -64,6 +64,10 @@ OMPI_DECLSPEC extern int mca_io_ompio_coll_timing_info; #define OMPIO_CONTIGUOUS_FVIEW 0x00000010 #define OMPIO_AGGREGATOR_IS_SET 0x00000020 #define OMPIO_SHAREDFP_IS_SET 0x00000040 +#define OMPIO_LOCK_ALWAYS 0x00000080 +#define OMPIO_LOCK_NEVER 0x00000100 +#define OMPIO_LOCK_NOT_THIS_OP 0x00000200 + #define QUEUESIZE 2048 #define MCA_IO_DEFAULT_FILE_VIEW_SIZE 4*1024*1024 @@ -121,6 +125,10 @@ OMPI_DECLSPEC extern int mca_io_ompio_coll_timing_info; #define OMPIO_PROCS_IN_GROUP_TAG 1 #define OMPIO_MERGE_THRESHOLD 0.5 + +#define OMPIO_LOCK_ENTIRE_REGION 10 +#define OMPIO_LOCK_SELECTIVE 11 + /*---------------------------*/ BEGIN_C_DECLS @@ -216,6 +224,7 @@ struct mca_io_ompio_file_t { opal_info_t *f_info; int32_t f_flags; void *f_fs_ptr; + int f_fs_block_size; int f_atomicity; size_t f_stripe_size; int f_stripe_count;