1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2017 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2008-2016 University of Houston. All rights reserved.
13 * Copyright (c) 2018 Research Organization for Information Science
14 * and Technology (RIST). All rights reserved.
15 * Copyright (c) 2018 DataDirect Networks. All rights reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 *
22 * These symbols are in a file by themselves to provide nice linker
23 * semantics. Since linkers generally pull in symbols by object fules,
24 * keeping these symbols as the only symbols in this file prevents
25 * utility programs such as "ompi_info" from having to import entire
26 * modules just to query their version and parameters
27 */
28
29
30 #include "ompi_config.h"
31 #include "mpi.h"
32 #include "ompi/mca/fs/fs.h"
33 #include "ompi/mca/fs/base/base.h"
34 #include "ompi/mca/fs/pvfs2/fs_pvfs2.h"
35
36 #ifdef HAVE_SYS_STATFS_H
37 #include <sys/statfs.h> /* or <sys/vfs.h> */
38 #endif
39 #ifdef HAVE_SYS_PARAM_H
40 #include <sys/param.h>
41 #endif
42 #ifdef HAVE_SYS_MOUNT_H
43 #include <sys/mount.h>
44 #endif
45 #ifdef HAVE_SYS_STAT_H
46 #include <sys/stat.h>
47 #endif
48
49 /*
50 * *******************************************************************
51 * ************************ actions structure ************************
52 * *******************************************************************
53 */
54 static mca_fs_base_module_1_0_0_t pvfs2 = {
55 mca_fs_pvfs2_module_init, /* initalise after being selected */
56 mca_fs_pvfs2_module_finalize, /* close a module on a communicator */
57 mca_fs_pvfs2_file_open,
58 mca_fs_pvfs2_file_close,
59 mca_fs_pvfs2_file_delete,
60 mca_fs_pvfs2_file_set_size,
61 mca_fs_pvfs2_file_get_size,
62 mca_fs_pvfs2_file_sync
63 };
64 /*
65 * *******************************************************************
66 * ************************* structure ends **************************
67 * *******************************************************************
68 */
69
70 int mca_fs_pvfs2_component_init_query(bool enable_progress_threads,
71 bool enable_mpi_threads)
72 {
73 /* Nothing to do */
74
75 return OMPI_SUCCESS;
76 }
77
78 struct mca_fs_base_module_1_0_0_t *
79 mca_fs_pvfs2_component_file_query (ompio_file_t *fh, int *priority)
80 {
81
82 /* The code in this function is based on the ADIO FS selection in ROMIO
83 * Copyright (C) 1997 University of Chicago.
84 * See COPYRIGHT notice in top-level directory.
85 */
86
87 char *tmp;
88
89 /* The code in this function is based on the ADIO FS selection in ROMIO
90 * Copyright (C) 1997 University of Chicago.
91 * See COPYRIGHT notice in top-level directory.
92 */
93
94 *priority = mca_fs_pvfs2_priority;
95
96 tmp = strchr (fh->f_filename, ':');
97 if (!tmp) {
98 /* The communicator might be NULL if we only want to delete the file */
99 if (OMPIO_ROOT == fh->f_rank || MPI_COMM_NULL == fh->f_comm) {
100 fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
101 }
102 if (fh->f_comm != MPI_COMM_NULL) {
103 fh->f_comm->c_coll->coll_bcast (&(fh->f_fstype),
104 1,
105 MPI_INT,
106 OMPIO_ROOT,
107 fh->f_comm,
108 fh->f_comm->c_coll->coll_bcast_module);
109 }
110 }
111 else {
112 if (!strncmp(fh->f_filename, "pvfs2:", 6) ||
113 !strncmp(fh->f_filename, "PVFS2:", 6)) {
114 fh->f_fstype = PVFS2;
115 }
116 }
117
118 if (PVFS2 == fh->f_fstype) {
119 if (*priority < 50) {
120 *priority = 50;
121 return &pvfs2;
122 }
123 }
124
125 return NULL;
126 }
127
128 int mca_fs_pvfs2_component_file_unquery (ompio_file_t *file)
129 {
130 /* This function might be needed for some purposes later. for now it
131 * does not have anything to do since there are no steps which need
132 * to be undone if this module is not selected */
133
134 return OMPI_SUCCESS;
135 }
136
137 int mca_fs_pvfs2_module_init (ompio_file_t *file)
138 {
139 /* Make sure the file type is not overwritten by the last queried
140 * component */
141 file->f_fstype = PVFS2;
142 return OMPI_SUCCESS;
143 }
144
145
146 int mca_fs_pvfs2_module_finalize (ompio_file_t *file)
147 {
148 return OMPI_SUCCESS;
149 }