|
| 1 | +/* |
| 2 | + * Copyright (C) by Argonne National Laboratory |
| 3 | + * See COPYRIGHT in top-level directory |
| 4 | + */ |
| 5 | + |
| 6 | +#include "ad_unify.h" |
| 7 | +#include "ad_unify_common.h" |
| 8 | + |
| 9 | +/* as with ADIOI_PVFS2_Flush, implement the resize operation in a scalable |
| 10 | + * manner. one process does the work, then broadcasts the result to everyone |
| 11 | + * else. fortunately, this operation is defined to be collective */ |
| 12 | +void ADIOI_UNIFY_Resize(ADIO_File fd, ADIO_Offset size, int *error_code) |
| 13 | +{ |
| 14 | + int ret, rank; |
| 15 | + ADIOI_UNIFY_fs *unifyfs_blob = fd->fs_ptr; |
| 16 | + |
| 17 | + *error_code = MPI_SUCCESS; |
| 18 | + |
| 19 | + unifyfs_io_request truncate_req = { |
| 20 | + .gfid = unifyfs_blob->gfid, |
| 21 | + .offset = size, |
| 22 | + .op = UNIFYFS_IOREQ_OP_TRUNC, |
| 23 | + }; |
| 24 | + |
| 25 | + MPI_Comm_rank(fd->comm, &rank); |
| 26 | + |
| 27 | + /* MPI-IO semantics treat conflicting MPI_File_set_size requests the |
| 28 | + * same as conflicting write requests. Thus, a resize from one |
| 29 | + * process does not have to be visible to the other processes until a |
| 30 | + * synchronization point is reached */ |
| 31 | + |
| 32 | + if (rank == fd->hints->ranklist[0]) { |
| 33 | + ret = unifyfs_dispatch_io(unifyfs_blob->fshdl, 1, &truncate_req); |
| 34 | + if (ret != UNIFYFS_SUCCESS) { |
| 35 | + *error_code = MPIO_Err_create_code(MPI_SUCCESS, |
| 36 | + MPIR_ERR_RECOVERABLE, |
| 37 | + __func__, __LINE__, MPI_ERR_IO, "Error in Dispatch:", |
| 38 | + "%s", strerror(ret)); |
| 39 | + goto exit; |
| 40 | + } |
| 41 | + ret = unifyfs_wait_io(unifyfs_blob->fshdl, 1, &truncate_req, 1); |
| 42 | + if (ret != UNIFYFS_SUCCESS) { |
| 43 | + *error_code = MPIO_Err_create_code(MPI_SUCCESS, |
| 44 | + MPIR_ERR_RECOVERABLE, |
| 45 | + __func__, __LINE__, MPI_ERR_IO, "Error in I/O Wait:", |
| 46 | + "%s", strerror(ret)); |
| 47 | + goto exit; |
| 48 | + } |
| 49 | + if (truncate_req.result.error != UNIFYFS_SUCCESS) { |
| 50 | + *error_code = MPIO_Err_create_code(MPI_SUCCESS, |
| 51 | + MPIR_ERR_RECOVERABLE, |
| 52 | + __func__, __LINE__, MPI_ERR_IO, |
| 53 | + "Error in I/O operation:", "%s", |
| 54 | + strerror(truncate_req.result.error)); |
| 55 | + ret = truncate_req.result.error; |
| 56 | + goto exit; |
| 57 | + } |
| 58 | + |
| 59 | + } |
| 60 | + exit: |
| 61 | + MPI_Bcast(&ret, 1, MPI_INT, fd->hints->ranklist[0], fd->comm); |
| 62 | + /* --BEGIN ERROR HANDLING-- */ |
| 63 | + if (ret != 0) { |
| 64 | + *error_code = MPIO_Err_create_code(MPI_SUCCESS, |
| 65 | + MPIR_ERR_RECOVERABLE, |
| 66 | + __func__, __LINE__, |
| 67 | + MPI_ERR_IO, "Error in Unify Truncate", 0); |
| 68 | + return; |
| 69 | + } |
| 70 | + /* --END ERROR HANDLING-- */ |
| 71 | +} |
0 commit comments