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