From d3a8d38cc6d1d79ab879a7c4616a40302a56c5af Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Mon, 23 Jan 2017 08:52:28 -0600 Subject: [PATCH] common/ompio: correctly position shared fp in append mode Fixes a bug reported on the mailing list. ompio did only reposition the individual file pointer when the file was opened in append mode. Set the shared file pointer also to point to the end of the file, similarly to the individual file pointer. Signed-off-by: Edgar Gabriel --- .../mca/common/ompio/common_ompio_file_open.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ompi/mca/common/ompio/common_ompio_file_open.c b/ompi/mca/common/ompio/common_ompio_file_open.c index b133b54c5a..6aa8f5de91 100644 --- a/ompi/mca/common/ompio/common_ompio_file_open.c +++ b/ompi/mca/common/ompio/common_ompio_file_open.c @@ -9,7 +9,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2008-2016 University of Houston. All rights reserved. + * Copyright (c) 2008-2017 University of Houston. All rights reserved. * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. @@ -204,10 +204,28 @@ int mca_common_ompio_file_open (ompi_communicator_t *comm, file pointer of OMPIO to the very end of the file. */ if ( ompio_fh->f_amode & MPI_MODE_APPEND ) { OMPI_MPI_OFFSET_TYPE current_size; + mca_sharedfp_base_module_t * shared_fp_base_module; ompio_fh->f_fs->fs_file_get_size( ompio_fh, ¤t_size); mca_common_ompio_set_explicit_offset (ompio_fh, current_size); + if ( true == use_sharedfp ) { + if ( NULL != ompio_fh->f_sharedfp && + (!mca_io_ompio_sharedfp_lazy_open || + !strcmp (ompio_fh->f_sharedfp_component->mca_component_name, + "addproc") )) { + + shared_fp_base_module = ompio_fh->f_sharedfp; + ret = shared_fp_base_module->sharedfp_seek(ompio_fh,current_size, MPI_SEEK_SET); + } + else { + opal_output(1, "mca_common_ompio_file_open: Could not adjust position of " + "shared file pointer whith MPI_MODE_APPEND\n"); + ret = MPI_ERR_OTHER; + goto fn_fail; + } + } + }