root/ompi/mca/io/romio321/romio/adio/ad_pfs/ad_pfs_hints.c

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

DEFINITIONS

This source file includes following definitions.
  1. ADIOI_PFS_SetInfo

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
   2 /* 
   3  *
   4  *   Copyright (C) 1997 University of Chicago. 
   5  *   See COPYRIGHT notice in top-level directory.
   6  */
   7 
   8 #include "ad_pfs.h"
   9 
  10 void ADIOI_PFS_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code)
  11 {
  12     char *value, *value_in_fd;
  13     int flag, tmp_val, str_factor=-1, str_unit=-1, start_iodev=-1;
  14     struct sattr attr;
  15     int err, myrank, fd_sys, perm, amode, old_mask;
  16 
  17     if ( (fd->info) == MPI_INFO_NULL) {
  18         /* This must be part of the open call. can set striping parameters 
  19            if necessary. */ 
  20         MPI_Info_create(&(fd->info));
  21         
  22         /* has user specified striping or server buffering parameters 
  23            and do they have the same value on all processes? */
  24         if (users_info != MPI_INFO_NULL) {
  25             value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
  26 
  27             ADIOI_Info_get(users_info, "striping_factor", MPI_MAX_INFO_VAL, 
  28                          value, &flag);
  29             if (flag) {
  30                 str_factor=atoi(value);
  31                 tmp_val = str_factor;
  32                 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
  33                 /* --BEGIN ERROR HANDLING-- */
  34                 if (tmp_val != str_factor) {
  35                     MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname,
  36                                                        "striping_factor",
  37                                                        error_code);
  38                     return;
  39                 }
  40                 /* --END ERROR HANDLING-- */
  41             }
  42 
  43             ADIOI_Info_get(users_info, "striping_unit", MPI_MAX_INFO_VAL, 
  44                          value, &flag);
  45             if (flag) {
  46                 str_unit=atoi(value);
  47                 tmp_val = str_unit;
  48                 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
  49                 /* --BEGIN ERROR HANDLING-- */
  50                 if (tmp_val != str_unit) {
  51                     MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname,
  52                                                        "striping_unit",
  53                                                        error_code);
  54                     return;
  55                 }
  56                 /* --END ERROR HANDLING-- */
  57             }
  58 
  59             ADIOI_Info_get(users_info, "start_iodevice", MPI_MAX_INFO_VAL, 
  60                          value, &flag);
  61             if (flag) {
  62                 start_iodev=atoi(value);
  63                 tmp_val = start_iodev;
  64                 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
  65                 /* --BEGIN ERROR HANDLING-- */
  66                 if (tmp_val != start_iodev) {
  67                     MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname,
  68                                                        "start_iodevice",
  69                                                        error_code);
  70                     return;
  71                 }
  72                 /* --END ERROR HANDLING-- */
  73             }
  74 
  75          /* if user has specified striping info, process 0 tries to set it */
  76             if ((str_factor > 0) || (str_unit > 0) || (start_iodev >= 0)) {
  77                 MPI_Comm_rank(fd->comm, &myrank);
  78                 if (!myrank) {
  79                     if (fd->perm == ADIO_PERM_NULL) {
  80                         old_mask = umask(022);
  81                         umask(old_mask);
  82                         perm = old_mask ^ 0666;
  83                     }
  84                     else perm = fd->perm;
  85 
  86                     amode = 0;
  87                     if (fd->access_mode & ADIO_CREATE)
  88                         amode = amode | O_CREAT;
  89                     if (fd->access_mode & ADIO_RDONLY)
  90                         amode = amode | O_RDONLY;
  91                     if (fd->access_mode & ADIO_WRONLY)
  92                         amode = amode | O_WRONLY;
  93                     if (fd->access_mode & ADIO_RDWR)
  94                         amode = amode | O_RDWR;
  95                     if (fd->access_mode & ADIO_EXCL)
  96                         amode = amode | O_EXCL;
  97 
  98                     fd_sys = open(fd->filename, amode, perm);
  99                     err = fcntl(fd_sys, F_GETSATTR, &attr);
 100 
 101                     if (!err) {
 102                         if (str_unit > 0) attr.s_sunitsize = str_unit;
 103                         if ((start_iodev >= 0) && 
 104                             (start_iodev < attr.s_sfactor))
 105                             attr.s_start_sdir = start_iodev;
 106                         if ((str_factor > 0) && (str_factor < attr.s_sfactor))
 107                             attr.s_sfactor = str_factor;
 108 
 109                         err = fcntl(fd_sys, F_SETSATTR, &attr);
 110                     }
 111 
 112                     close(fd_sys);
 113                 }
 114 
 115                 MPI_Barrier(fd->comm);
 116             }
 117 
 118             /* Has user asked for pfs server buffering to be turned on?
 119                If so, mark it as true in fd->info and turn it on in 
 120                ADIOI_PFS_Open after the file is opened */
 121 
 122             ADIOI_Info_get(users_info, "pfs_svr_buf", MPI_MAX_INFO_VAL, 
 123                          value, &flag);
 124             if (flag && (!strcmp(value, "true")))
 125                 ADIOI_Info_set(fd->info, "pfs_svr_buf", "true");
 126             else ADIOI_Info_set(fd->info, "pfs_svr_buf", "false");
 127 
 128             ADIOI_Free(value);
 129         }
 130         else ADIOI_Info_set(fd->info, "pfs_svr_buf", "false");
 131         
 132         /* set the values for collective I/O and data sieving parameters */
 133         ADIOI_GEN_SetInfo(fd, users_info, error_code);
 134     }
 135     
 136     else {
 137         /* The file has been opened previously and fd->fd_sys is a valid
 138            file descriptor. cannot set striping parameters now. */
 139         
 140         /* set the values for collective I/O and data sieving parameters */
 141         ADIOI_GEN_SetInfo(fd, users_info, error_code);
 142 
 143         /* has user specified value for pfs_svr_buf? */
 144         if (users_info != MPI_INFO_NULL) {
 145             value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
 146 
 147             ADIOI_Info_get(users_info, "pfs_svr_buf", MPI_MAX_INFO_VAL, 
 148                          value, &flag);
 149             if (flag && (!strcmp(value, "true") || !strcmp(value, "false"))) {
 150                 value_in_fd = (char *) 
 151                           ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
 152                 ADIOI_Info_get(fd->info, "pfs_svr_buf", MPI_MAX_INFO_VAL, 
 153                          value_in_fd, &flag);
 154                 if (strcmp(value, value_in_fd)) {
 155                     if (!strcmp(value, "true")) {
 156                         err = fcntl(fd->fd_sys, F_PFS_SVR_BUF, TRUE);
 157                         if (!err) 
 158                             ADIOI_Info_set(fd->info, "pfs_svr_buf", "true");
 159                     }
 160                     else {
 161                         err = fcntl(fd->fd_sys, F_PFS_SVR_BUF, FALSE);
 162                         if (!err) 
 163                             ADIOI_Info_set(fd->info, "pfs_svr_buf", "false");
 164                     }
 165                 }
 166                 ADIOI_Free(value_in_fd);
 167             }
 168             ADIOI_Free(value);
 169         }
 170 
 171     }
 172     
 173     *error_code = MPI_SUCCESS;
 174 }

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