00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_piofs.h"
00009
00010 void ADIOI_PIOFS_SetInfo(ADIO_File fd, MPI_Info users_info, int *error_code)
00011 {
00012 piofs_create_t piofs_create;
00013 piofs_statfs_t piofs_statfs;
00014 char *value, *path, *slash;
00015 int flag, tmp_val, str_factor=-1, str_unit=-1, start_iodev=-1;
00016 int err, myrank, perm, old_mask, nioservers;
00017
00018 if ((fd->info) == MPI_INFO_NULL) {
00019
00020
00021 MPI_Info_create(&(fd->info));
00022
00023
00024
00025 if (users_info != MPI_INFO_NULL) {
00026 value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));
00027
00028 ADIOI_Info_get(users_info, "striping_factor", MPI_MAX_INFO_VAL,
00029 value, &flag);
00030 if (flag) {
00031 str_factor=atoi(value);
00032 tmp_val = str_factor;
00033 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
00034 if (tmp_val != str_factor) {
00035 FPRINTF(stderr, "ADIOI_PIOFS_SetInfo: the value for key \"striping_factor\" must be the same on all processes\n");
00036 MPI_Abort(MPI_COMM_WORLD, 1);
00037 }
00038 }
00039
00040 ADIOI_Info_get(users_info, "striping_unit", MPI_MAX_INFO_VAL,
00041 value, &flag);
00042 if (flag) {
00043 str_unit=atoi(value);
00044 tmp_val = str_unit;
00045 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
00046 if (tmp_val != str_unit) {
00047 FPRINTF(stderr, "ADIOI_PIOFS_SetInfo: the value for key \"striping_unit\" must be the same on all processes\n");
00048 MPI_Abort(MPI_COMM_WORLD, 1);
00049 }
00050 }
00051
00052 ADIOI_Info_get(users_info, "start_iodevice", MPI_MAX_INFO_VAL,
00053 value, &flag);
00054 if (flag) {
00055 start_iodev=atoi(value);
00056 tmp_val = start_iodev;
00057 MPI_Bcast(&tmp_val, 1, MPI_INT, 0, fd->comm);
00058 if (tmp_val != start_iodev) {
00059 FPRINTF(stderr, "ADIOI_PIOFS_SetInfo: the value for key \"start_iodevice\" must be the same on all processes\n");
00060 MPI_Abort(MPI_COMM_WORLD, 1);
00061 }
00062 }
00063
00064 ADIOI_Free(value);
00065
00066
00067 if ((str_factor > 0) || (str_unit > 0) || (start_iodev >= 0)) {
00068 MPI_Comm_rank(fd->comm, &myrank);
00069 if (!myrank) {
00070 int len;
00071
00072 if (fd->perm == ADIO_PERM_NULL) {
00073 old_mask = umask(022);
00074 umask(old_mask);
00075 perm = old_mask ^ 0666;
00076 }
00077 else perm = fd->perm;
00078
00079
00080
00081
00082 path = ADIOI_Strdup(fd->filename);
00083 len = strlen(path) + 1;
00084 slash = strrchr(path, '/');
00085 if (!slash) ADIOI_Strncpy(path, ".", len);
00086 else {
00087 if (slash == path) *(path + 1) = '\0';
00088 else *slash = '\0';
00089 }
00090 ADIOI_Strncpy(piofs_statfs.name, path, len);
00091 err = piofsioctl(0, PIOFS_STATFS, &piofs_statfs);
00092 nioservers = (err) ? -1 : piofs_statfs.f_nodes;
00093
00094 ADIOI_Free(path);
00095
00096 str_factor = ADIOI_MIN(nioservers, str_factor);
00097 if (start_iodev >= nioservers) start_iodev = -1;
00098
00099 ADIOI_Strncpy(piofs_create.name, fd->filename, len);
00100 piofs_create.bsu = (str_unit > 0) ? str_unit : -1;
00101 piofs_create.cells = (str_factor > 0) ? str_factor : -1;
00102 piofs_create.permissions = perm;
00103 piofs_create.base_node = (start_iodev >= 0) ?
00104 start_iodev : -1;
00105 piofs_create.flags = 0;
00106
00107 err = piofsioctl(0, PIOFS_CREATE, &piofs_create);
00108 }
00109 MPI_Barrier(fd->comm);
00110 }
00111 }
00112 }
00113
00114
00115 ADIOI_GEN_SetInfo(fd, users_info, error_code);
00116
00117 *error_code = MPI_SUCCESS;
00118 }