00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_pfs.h"
00009
00010 void ADIOI_PFS_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code)
00011 {
00012 char *value, *value_in_fd;
00013 int flag, tmp_val, str_factor=-1, str_unit=-1, start_iodev=-1;
00014 struct sattr attr;
00015 int err, myrank, fd_sys, perm, amode, old_mask;
00016
00017 if ( (fd->info) == MPI_INFO_NULL) {
00018
00019
00020 MPI_Info_create(&(fd->info));
00021
00022
00023
00024 if (users_info != MPI_INFO_NULL) {
00025 value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
00026
00027 ADIOI_Info_get(users_info, "striping_factor", MPI_MAX_INFO_VAL,
00028 value, &flag);
00029 if (flag) {
00030 str_factor=atoi(value);
00031 tmp_val = str_factor;
00032 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
00033
00034 if (tmp_val != str_factor) {
00035 MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname,
00036 "striping_factor",
00037 error_code);
00038 return;
00039 }
00040
00041 }
00042
00043 ADIOI_Info_get(users_info, "striping_unit", MPI_MAX_INFO_VAL,
00044 value, &flag);
00045 if (flag) {
00046 str_unit=atoi(value);
00047 tmp_val = str_unit;
00048 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
00049
00050 if (tmp_val != str_unit) {
00051 MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname,
00052 "striping_unit",
00053 error_code);
00054 return;
00055 }
00056
00057 }
00058
00059 ADIOI_Info_get(users_info, "start_iodevice", MPI_MAX_INFO_VAL,
00060 value, &flag);
00061 if (flag) {
00062 start_iodev=atoi(value);
00063 tmp_val = start_iodev;
00064 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
00065
00066 if (tmp_val != start_iodev) {
00067 MPIO_ERR_CREATE_CODE_INFO_NOT_SAME(myname,
00068 "start_iodevice",
00069 error_code);
00070 return;
00071 }
00072
00073 }
00074
00075
00076 if ((str_factor > 0) || (str_unit > 0) || (start_iodev >= 0)) {
00077 MPI_Comm_rank(fd->comm, &myrank);
00078 if (!myrank) {
00079 if (fd->perm == ADIO_PERM_NULL) {
00080 old_mask = umask(022);
00081 umask(old_mask);
00082 perm = old_mask ^ 0666;
00083 }
00084 else perm = fd->perm;
00085
00086 amode = 0;
00087 if (fd->access_mode & ADIO_CREATE)
00088 amode = amode | O_CREAT;
00089 if (fd->access_mode & ADIO_RDONLY)
00090 amode = amode | O_RDONLY;
00091 if (fd->access_mode & ADIO_WRONLY)
00092 amode = amode | O_WRONLY;
00093 if (fd->access_mode & ADIO_RDWR)
00094 amode = amode | O_RDWR;
00095 if (fd->access_mode & ADIO_EXCL)
00096 amode = amode | O_EXCL;
00097
00098 fd_sys = open(fd->filename, amode, perm);
00099 err = fcntl(fd_sys, F_GETSATTR, &attr);
00100
00101 if (!err) {
00102 if (str_unit > 0) attr.s_sunitsize = str_unit;
00103 if ((start_iodev >= 0) &&
00104 (start_iodev < attr.s_sfactor))
00105 attr.s_start_sdir = start_iodev;
00106 if ((str_factor > 0) && (str_factor < attr.s_sfactor))
00107 attr.s_sfactor = str_factor;
00108
00109 err = fcntl(fd_sys, F_SETSATTR, &attr);
00110 }
00111
00112 close(fd_sys);
00113 }
00114
00115 MPI_Barrier(fd->comm);
00116 }
00117
00118
00119
00120
00121
00122 ADIOI_Info_get(users_info, "pfs_svr_buf", MPI_MAX_INFO_VAL,
00123 value, &flag);
00124 if (flag && (!strcmp(value, "true")))
00125 ADIOI_Info_set(fd->info, "pfs_svr_buf", "true");
00126 else ADIOI_Info_set(fd->info, "pfs_svr_buf", "false");
00127
00128 ADIOI_Free(value);
00129 }
00130 else ADIOI_Info_set(fd->info, "pfs_svr_buf", "false");
00131
00132
00133 ADIOI_GEN_SetInfo(fd, users_info, error_code);
00134 }
00135
00136 else {
00137
00138
00139
00140
00141 ADIOI_GEN_SetInfo(fd, users_info, error_code);
00142
00143
00144 if (users_info != MPI_INFO_NULL) {
00145 value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
00146
00147 ADIOI_Info_get(users_info, "pfs_svr_buf", MPI_MAX_INFO_VAL,
00148 value, &flag);
00149 if (flag && (!strcmp(value, "true") || !strcmp(value, "false"))) {
00150 value_in_fd = (char *)
00151 ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
00152 ADIOI_Info_get(fd->info, "pfs_svr_buf", MPI_MAX_INFO_VAL,
00153 value_in_fd, &flag);
00154 if (strcmp(value, value_in_fd)) {
00155 if (!strcmp(value, "true")) {
00156 err = fcntl(fd->fd_sys, F_PFS_SVR_BUF, TRUE);
00157 if (!err)
00158 ADIOI_Info_set(fd->info, "pfs_svr_buf", "true");
00159 }
00160 else {
00161 err = fcntl(fd->fd_sys, F_PFS_SVR_BUF, FALSE);
00162 if (!err)
00163 ADIOI_Info_set(fd->info, "pfs_svr_buf", "false");
00164 }
00165 }
00166 ADIOI_Free(value_in_fd);
00167 }
00168 ADIOI_Free(value);
00169 }
00170
00171 }
00172
00173 *error_code = MPI_SUCCESS;
00174 }