root/ompi/mca/fs/ime/fs_ime.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. mca_fs_ime_component_init_query
  2. mca_fs_ime_component_file_query
  3. mca_fs_ime_component_file_unquery
  4. mca_fs_ime_module_init
  5. mca_fs_ime_module_finalize
  6. mca_fs_ime_get_mpi_err
  7. mca_fs_ime_native_fini

   1 /*
   2  * Copyright (c) 2018      DataDirect Networks. All rights reserved.
   3  * $COPYRIGHT$
   4  *
   5  * Additional copyrights may follow
   6  *
   7  * $HEADER$
   8  */
   9 
  10 #include "ime_native.h"
  11 
  12 #include "ompi_config.h"
  13 #include "mpi.h"
  14 #include "ompi/mca/fs/fs.h"
  15 #include "ompi/mca/fs/base/base.h"
  16 #include "ompi/mca/fs/ime/fs_ime.h"
  17 
  18 /*
  19  * *******************************************************************
  20  * ************************ actions structure ************************
  21  * *******************************************************************
  22  */
  23 static mca_fs_base_module_1_0_0_t ime =  {
  24     mca_fs_ime_module_init, /* initalise after being selected */
  25     mca_fs_ime_module_finalize, /* close a module on a communicator */
  26     mca_fs_ime_file_open,
  27     mca_fs_ime_file_close,
  28     mca_fs_ime_file_delete,
  29     mca_fs_ime_file_set_size,
  30     mca_fs_ime_file_get_size,
  31     mca_fs_ime_file_sync
  32 };
  33 /*
  34  * *******************************************************************
  35  * ************************* structure ends **************************
  36  * *******************************************************************
  37  */
  38 
  39 /*
  40  * Private variables
  41  */
  42 static int mca_fs_ime_IS_INITIALIZED = 0;
  43 
  44 /*
  45  * Function decls
  46  */
  47 int mca_fs_ime_component_init_query(bool enable_progress_threads,
  48                                       bool enable_mpi_threads)
  49 {
  50     /* Nothing to do */
  51 
  52    return OMPI_SUCCESS;
  53 }
  54 
  55 struct mca_fs_base_module_1_0_0_t *
  56 mca_fs_ime_component_file_query (ompio_file_t *fh, int *priority)
  57 {
  58     /* IME should only be used for paths starting with ime: or IME:
  59        Therefore, this function will return a NULL module when no IME
  60        path is detected. */
  61 
  62     char *tmp;
  63 
  64     *priority = mca_fs_ime_priority;
  65 
  66     tmp = strchr (fh->f_filename, ':');
  67     if (!tmp) {
  68         /* The communicator might be NULL if we only want to delete the file */
  69         if (OMPIO_ROOT == fh->f_rank || MPI_COMM_NULL == fh->f_comm) {
  70             fh->f_fstype = mca_fs_base_get_fstype ( fh->f_filename );
  71         }
  72         if (fh->f_comm != MPI_COMM_NULL) {
  73             fh->f_comm->c_coll->coll_bcast (&(fh->f_fstype),
  74                                             1,
  75                                             MPI_INT,
  76                                             OMPIO_ROOT,
  77                                             fh->f_comm,
  78                                             fh->f_comm->c_coll->coll_bcast_module);
  79         }
  80     }
  81     else {
  82         if (!strncmp(fh->f_filename, DEFAULT_IME_PREFIX_NO_FWD_SLASH, 
  83                      IME_FILE_PREFIX_LEN_NO_FWD_SLASH)){
  84             fh->f_fstype = IME;
  85         }
  86     }
  87 
  88     /* According to my understanding, a valid module should be returned
  89        as long as a valid FS type is detected. (This isn't what is done
  90        for LUSTRE or PVFS2)
  91      */
  92     if (IME == fh->f_fstype) {
  93         if (*priority < FS_IME_INCREASED_PRIORITY) {
  94             *priority = FS_IME_INCREASED_PRIORITY;
  95         }
  96         return &ime;
  97     }
  98 
  99    return NULL;
 100 }
 101 
 102 int mca_fs_ime_component_file_unquery (ompio_file_t *file)
 103 {
 104    /* This function might be needed for some purposes later. for now it
 105     * does not have anything to do since there are no steps which need
 106     * to be undone if this module is not selected */
 107 
 108    return OMPI_SUCCESS;
 109 }
 110 
 111 int mca_fs_ime_module_init (ompio_file_t *file)
 112 {
 113     /* Make sure the file type is not overwritten by the last queried
 114      * component */
 115     file->f_fstype = IME;
 116 
 117     if (mca_fs_ime_IS_INITIALIZED == 0) {
 118         mca_fs_ime_IS_INITIALIZED = 1;
 119         ime_native_init();
 120     }
 121     return OMPI_SUCCESS;
 122 }
 123 
 124 int mca_fs_ime_module_finalize (ompio_file_t *file)
 125 {
 126     /*
 127      * Nothing to do here:
 128      * We can't finalize IME here because other files might
 129      * still be using it. Instead, IME is finalized when
 130      * the OMPIO component is closed.
 131      */
 132     
 133     return OMPI_SUCCESS;
 134 }
 135 
 136 int mca_fs_ime_get_mpi_err(int errno_val)
 137 {
 138     switch (errno_val) {
 139         case EACCES:
 140             return MPI_ERR_ACCESS;
 141 
 142         case ENAMETOOLONG:
 143             return MPI_ERR_BAD_FILE;
 144 
 145         case ENOENT:
 146             return MPI_ERR_NO_SUCH_FILE;
 147 
 148         case EISDIR:
 149             return MPI_ERR_BAD_FILE;
 150 
 151         case EROFS:
 152             return MPI_ERR_READ_ONLY;
 153 
 154         case EEXIST:
 155             return MPI_ERR_FILE_EXISTS;
 156 
 157         case ENOSPC:
 158             return MPI_ERR_NO_SPACE;
 159 
 160         case EDQUOT:
 161             return MPI_ERR_QUOTA;
 162 
 163         case ETXTBSY:
 164             return MPI_ERR_FILE_IN_USE;
 165 
 166         case EBADF:
 167             return MPI_ERR_FILE;
 168 
 169         default:
 170             return MPI_ERR_OTHER;
 171     }
 172 }
 173 
 174 int mca_fs_ime_native_fini()
 175 {
 176     int ret;
 177     if (mca_fs_ime_IS_INITIALIZED == 0) {
 178         return OMPI_SUCCESS;
 179     }
 180 
 181     /* We don't actually need to reset this variable since
 182         mca_fs_ime_native_fini is only called once:
 183         when OMPIO is closed
 184     */
 185     mca_fs_ime_IS_INITIALIZED = 0;
 186 
 187     ret = ime_native_finalize();
 188     if (ret != 0) {
 189         return OMPI_ERROR;
 190     }
 191     
 192     return OMPI_SUCCESS;

/* [<][>][^][v][top][bottom][index][help] */