⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ad_panfs_open.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 2 页
字号:
/* -*- Mode: C; c-basic-offset:4 ; -*- *//*  *   ad_panfs_open.c * *   Copyright (C) 2001 University of Chicago. *   See COPYRIGHT notice in top-level directory. */#include "ad_panfs.h"#include <string.h>#include <pan_fs_client_cw_mode.h>#define TEMP_BUFFER_SIZE 64void ADIOI_PANFS_Open(ADIO_File fd, int *error_code){    char* value;    int perm, old_mask, amode, flag;    static char myname[] = "ADIOI_PANFS_OPEN";    if (fd->perm == ADIO_PERM_NULL) {        old_mask = umask(022);        umask(old_mask);        perm = ~old_mask & 0666;    }    else perm = fd->perm;    amode = 0;    if (fd->access_mode & ADIO_CREATE)    {        pan_fs_client_layout_agg_type_t layout_type = PAN_FS_CLIENT_LAYOUT_TYPE__DEFAULT;        unsigned long int layout_stripe_unit = 0;        unsigned long int layout_parity_stripe_width = 0;        unsigned long int layout_parity_stripe_depth = 0;         unsigned long int layout_total_num_comps = 0;        pan_fs_client_layout_visit_t layout_visit_policy  = PAN_FS_CLIENT_LAYOUT_VISIT__ROUND_ROBIN;        int myrank;        MPI_Comm_rank(fd->comm, &myrank);        *error_code = MPI_SUCCESS;        value = (char *) ADIOI_Malloc((MPI_MAX_INFO_VAL+1)*sizeof(char));        MPI_Info_get(fd->info, "panfs_layout_type", MPI_MAX_INFO_VAL,                  value, &flag);        if (flag) {            layout_type = strtoul(value,NULL,10);        }        MPI_Info_get(fd->info, "panfs_layout_stripe_unit", MPI_MAX_INFO_VAL,                  value, &flag);        if (flag) {            layout_stripe_unit = strtoul(value,NULL,10);        }        MPI_Info_get(fd->info, "panfs_layout_total_num_comps", MPI_MAX_INFO_VAL,                  value, &flag);        if (flag) {            layout_total_num_comps = strtoul(value,NULL,10);        }        MPI_Info_get(fd->info, "panfs_layout_parity_stripe_width", MPI_MAX_INFO_VAL,                  value, &flag);        if (flag) {            layout_parity_stripe_width = strtoul(value,NULL,10);        }        MPI_Info_get(fd->info, "panfs_layout_parity_stripe_depth", MPI_MAX_INFO_VAL,                  value, &flag);        if (flag) {            layout_parity_stripe_depth = strtoul(value,NULL,10);        }        MPI_Info_get(fd->info, "panfs_layout_visit_policy", MPI_MAX_INFO_VAL,                  value, &flag);        if (flag) {            layout_visit_policy = strtoul(value,NULL,10);        }        ADIOI_Free(value);        amode = amode | O_CREAT;        /* Check for valid set of hints */        if ((layout_type < PAN_FS_CLIENT_LAYOUT_TYPE__DEFAULT) ||           (layout_type > PAN_FS_CLIENT_LAYOUT_TYPE__RAID10))        {            FPRINTF(stderr, "%s: panfs_layout_type is not a valid value: %u.\n", myname, layout_type);            MPI_Abort(MPI_COMM_WORLD, 1);        }        if ((layout_type == PAN_FS_CLIENT_LAYOUT_TYPE__RAID0) &&           ((layout_stripe_unit == 0) || (layout_total_num_comps == 0)))        {            if(layout_stripe_unit == 0)            {                FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_stripe_unit hint which is necessary to specify a valid RAID0 layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);            }            if(layout_total_num_comps == 0)            {                FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_total_num_comps hint which is necessary to specify a valid RAID0 layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);            }            MPI_Abort(MPI_COMM_WORLD, 1);        }        if (layout_type == PAN_FS_CLIENT_LAYOUT_TYPE__RAID1_5_PARITY_STRIPE)        {            if ((layout_stripe_unit == 0) ||               (layout_parity_stripe_width == 0) ||               (layout_parity_stripe_depth == 0) ||               (layout_total_num_comps == 0))            {                if(layout_stripe_unit == 0)                {                    FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_stripe_unit hint which is necessary to specify a valid RAID5 parity stripe layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);                }                if(layout_total_num_comps == 0)                {                    FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_total_num_comps hint which is necessary to specify a valid RAID5 parity stripe layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);                }                if(layout_parity_stripe_width == 0)                {                    FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_parity_stripe_width hint which is necessary to specify a valid RAID5 parity stripe layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);                }                if(layout_parity_stripe_depth == 0)                {                    FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_parity_stripe_depth hint which is necessary to specify a valid RAID5 parity stripe layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);                }                MPI_Abort(MPI_COMM_WORLD, 1);           }           if ((layout_visit_policy < PAN_FS_CLIENT_LAYOUT_VISIT__ROUND_ROBIN) ||              (layout_visit_policy > PAN_FS_CLIENT_LAYOUT_VISIT__ROUND_ROBIN_WITH_HASHED_OFFSET))           {                FPRINTF(stderr, "%s: panfs_layout_visit_policy is not a valid value: %u.\n", myname, layout_visit_policy);                MPI_Abort(MPI_COMM_WORLD, 1);           }        }        if (layout_type == PAN_FS_CLIENT_LAYOUT_TYPE__RAID10)        {            if ((layout_stripe_unit == 0) || (layout_total_num_comps == 0))            {                if(layout_stripe_unit == 0)                {                    FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_stripe_unit hint which is necessary to specify a valid RAID10 layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);                }                if(layout_total_num_comps == 0)                {                    FPRINTF(stderr, "%s: MPI_Info does not contain the panfs_layout_total_num_comps hint which is necessary to specify a valid RAID10 layout to the PAN_FS_CLIENT_LAYOUT_CREATE_FILE ioctl.\n", myname);                }                MPI_Abort(MPI_COMM_WORLD, 1);            }            if ((layout_visit_policy < PAN_FS_CLIENT_LAYOUT_VISIT__ROUND_ROBIN) ||              (layout_visit_policy > PAN_FS_CLIENT_LAYOUT_VISIT__ROUND_ROBIN_WITH_HASHED_OFFSET))            {                FPRINTF(stderr, "%s: panfs_layout_visit_policy is not a valid value: %u.\n", myname, layout_visit_policy);                MPI_Abort(MPI_COMM_WORLD, 1);            }        }        /* Create the file via ioctl() or open(). ADIOI_PANFS_Open's caller          * already optimizes performance by only calling this function with         * ADIO_CREATE on rank 0.  Therefore, we don't need to worry about          * implementing that optimization here. */        if((layout_type == PAN_FS_CLIENT_LAYOUT_TYPE__RAID0) || (layout_type == PAN_FS_CLIENT_LAYOUT_TYPE__RAID1_5_PARITY_STRIPE)                 || (layout_type == PAN_FS_CLIENT_LAYOUT_TYPE__RAID10)) {            pan_fs_client_layout_create_args_t file_create_args;                int fd_dir;            char* slash;            struct stat stat_buf;            int err;            char *value, *path, *file_name_ptr;            /* Check that the file does not exist before             * trying to create it.  The ioctl itself should             * be able to handle this condition.  Currently,             * the ioctl will return successfully if the file             * has been previously created.  Filed bug 33862             * to track the problem.             */            err = stat(fd->filename,&stat_buf);            if((err == -1) && (errno != ENOENT))            {                FPRINTF(stderr,"%s: Unexpected I/O Error calling stat() on PanFS file: %s.\n", myname, strerror(errno));                MPI_Abort(MPI_COMM_WORLD, 1);            }            else if (err == 0)            {                FPRINTF(stderr,"%s: Cannot create PanFS file with ioctl when file already exists.\n", myname);                MPI_Abort(MPI_COMM_WORLD, 1);            }            else            {                /* (err == -1) && (errno == ENOENT) */                /* File does not exist */                path = ADIOI_Strdup(fd->filename);                slash = strrchr(path, '/');                if (!slash)                    ADIOI_Strncpy(path, ".", 2);                else {                    if (slash == path)                         *(path + 1) = '\0';                    else *slash = '\0';                }                /* create PanFS object */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -