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-2017 University of Houston. All rights reserved.
13 * $COPYRIGHT$
14 *
15 * Additional copyrights may follow
16 *
17 * $HEADER$
18 *
19 * These symbols are in a file by themselves to provide nice linker
20 * semantics. Since linkers generally pull in symbols by object fules,
21 * keeping these symbols as the only symbols in this file prevents
22 * utility programs such as "ompi_info" from having to import entire
23 * modules just to query their version and parameters
24 */
25
26 #include "ompi_config.h"
27 #include "mpi.h"
28 #include "ompi/mca/fs/fs.h"
29 #include "ompi/mca/fs/base/base.h"
30 #include "ompi/mca/fs/lustre/fs_lustre.h"
31
32 #ifdef HAVE_SYS_STATFS_H
33 #include <sys/statfs.h> /* or <sys/vfs.h> */
34 #endif
35 #ifdef HAVE_SYS_PARAM_H
36 #include <sys/param.h>
37 #endif
38 #ifdef HAVE_SYS_MOUNT_H
39 #include <sys/mount.h>
40 #endif
41 #ifdef HAVE_SYS_STAT_H
42 #include <sys/stat.h>
43 #endif
44
45 #include <sys/ioctl.h>
46
47 /*
48 * *******************************************************************
49 * ************************ actions structure ************************
50 * *******************************************************************
51 */
52 static mca_fs_base_module_1_0_0_t lustre = {
53 mca_fs_lustre_module_init, /* initalise after being selected */
54 mca_fs_lustre_module_finalize, /* close a module on a communicator */
55 mca_fs_lustre_file_open,
56 mca_fs_lustre_file_close,
57 mca_fs_lustre_file_delete,
58 mca_fs_lustre_file_set_size,
59 mca_fs_lustre_file_get_size,
60 mca_fs_lustre_file_sync
61 };
62 /*
63 * *******************************************************************
64 * ************************* structure ends **************************
65 * *******************************************************************
66 */
67
mca_fs_lustre_component_init_query(bool enable_progress_threads,bool enable_mpi_threads)68 int mca_fs_lustre_component_init_query(bool enable_progress_threads,
69 bool enable_mpi_threads)
70 {
71 /* Nothing to do */
72
73 return OMPI_SUCCESS;
74 }
75
76 struct mca_fs_base_module_1_0_0_t *
mca_fs_lustre_component_file_query(mca_io_ompio_file_t * fh,int * priority)77 mca_fs_lustre_component_file_query (mca_io_ompio_file_t *fh, int *priority)
78 {
79 char *tmp;
80
81 /* The code in this function is based on the ADIO FS selection in ROMIO
82 * Copyright (C) 1997 University of Chicago.
83 * See COPYRIGHT notice in top-level directory.
84 */
85
86 *priority = mca_fs_lustre_priority;
87
88 tmp = strchr (fh->f_filename, ':');
89 if (!tmp) {
90 if (OMPIO_ROOT == fh->f_rank) {
91 fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
92 }
93 fh->f_comm->c_coll->coll_bcast (&(fh->f_fstype),
94 1,
95 MPI_INT,
96 OMPIO_ROOT,
97 fh->f_comm,
98 fh->f_comm->c_coll->coll_bcast_module);
99 }
100 else {
101 if (!strncmp(fh->f_filename, "lustre:", 7) ||
102 !strncmp(fh->f_filename, "LUSTRE:", 7)) {
103 fh->f_fstype = LUSTRE;
104 }
105 }
106
107 if (LUSTRE == fh->f_fstype) {
108 if (*priority < 50) {
109 *priority = 50;
110 return &lustre;
111 }
112 }
113
114 return NULL;
115 }
116
mca_fs_lustre_component_file_unquery(mca_io_ompio_file_t * file)117 int mca_fs_lustre_component_file_unquery (mca_io_ompio_file_t *file)
118 {
119 /* This function might be needed for some purposes later. for now it
120 * does not have anything to do since there are no steps which need
121 * to be undone if this module is not selected */
122
123 return OMPI_SUCCESS;
124 }
125
mca_fs_lustre_module_init(mca_io_ompio_file_t * file)126 int mca_fs_lustre_module_init (mca_io_ompio_file_t *file)
127 {
128 /* Make sure the file type is not overwritten by the last queried
129 * component */
130 file->f_fstype = LUSTRE;
131 return OMPI_SUCCESS;
132 }
133
134
mca_fs_lustre_module_finalize(mca_io_ompio_file_t * file)135 int mca_fs_lustre_module_finalize (mca_io_ompio_file_t *file)
136 {
137 return OMPI_SUCCESS;
138 }
139