|
| 1 | +/* -*- Mode: C; c-basic-offset:4 ; -*- */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana |
| 4 | + * University Research and Technology |
| 5 | + * Corporation. All rights reserved. |
| 6 | + * Copyright (c) 2004-2007 The University of Tennessee and The University |
| 7 | + * of Tennessee Research Foundation. All rights |
| 8 | + * reserved. |
| 9 | + * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, |
| 10 | + * University of Stuttgart. All rights reserved. |
| 11 | + * Copyright (c) 2004-2005 The Regents of the University of California. |
| 12 | + * All rights reserved. |
| 13 | + * Copyright (c) 2008-2012 University of Houston. All rights reserved. |
| 14 | + * Copyright (c) 2011 Cisco Systems, Inc. All rights reserved. |
| 15 | + * $COPYRIGHT$ |
| 16 | + * |
| 17 | + * Additional copyrights may follow |
| 18 | + * |
| 19 | + * $HEADER$ |
| 20 | + */ |
| 21 | + |
| 22 | +#include "ompi_config.h" |
| 23 | +#include "mpi.h" |
| 24 | +#include "ompi/mca/fs/fs.h" |
| 25 | +#include "ompi/mca/fs/base/base.h" |
| 26 | +#include "ompi/mca/fs/gpfs/fs_gpfs.h" |
| 27 | + |
| 28 | +#ifdef HAVE_SYS_STATFS_H |
| 29 | +#include <sys/statfs.h> /* or <sys/vfs.h> */ |
| 30 | +#endif |
| 31 | +#ifdef HAVE_SYS_PARAM_H |
| 32 | +#include <sys/param.h> |
| 33 | +#endif |
| 34 | +#ifdef HAVE_SYS_MOUNT_H |
| 35 | +#include <sys/mount.h> |
| 36 | +#endif |
| 37 | +#ifdef HAVE_SYS_STAT_H |
| 38 | +#include <sys/stat.h> |
| 39 | +#endif |
| 40 | + |
| 41 | +/* |
| 42 | + * ******************************************************************* |
| 43 | + * ************************ actions structure ************************ |
| 44 | + * ******************************************************************* |
| 45 | + */ |
| 46 | +static mca_fs_base_module_1_0_0_t gpfs = { mca_fs_gpfs_module_init, /* initialize after being selected */ |
| 47 | +mca_fs_gpfs_module_finalize, /* close a module on a communicator */ |
| 48 | +mca_fs_gpfs_file_open, mca_fs_gpfs_file_close, mca_fs_gpfs_file_delete, |
| 49 | + mca_fs_gpfs_file_set_size, mca_fs_gpfs_file_get_size, |
| 50 | + mca_fs_gpfs_file_set_info, mca_fs_gpfs_file_sync }; |
| 51 | +/* |
| 52 | + * ******************************************************************* |
| 53 | + * ************************* structure ends ************************** |
| 54 | + * ******************************************************************* |
| 55 | + */ |
| 56 | + |
| 57 | +int mca_fs_gpfs_component_init_query(bool enable_progress_threads, |
| 58 | + bool enable_mpi_threads) { |
| 59 | + /* Nothing to do */ |
| 60 | + |
| 61 | + return OMPI_SUCCESS; |
| 62 | +} |
| 63 | + |
| 64 | +struct mca_fs_base_module_1_0_0_t * |
| 65 | +mca_fs_gpfs_component_file_query(mca_io_ompio_file_t *fh, int *priority) { |
| 66 | + int err; |
| 67 | + char *dir; |
| 68 | + struct statfs fsbuf; |
| 69 | + char *tmp; |
| 70 | + |
| 71 | + /* The code in this function is based on the ADIO FS selection in ROMIO |
| 72 | + * Copyright (C) 1997 University of Chicago. |
| 73 | + * See COPYRIGHT notice in top-level directory. |
| 74 | + */ |
| 75 | + *priority = mca_fs_gpfs_priority; |
| 76 | + |
| 77 | + tmp = strchr(fh->f_filename, ':'); |
| 78 | + if (!tmp) { |
| 79 | + if (OMPIO_ROOT == fh->f_rank) { |
| 80 | + do { |
| 81 | + err = statfs(fh->f_filename, &fsbuf); |
| 82 | + } while (err && (errno == ESTALE)); |
| 83 | + |
| 84 | + if (err && (errno == ENOENT)) { |
| 85 | + mca_fs_base_get_parent_dir(fh->f_filename, &dir); |
| 86 | + err = statfs(dir, &fsbuf); |
| 87 | + free(dir); |
| 88 | + } |
| 89 | + |
| 90 | +#ifndef GPFS_SUPER_MAGIC |
| 91 | +#define GPFS_SUPER_MAGIC 0x47504653 /* Thats GPFS in ASCII */ |
| 92 | +#endif |
| 93 | + if (fsbuf.f_type == GPFS_SUPER_MAGIC) { |
| 94 | + fh->f_fstype = GPFS; |
| 95 | + } |
| 96 | + } |
| 97 | + fh->f_comm->c_coll.coll_bcast(&(fh->f_fstype), 1, |
| 98 | + MPI_INT, |
| 99 | + OMPIO_ROOT, fh->f_comm, fh->f_comm->c_coll.coll_bcast_module); |
| 100 | + } else { |
| 101 | + if (!strncmp(fh->f_filename, "gpfs:", 5) |
| 102 | + || !strncmp(fh->f_filename, "GPFS:", 5)) { |
| 103 | + fh->f_fstype = GPFS; |
| 104 | + } |
| 105 | + } |
| 106 | + |
| 107 | + if (GPFS == fh->f_fstype) { |
| 108 | + if (*priority < 50) { |
| 109 | + *priority = 50; |
| 110 | + return &gpfs; |
| 111 | + } |
| 112 | + } |
| 113 | + |
| 114 | + return NULL; |
| 115 | +} |
| 116 | + |
| 117 | +int mca_fs_gpfs_component_file_unquery(mca_io_ompio_file_t *file) { |
| 118 | + /* This function might be needed for some purposes later. for now it |
| 119 | + * does not have anything to do since there are no steps which need |
| 120 | + * to be undone if this module is not selected */ |
| 121 | + |
| 122 | + return OMPI_SUCCESS; |
| 123 | +} |
| 124 | + |
| 125 | +int mca_fs_gpfs_module_init(mca_io_ompio_file_t *file) { |
| 126 | + return OMPI_SUCCESS; |
| 127 | +} |
| 128 | + |
| 129 | +int mca_fs_gpfs_module_finalize(mca_io_ompio_file_t *file) { |
| 130 | + return OMPI_SUCCESS; |
| 131 | +} |
| 132 | + |
0 commit comments