int s3_op_internal(ObjectStream* os) { IOBuf* b = &os->iob; __attribute__ ((unused)) AWSContext* ctx = b->context; // run the GET or PUT int is_get = (os->flags & OSF_READING); if (is_get) { LOG(LOG_INFO, "GET '%s/%s/%s'\n", (ctx ? ctx->S3Host : "*"), (ctx ? ctx->Bucket : "*"), os->url); AWS4C_CHECK1( s3_get(b, os->url) ); /* create empty object with user metadata */ } else { LOG(LOG_INFO, "PUT '%s/%s/%s'\n", (ctx ? ctx->S3Host : "*"), (ctx ? ctx->Bucket : "*"), os->url); // If you are getting errors here, the comments above the "#if // ((LIBCURL_VERSION ...", in stream_sync(), *might* be relevant. AWS4C_CHECK1( s3_put(b, os->url) ); /* create empty object with user metadata */ } // s3_get with byte-range can leave streaming_writefunc() waiting for // a curl callback that never comes. This happens if there is still writable // space in the buffer, when the last bytes in the request are processed. // This can happen because caller (e.g. fuse) may ask for more bytes than are present, // and provide a buffer big enought o receive them. if (is_get && (b->code == 206)) { // should we do something with os->iob_full? set os->flags & EOF? LOG(LOG_INFO, "GET complete\n"); os->flags |= OSF_EOF; POST(&os->iob_full); return 0; } else if (AWS4C_OK(b) ) { LOG(LOG_INFO, "%s complete\n", ((is_get) ? "GET" : "PUT")); return 0; } LOG(LOG_ERR, "CURL ERROR: %lx %d '%s'\n", (size_t)b, b->code, b->result); return -1; }
static IOR_offset_t S3_GetFileSize(IOR_param_t * param, MPI_Comm testComm, char * testFileName) { if (param->verbose >= VERBOSE_2) { printf("-> S3_GetFileSize(%s)\n", testFileName); } IOR_offset_t aggFileSizeFromStat; /* i.e. "long long int" */ IOR_offset_t tmpMin, tmpMax, tmpSum; /* make sure curl is connected, and inits are done */ s3_connect( param ); /* send HEAD request. aws4c parses some headers into IOBuf arg. */ AWS4C_CHECK( s3_head(param->io_buf, testFileName) ); if ( ! AWS4C_OK(param->io_buf) ) { fprintf(stderr, "rank %d: couldn't stat '%s': %s\n", rank, testFileName, param->io_buf->result); MPI_Abort(param->testComm, 1); } aggFileSizeFromStat = param->io_buf->contentLen; if (param->verbose >= VERBOSE_2) { printf("\trank %d: file-size %llu\n", rank, aggFileSizeFromStat); } if ( param->filePerProc == TRUE ) { if (param->verbose >= VERBOSE_2) { printf("\tall-reduce (1)\n"); } MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpSum, /* sum */ 1, MPI_LONG_LONG_INT, MPI_SUM, testComm ), "cannot total data moved" ); aggFileSizeFromStat = tmpSum; } else { if (param->verbose >= VERBOSE_2) { printf("\tall-reduce (2a)\n"); } MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMin, /* min */ 1, MPI_LONG_LONG_INT, MPI_MIN, testComm ), "cannot total data moved" ); if (param->verbose >= VERBOSE_2) { printf("\tall-reduce (2b)\n"); } MPI_CHECK(MPI_Allreduce(&aggFileSizeFromStat, &tmpMax, /* max */ 1, MPI_LONG_LONG_INT, MPI_MAX, testComm ), "cannot total data moved" ); if ( tmpMin != tmpMax ) { if ( rank == 0 ) { WARN( "inconsistent file size by different tasks" ); } /* incorrect, but now consistent across tasks */ aggFileSizeFromStat = tmpMin; } } if (param->verbose >= VERBOSE_2) { printf("<- S3_GetFileSize [%llu]\n", aggFileSizeFromStat); } return ( aggFileSizeFromStat ); }