📄 io_romio_ad_gridftp_open.c
字号:
globus_err_handler("globus_ftp_client_operationattr_set_tcp_buffer",myname,result); } } MPI_Info_get(fd->info,"transfer_type",MPI_MAX_INFO_VAL,hintval,&keyfound); if ( keyfound ) { globus_ftp_control_type_t filetype; /* set transfer type (i.e. ASCII or binary) */ if ( !strcmp("ascii",hintval) || !strcmp("ASCII",hintval) ) { filetype=GLOBUS_FTP_CONTROL_TYPE_ASCII; } else { filetype=GLOBUS_FTP_CONTROL_TYPE_IMAGE; } if ( (result=globus_ftp_client_operationattr_set_type(&(oattr[fd->fd_sys]),filetype))!=GLOBUS_SUCCESS ) globus_err_handler("globus_ftp_client_operationattr_set_type",myname,result); } } else FPRINTF(stderr,"no MPI_Info object associated with %s\n",fd->filename); /* Create the ftp handle */ result=globus_ftp_client_handle_init(&(gridftp_fh[fd->fd_sys]),&hattr); if ( result != GLOBUS_SUCCESS ) { globus_err_handler("globus_ftp_client_handle_init",myname,result); fd->fd_sys = -1; *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", globus_object_printable_to_string(globus_error_get(result))); return; } /* Check for existence of the file */ globus_mutex_init(&lock, GLOBUS_NULL); globus_cond_init(&cond, GLOBUS_NULL); file_exists=GLOBUS_FALSE; exists_done=GLOBUS_FALSE; if ( myrank==0 ) { if ( (result=globus_ftp_client_exists(&(gridftp_fh[fd->fd_sys]), fd->filename, &(oattr[fd->fd_sys]), exists_cb, GLOBUS_NULL))!=GLOBUS_SUCCESS ) { globus_err_handler("globus_ftp_client_exists",myname,result); fd->fd_sys = -1; *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", globus_object_printable_to_string(globus_error_get(result))); return; } /* wait till the callback completes */ globus_mutex_lock(&lock); while ( exists_done!=GLOBUS_TRUE ) globus_cond_wait(&cond,&lock); globus_mutex_unlock(&lock); } MPI_Barrier(fd->comm); MPI_Bcast(&file_exists,1,MPI_INT,0,fd->comm); /* It turns out that this is handled by MPI_File_open() directly */ if ( (file_exists!=GLOBUS_TRUE) && (fd->access_mode&ADIO_CREATE) && !(fd->access_mode&ADIO_EXCL) && !(fd->access_mode&ADIO_RDONLY) ) { if ( myrank==0 ) { /* if the file doesn't exist, write a single NULL to it */ globus_byte_t touchbuf=(globus_byte_t)'\0'; touch_ctl_done=GLOBUS_FALSE; if ( (result=globus_ftp_client_put(&(gridftp_fh[fd->fd_sys]), fd->filename, &(oattr[fd->fd_sys]), GLOBUS_NULL, touch_ctl_cb, GLOBUS_NULL))!=GLOBUS_SUCCESS ) { globus_err_handler("globus_ftp_client_put",myname,result); fd->fd_sys = -1; *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", globus_object_printable_to_string(globus_error_get(result))); return; } result=globus_ftp_client_register_write(&(gridftp_fh[fd->fd_sys]), (globus_byte_t *)&touchbuf, 0, (globus_off_t)0, GLOBUS_TRUE, touch_data_cb, GLOBUS_NULL); if ( result != GLOBUS_SUCCESS ) { globus_err_handler("globus_ftp_client_register_write",myname,result); *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", "**io %s", globus_object_printable_to_string(globus_error_get(result))); return; } globus_mutex_lock(&lock); while ( touch_ctl_done!=GLOBUS_TRUE ) globus_cond_wait(&cond,&lock); globus_mutex_unlock(&lock); } MPI_Barrier(fd->comm); } else if ( (fd->access_mode&ADIO_EXCL) && (file_exists==GLOBUS_TRUE) ) { fd->fd_sys = -1; *error_code = MPIO_Err_create_code(MPI_SUCCESS, MPIR_ERR_RECOVERABLE, myname, __LINE__, MPI_ERR_IO, "**io", 0); return; } else if ( (fd->access_mode&ADIO_RDONLY) && (file_exists!=GLOBUS_TRUE) ) { if ( myrank==0 ) { FPRINTF(stderr,"WARNING: read-only file %s does not exist!\n",fd->filename); } } num_gridftp_handles++; #if 0 /* Debugging info for testing PASV mode behind firewalls */ if ( myrank==0 ) { globus_bool_t striped; globus_ftp_control_mode_t mode; globus_ftp_control_type_t filetype; globus_ftp_control_parallelism_t parallelism; FPRINTF(stderr,"--gridftp details for %s--\n", fd->filename); /* FPRINTF(stderr,"Connection caching: "); globus_ftp_client_handleattr_get_cache_all(&hattr,&cached); if ( cached==GLOBUS_TRUE ) FPRINTF(stderr,"Y\n"); else FPRINTF(stderr,"N\n"); */ FPRINTF(stderr,"Control mode: "); globus_ftp_client_operationattr_get_mode(&(oattr[fd->fd_sys]),&mode); if ( mode==GLOBUS_FTP_CONTROL_MODE_BLOCK ) FPRINTF(stderr,"block\n"); else if ( mode==GLOBUS_FTP_CONTROL_MODE_COMPRESSED ) FPRINTF(stderr,"compressed\n"); else if ( mode==GLOBUS_FTP_CONTROL_MODE_EXTENDED_BLOCK ) FPRINTF(stderr,"extended block\n"); else if ( mode==GLOBUS_FTP_CONTROL_MODE_STREAM ) FPRINTF(stderr,"stream\n"); else FPRINTF(stderr,"unknown\n"); FPRINTF(stderr,"File type: "); globus_ftp_client_operationattr_get_type(&(oattr[fd->fd_sys]),&filetype); if ( filetype==GLOBUS_FTP_CONTROL_TYPE_ASCII ) FPRINTF(stderr,"ASCII\n"); else if ( filetype==GLOBUS_FTP_CONTROL_TYPE_IMAGE ) FPRINTF(stderr,"binary\n"); else if ( filetype==GLOBUS_FTP_CONTROL_TYPE_EBCDIC ) FPRINTF(stderr,"EBCDIC\n"); else FPRINTF(stderr,"unknown\n"); FPRINTF(stderr,"Parallelism: "); globus_ftp_client_operationattr_get_parallelism(&(oattr[fd->fd_sys]),¶llelism); if ( parallelism.mode==GLOBUS_FTP_CONTROL_PARALLELISM_NONE ) FPRINTF(stderr,"none\n"); else if ( parallelism.mode==GLOBUS_FTP_CONTROL_PARALLELISM_FIXED ) FPRINTF(stderr,"fixed with %d streams\n",parallelism.fixed.size); else FPRINTF(stderr,"unknown\n"); FPRINTF(stderr,"Striping: "); globus_ftp_client_operationattr_get_striped(&(oattr[fd->fd_sys]),&striped); if ( striped==GLOBUS_TRUE ) { globus_ftp_control_layout_t layout; FPRINTF(stderr,"Y\nLayout: "); globus_ftp_client_operationattr_get_layout(&(oattr[fd->fd_sys]), &layout); if ( layout.mode==GLOBUS_FTP_CONTROL_STRIPING_NONE ) FPRINTF(stderr,"none\n"); else if ( layout.mode==GLOBUS_FTP_CONTROL_STRIPING_PARTITIONED ) FPRINTF(stderr,"partitioned, size=%d\n",layout.partitioned.size); else if ( layout.mode==GLOBUS_FTP_CONTROL_STRIPING_BLOCKED_ROUND_ROBIN ) FPRINTF(stderr,"round-robin, block size=%d\n",layout.round_robin.block_size); else FPRINTF(stderr,"unknown\n"); } else FPRINTF(stderr,"N\n"); fflush(stderr); }#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -