00001
00002
00003
00004
00005
00006
00007
00008 #include "ad_gridftp.h"
00009 #include "adioi.h"
00010 #include "adio_extern.h"
00011
00012 globus_mutex_t fcntl_size_lock;
00013 globus_cond_t fcntl_size_cond;
00014 globus_bool_t fcntl_size_done;
00015
00016 void fcntl_size_cb(void *myargs, globus_ftp_client_handle_t *handle,
00017 globus_object_t *error)
00018 {
00019 if (error)
00020 {
00021 FPRINTF(stderr, "%s\n", globus_object_printable_to_string(error));
00022 }
00023 globus_mutex_lock(&fcntl_size_lock);
00024 fcntl_size_done=GLOBUS_TRUE;
00025 globus_cond_signal(&fcntl_size_cond);
00026 globus_mutex_unlock(&fcntl_size_lock);
00027 }
00028
00029 void ADIOI_GRIDFTP_Fcntl(ADIO_File fd, int flag, ADIO_Fcntl_t *fcntl_struct,
00030 int *error_code)
00031 {
00032 MPI_Datatype copy_etype, copy_filetype;
00033 int combiner, i, j, k, filetype_is_contig, err;
00034 ADIOI_Flatlist_node *flat_file;
00035 char myname[]="ADIOI_GRIDFTP_Fcntl";
00036
00037 int myrank, nprocs;
00038
00039 *error_code = MPI_SUCCESS;
00040
00041 MPI_Comm_size(fd->comm, &nprocs);
00042 MPI_Comm_rank(fd->comm, &myrank);
00043
00044 switch(flag) {
00045 case ADIO_FCNTL_GET_FSIZE:
00046 {
00047 globus_result_t result;
00048 globus_off_t fsize=0;
00049
00050 globus_mutex_init(&fcntl_size_lock,GLOBUS_NULL);
00051 globus_cond_init(&fcntl_size_cond,GLOBUS_NULL);
00052 fcntl_size_done=GLOBUS_FALSE;
00053 if ( (result=globus_ftp_client_size(&(gridftp_fh[fd->fd_sys]),
00054 fd->filename,
00055 &(oattr[fd->fd_sys]),
00056 &(fsize),
00057 fcntl_size_cb,
00058 GLOBUS_NULL))!=GLOBUS_SUCCESS )
00059 {
00060 globus_err_handler("globus_ftp_client_size",myname,result);
00061 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00062 MPIR_ERR_RECOVERABLE,
00063 myname, __LINE__, MPI_ERR_IO,
00064 "**io", "**io %s",
00065 globus_object_printable_to_string(globus_error_get(result)));
00066 return;
00067 }
00068 globus_mutex_lock(&fcntl_size_lock);
00069 while ( fcntl_size_done!=GLOBUS_TRUE )
00070 globus_cond_wait(&fcntl_size_lock,&fcntl_size_cond);
00071 globus_mutex_unlock(&fcntl_size_lock);
00072 globus_mutex_destroy(&fcntl_size_lock);
00073 globus_cond_destroy(&fcntl_size_cond);
00074 fcntl_struct->fsize=fsize;
00075 }
00076 *error_code = MPI_SUCCESS;
00077 break;
00078
00079 case ADIO_FCNTL_SET_DISKSPACE:
00080 ADIOI_GEN_Prealloc(fd, fcntl_struct->diskspace, error_code);
00081 break;
00082
00083 case ADIO_FCNTL_SET_ATOMICITY:
00084 default:
00085 *error_code = MPIO_Err_create_code(MPI_SUCCESS,
00086 MPIR_ERR_RECOVERABLE,
00087 myname, __LINE__,
00088 MPI_ERR_ARG,
00089 "**flag", "**flag %d", flag);
00090 }
00091 }