55 * Copyright (c) 2004-2005 The University of Tennessee and The University
66 * of Tennessee Research Foundation. All rights
77 * reserved.
8- * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
8+ * Copyright (c) 2004-2015 High Performance Computing Center Stuttgart,
99 * University of Stuttgart. All rights reserved.
1010 * Copyright (c) 2004-2005 The Regents of the University of California.
1111 * All rights reserved.
4141
4242int
4343mca_fs_gpfs_file_open (struct ompi_communicator_t * comm ,
44- char * filename ,
44+ char * filename ,
4545 int access_mode ,
4646 struct ompi_info_t * info ,
4747 mca_io_ompio_file_t * fh )
@@ -60,35 +60,30 @@ mca_fs_gpfs_file_open (struct ompi_communicator_t *comm,
6060
6161 amode = 0 ;
6262
63- if (access_mode & MPI_MODE_CREATE )
63+ if (access_mode & MPI_MODE_CREATE ) {
6464 amode = amode | O_CREAT ;
65- if (access_mode & MPI_MODE_RDONLY )
65+ }
66+ if (access_mode & MPI_MODE_RDONLY ) {
6667 amode = amode | O_RDONLY ;
67- if (access_mode & MPI_MODE_WRONLY )
68+ }
69+ if (access_mode & MPI_MODE_WRONLY ) {
6870 amode = amode | O_WRONLY ;
69- if (access_mode & MPI_MODE_RDWR )
71+ }
72+ if (access_mode & MPI_MODE_RDWR ) {
7073 amode = amode | O_RDWR ;
71- if (access_mode & MPI_MODE_EXCL )
74+ }
75+ if (access_mode & MPI_MODE_EXCL ) {
7276 amode = amode | O_EXCL ;
77+ }
78+
79+ //DEBUG: fprintf(stderr, "Opening a file using Linux open() within fs_gpfs_file_open\n");
7380
74- printf ("Opening a file using Linux open() within fs_gpfs_file_open\n" );
75-
76- // for DEBUG
77- //int gdb = 0;
78- //char hostname[256];
79- //gethostname(hostname, sizeof(hostname));
80- //printf("PID %d on %s ready for attach\n", getpid(), hostname);
81- //fflush(stdout);
82- //while (0 == gdb)
83- //sleep(5);
84-
8581 fh -> fd = open (filename , amode , perm );
8682 if (-1 == fh -> fd ) {
8783 return OMPI_ERROR ;
8884 }
8985
9086 fh -> f_amode = access_mode ;
91- //Setting GPFS Hints
9287 mca_fs_gpfs_file_set_info (fh , info );
9388
9489 return OMPI_SUCCESS ;
@@ -107,53 +102,55 @@ mca_fs_gpfs_file_get_amode (ompi_file_t *fh,
107102 return OMPI_SUCCESS ;
108103}
109104
110- int mca_fs_gpfs_file_seek (ompi_file_t * fh , OMPI_MPI_OFFSET_TYPE off , int whence ) {
111- printf ("GPFS FILE SEEK!" );
112- int ret = OMPI_SUCCESS ;
113- mca_io_ompio_data_t * data ;
114- OMPI_MPI_OFFSET_TYPE offset , temp_offset ;
115-
116- data = (mca_io_ompio_data_t * ) fh -> f_io_selected_data ;
117-
118- offset = off * data -> ompio_fh .f_etype_size ;
119-
120- switch (whence ) {
121- case MPI_SEEK_SET :
122- if (offset < 0 ) {
123- return OMPI_ERROR ;
124- }
125- break ;
126- case MPI_SEEK_CUR :
127- offset += data -> ompio_fh .f_position_in_file_view ;
128- offset += data -> ompio_fh .f_disp ;
129- if (offset < 0 ) {
130- return OMPI_ERROR ;
131- }
132- break ;
133- case MPI_SEEK_END :
134- ret = data -> ompio_fh .f_fs -> fs_file_get_size (& data -> ompio_fh ,
135- & temp_offset );
136- offset += temp_offset ;
137- if (offset < 0 || OMPI_SUCCESS != ret ) {
138- return OMPI_ERROR ;
139- }
140- break ;
141- default :
142- return OMPI_ERROR ;
143- }
144-
145- ret = ompi_io_ompio_set_explicit_offset (& data -> ompio_fh , offset
146- / data -> ompio_fh .f_etype_size );
147- return ret ;
105+ //CN: Is mca_fs_gpfs_file_seek needed at all. Not used anywhere!
106+ int
107+ mca_fs_gpfs_file_seek (ompi_file_t * fh , OMPI_MPI_OFFSET_TYPE off , int whence ) {
108+ //DEBUG: fprintf(stderr, "GPFS FILE SEEK!");
109+ int ret = OMPI_SUCCESS ;
110+ mca_io_ompio_data_t * data ;
111+ OMPI_MPI_OFFSET_TYPE offset , temp_offset ;
112+
113+ data = (mca_io_ompio_data_t * ) fh -> f_io_selected_data ;
114+
115+ offset = off * data -> ompio_fh .f_etype_size ;
116+
117+ switch (whence ) {
118+ case MPI_SEEK_SET :
119+ if (offset < 0 ) {
120+ return OMPI_ERROR ;
121+ }
122+ break ;
123+ case MPI_SEEK_CUR :
124+ offset += data -> ompio_fh .f_position_in_file_view ;
125+ offset += data -> ompio_fh .f_disp ;
126+ if (offset < 0 ) {
127+ return OMPI_ERROR ;
128+ }
129+ break ;
130+ case MPI_SEEK_END :
131+ ret = data -> ompio_fh .f_fs -> fs_file_get_size (& data -> ompio_fh ,
132+ & temp_offset );
133+ offset += temp_offset ;
134+ if (offset < 0 || OMPI_SUCCESS != ret ) {
135+ return OMPI_ERROR ;
136+ }
137+ break ;
138+ default :
139+ return OMPI_ERROR ;
140+ }
141+
142+ ret = ompi_io_ompio_set_explicit_offset (& data -> ompio_fh , offset
143+ / data -> ompio_fh .f_etype_size );
144+ return ret ;
148145}
149146
150147int mca_fs_gpfs_file_get_position (ompi_file_t * fh , OMPI_MPI_OFFSET_TYPE * offset ) {
151- mca_io_ompio_data_t * data ;
148+ mca_io_ompio_data_t * data ;
152149
153- data = (mca_io_ompio_data_t * ) fh -> f_io_selected_data ;
150+ data = (mca_io_ompio_data_t * ) fh -> f_io_selected_data ;
154151
155- * offset = data -> ompio_fh .f_position_in_file_view
156- / data -> ompio_fh .f_etype_size ;
152+ * offset = data -> ompio_fh .f_position_in_file_view
153+ / data -> ompio_fh .f_etype_size ;
157154
158- return OMPI_SUCCESS ;
155+ return OMPI_SUCCESS ;
159156}
0 commit comments