This source file includes following definitions.
- ADIOI_NFS_Get_shared_fp
1
2
3
4
5
6
7
8 #include "ad_nfs.h"
9
10
11
12
13
14
15 void ADIOI_NFS_Get_shared_fp(ADIO_File fd, ADIO_Offset incr, ADIO_Offset *shared_fp,
16 int *error_code)
17 {
18 ADIO_Offset new_fp;
19 ssize_t err;
20 MPI_Comm dupcommself;
21 static char myname[] = "ADIOI_NFS_GET_SHARED_FP";
22
23 if (fd->shared_fp_fd == ADIO_FILE_NULL) {
24 MPI_Comm_dup(MPI_COMM_SELF, &dupcommself);
25 fd->shared_fp_fd = ADIO_Open(MPI_COMM_SELF, dupcommself,
26 fd->shared_fp_fname,
27 fd->file_system,
28 fd->fns,
29 ADIO_CREATE | ADIO_RDWR | ADIO_DELETE_ON_CLOSE,
30 0, MPI_BYTE, MPI_BYTE, MPI_INFO_NULL,
31 ADIO_PERM_NULL, error_code);
32 if (*error_code != MPI_SUCCESS) return;
33 *shared_fp = 0;
34 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
35 #ifdef ADIOI_MPE_LOGGING
36 MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
37 #endif
38 err = read(fd->shared_fp_fd->fd_sys, shared_fp, sizeof(ADIO_Offset));
39 #ifdef ADIOI_MPE_LOGGING
40 MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
41 #endif
42
43
44
45 }
46 else {
47 ADIOI_WRITE_LOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
48
49 #ifdef ADIOI_MPE_LOGGING
50 MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
51 #endif
52 err = lseek(fd->shared_fp_fd->fd_sys, 0, SEEK_SET);
53 #ifdef ADIOI_MPE_LOGGING
54 MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
55 #endif
56 if (err == 0) {
57 #ifdef ADIOI_MPE_LOGGING
58 MPE_Log_event( ADIOI_MPE_read_a, 0, NULL );
59 #endif
60 err = read(fd->shared_fp_fd->fd_sys, shared_fp,
61 sizeof(ADIO_Offset));
62 #ifdef ADIOI_MPE_LOGGING
63 MPE_Log_event( ADIOI_MPE_read_b, 0, NULL );
64 #endif
65 }
66 if (err == -1) {
67 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
68 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
69 MPIR_ERR_RECOVERABLE, myname,
70 __LINE__, MPI_ERR_IO, "**io",
71 "**io %s", strerror(errno));
72 return;
73 }
74 }
75
76 if (incr == 0) {goto done;}
77
78 new_fp = *shared_fp + incr;
79
80 #ifdef ADIOI_MPE_LOGGING
81 MPE_Log_event( ADIOI_MPE_lseek_a, 0, NULL );
82 #endif
83 err = lseek(fd->shared_fp_fd->fd_sys, 0, SEEK_SET);
84 #ifdef ADIOI_MPE_LOGGING
85 MPE_Log_event( ADIOI_MPE_lseek_b, 0, NULL );
86 #endif
87 if (err == 0) {
88 #ifdef ADIOI_MPE_LOGGING
89 MPE_Log_event( ADIOI_MPE_write_a, 0, NULL );
90 #endif
91 err = write(fd->shared_fp_fd->fd_sys, &new_fp, sizeof(ADIO_Offset));
92 #ifdef ADIOI_MPE_LOGGING
93 MPE_Log_event( ADIOI_MPE_write_b, 0, NULL );
94 #endif
95 }
96 done:
97 ADIOI_UNLOCK(fd->shared_fp_fd, 0, SEEK_SET, sizeof(ADIO_Offset));
98 if (err == -1) {
99 *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE,
100 myname, __LINE__, MPI_ERR_IO,
101 "**io",
102 "**io %s", strerror(errno));
103 }
104 else *error_code = MPI_SUCCESS;
105 }