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_zoidfs.h"
9 #include "ad_zoidfs_common.h"
10
11 /* we want to be a bit clever here: at scale, if every client sends a
12 * flush request, it will stress the file system with redundant
13 * commit requests. Instead, one process should wait for
14 * everyone to catch up, do the sync, then broadcast the result.
15 */
16
17 void ADIOI_ZOIDFS_Flush(ADIO_File fd, int *error_code)
18 {
19 int ret, rank, dummy=0, dummy_in=0;
20 ADIOI_ZOIDFS_object *zoidfs_obj_ptr;
21 static char myname[] = "ADIOI_ZOIDFS_FLUSH";
22
23 *error_code = MPI_SUCCESS;
24
25 zoidfs_obj_ptr = (ADIOI_ZOIDFS_object*)fd->fs_ptr;
26
27 MPI_Comm_rank(fd->comm, &rank);
28
29 /* collective call to ensure no outstanding write requests. reduce is
30 * slightly less expensvie than barrier */
31 MPI_Reduce(&dummy_in, &dummy, 1, MPI_INT, MPI_SUM,
32 fd->hints->ranklist[0], fd->comm);
33
34 if (rank == fd->hints->ranklist[0]) {
35 ret = zoidfs_commit(zoidfs_obj_ptr, ZOIDFS_NO_OP_HINT);
36 }
37 MPI_Bcast(&ret, 1, MPI_INT, fd->hints->ranklist[0], fd->comm);
38
39 /* --BEGIN ERROR HANDLING-- */
40 if (ret != 0) {
41 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
42 MPIR_ERR_RECOVERABLE,
43 myname, __LINE__,
44 ADIOI_ZOIDFS_error_convert(ret),
45 "Error in zoidfs_commit", 0);
46 }
47 /* --END ERROR HANDLING-- */
48 }
49
50 /*
51 * vim: ts=8 sts=4 sw=4 noexpandtab
52 */