1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3 *
4 * Copyright (C) 1997 University of Chicago.
5 * See COPYRIGHT notice in top-level directory.
6 */
7
8 #include "ad_pvfs2.h"
9 #include "ad_pvfs2_common.h"
10
11 /* as with ADIOI_PVFS2_Flush, implement the resize operation in a scalable
12 * manner. one process does the work, then broadcasts the result to everyone
13 * else. fortunately, this operation is defined to be collective */
14 void ADIOI_PVFS2_Resize(ADIO_File fd, ADIO_Offset size, int *error_code)
15 {
16 int ret, rank;
17 ADIOI_PVFS2_fs *pvfs_fs;
18 static char myname[] = "ADIOI_PVFS2_RESIZE";
19
20 *error_code = MPI_SUCCESS;
21
22 pvfs_fs = (ADIOI_PVFS2_fs*)fd->fs_ptr;
23
24 MPI_Comm_rank(fd->comm, &rank);
25
26 /* We desginate one node in the communicator to be an 'io_worker' in
27 * ADIO_Open. This node can perform operations on files and then
28 * inform the other nodes of the result */
29
30 /* MPI-IO semantics treat conflicting MPI_File_set_size requests the
31 * same as conflicting write requests. Thus, a resize from one
32 * process does not have to be visible to the other processes until a
33 * syncronization point is reached */
34
35 if (rank == fd->hints->ranklist[0]) {
36 ret = PVFS_sys_truncate(pvfs_fs->object_ref,
37 size, &(pvfs_fs->credentials));
38 MPI_Bcast(&ret, 1, MPI_INT, fd->hints->ranklist[0], fd->comm);
39 } else {
40 MPI_Bcast(&ret, 1, MPI_INT, fd->hints->ranklist[0], fd->comm);
41 }
42 /* --BEGIN ERROR HANDLING-- */
43 if (ret != 0) {
44 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
45 MPIR_ERR_RECOVERABLE,
46 myname, __LINE__,
47 ADIOI_PVFS2_error_convert(ret),
48 "Error in PVFS_sys_truncate", 0);
49 return;
50 }
51 /* --END ERROR HANDLING-- */
52 }
53
54 /*
55 * vim: ts=8 sts=4 sw=4 noexpandtab
56 */