From 217dcca853f3bfc438924be83e993f357e1dc10c Mon Sep 17 00:00:00 2001 From: Edgar Gabriel Date: Wed, 29 Jul 2015 17:10:39 -0500 Subject: [PATCH] - the memory chunk that has to be allocated for the llapi_get_stripe function seems to have changed compared to earlier version. This implementation now follows the code snipplet from the man pages. - implementation of file_get_size and set_size --- ompi/mca/fs/lustre/fs_lustre_file_get_size.c | 13 +++++++++++-- ompi/mca/fs/lustre/fs_lustre_file_set_size.c | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ompi/mca/fs/lustre/fs_lustre_file_get_size.c b/ompi/mca/fs/lustre/fs_lustre_file_get_size.c index 46ac3d58a5..e6e2a51422 100644 --- a/ompi/mca/fs/lustre/fs_lustre_file_get_size.c +++ b/ompi/mca/fs/lustre/fs_lustre_file_get_size.c @@ -33,9 +33,18 @@ * Returns: - Success if size is get */ int -mca_fs_lustre_file_get_size (mca_io_ompio_file_t *file_handle, +mca_fs_lustre_file_get_size (mca_io_ompio_file_t *fh, OMPI_MPI_OFFSET_TYPE *size) { - printf ("LUSTRE GET SIZE\n"); + *size = lseek(fh->fd, 0, SEEK_END); + if (-1 == *size) { + perror ("lseek"); + return OMPI_ERROR; + } + + if (-1 == (lseek(fh->fd, fh->f_offset, SEEK_SET))) { + perror ("lseek"); + return OMPI_ERROR; + } return OMPI_SUCCESS; } diff --git a/ompi/mca/fs/lustre/fs_lustre_file_set_size.c b/ompi/mca/fs/lustre/fs_lustre_file_set_size.c index 4c22f70587..5c2d6b1eb5 100644 --- a/ompi/mca/fs/lustre/fs_lustre_file_set_size.c +++ b/ompi/mca/fs/lustre/fs_lustre_file_set_size.c @@ -33,9 +33,21 @@ * Returns: - Success if size is set */ int -mca_fs_lustre_file_set_size (mca_io_ompio_file_t *file_handle, +mca_fs_lustre_file_set_size (mca_io_ompio_file_t *fh, OMPI_MPI_OFFSET_TYPE size) { - printf ("LUSTRE SET SIZE\n"); + int err = 0; + + err = ftruncate(fh->fd, size); + + fh->f_comm->c_coll.coll_bcast (&err, + 1, + MPI_INT, + OMPIO_ROOT, + fh->f_comm, + fh->f_comm->c_coll.coll_bcast_module); + if (-1 == err) { + return OMPI_ERROR; + } return OMPI_SUCCESS; }