51 if (init_values !=
NULL){
62 {0,
"S3-libs3.bucket-per-file",
"Use one bucket to map one file/directory, otherwise one bucket is used to store all dirs/files.",
OPTION_FLAG,
'd', & o->
bucket_per_file},
64 {0,
"S3-libs3.dont-suffix-bucket",
"By default a hash will be added to the bucket name to increase uniqueness, this disables the option.",
OPTION_FLAG,
'd', & o->
dont_suffix },
65 {0,
"S3-libs3.s3-compatible",
"to be selected when using S3 compatible storage",
OPTION_FLAG,
'd', & o->
s3_compatible },
66 {0,
"S3-libs3.use-ssl",
"used to specify that SSL is needed for the connection",
OPTION_FLAG,
'd', & o->
use_ssl },
67 {0,
"S3-libs3.host",
"The host optionally followed by:port. Or specify a list of hosts separated by [ ,;] to be used in a round robin fashion by the MPI ranks.",
OPTION_OPTIONAL_ARGUMENT,
's', & o->
host},
75 memcpy(help, h,
sizeof(h));
86 if(((c >=
'0' && c <=
'9') || (c >=
'a' && c <=
'z') )){
89 }
else if(c >=
'A' && c <=
'Z'){
90 *out_name = *path + (
'a' -
'A');
97 *out_name =
'a' + (c / 26);
99 *out_name =
'a' + (c % 26);
117 if(((c >=
'0' && c <=
'9') || (c >=
'a' && c <=
'z') )){
120 }
else if(c >=
'A' && c <=
'Z'){
121 *out_name = *path + (
'a' -
'A');
154 #define CHECK_ERROR(p) \ 155 if (s3status != S3StatusOK){ \ 156 WARNF("S3 %s:%d (path:%s) \"%s\": %s %s", __FUNCTION__, __LINE__, p, S3_get_status_name(s3status), s3error.message, s3error.furtherDetails ? s3error.furtherDetails : ""); \ 178 static S3Status
S3ListResponseCallback(
const char *ownerId,
const char *ownerDisplayName,
const char *bucketName, int64_t creationDateSeconds,
void *callbackData){
179 uint64_t * count = (uint64_t*) callbackData;
195 uint64_t buckets = 0;
205 *((
char const**)(callbackData)) = upload_id;
217 const int64_t
size = dh->
size > bufferSize ? bufferSize : dh->
size;
218 if(size == 0)
return 0;
219 memcpy(buffer, dh->
buf, size);
232 char p[FILENAME_MAX];
238 S3_create_bucket(o->
s3_protocol, o->
access_key, o->
secret_key,
NULL, o->
host, p, o->
authRegion, S3CannedAclPrivate, o->
locationConstraint,
NULL, o->
timeout, &
responseHandler,
NULL);
257 struct stat *
buf = (
struct stat*) callbackData;
259 buf->st_size = properties->contentLength;
260 buf->st_mtime = properties->lastModified;
274 WARN(
"S3 IOR_WRONLY is not supported");
277 WARN(
"S3 IOR_RDWR is not supported");
281 char p[FILENAME_MAX];
304 const int64_t
size = dh->
size > bufferSize ? bufferSize : dh->
size;
305 memcpy(dh->
buf, buffer, size);
319 char p[FILENAME_MAX];
324 sprintf(p,
"%ld-%ld", (
long) offset, (
long) length);
330 sprintf(p,
"%s-%ld-%ld", fd->
object, (
long) offset, (
long) length);
332 sprintf(p,
"%s", fd->
object);
361 S3Status
list_delete_cb(
int isTruncated,
const char *nextMarker,
int contentsCount,
const S3ListBucketContent *contents,
int commonPrefixesCount,
const char **commonPrefixes,
void *callbackData){
363 for(
int i=0; i < contentsCount; i++){
378 char p[FILENAME_MAX];
388 S3_delete_bucket(o->
s3_protocol, S3UriStylePath, o->
access_key, o->
secret_key, NULL, o->
host, p, o->
authRegion, NULL, o->
timeout, &
responseHandler, NULL);
390 char * del_heuristics = getenv(
"S3LIB_DELETE_HEURISTICS");
399 int threshold = atoi(del_heuristics);
400 if (buf.st_size > threshold){
427 char p[FILENAME_MAX];
432 S3_create_bucket(o->
s3_protocol, o->
access_key, o->
secret_key,
NULL, o->
host, p, o->
authRegion, S3CannedAclPrivate, o->
locationConstraint,
NULL, o->
timeout, &
responseHandler,
NULL);
447 char p[FILENAME_MAX];
451 S3_delete_bucket(o->
s3_protocol, S3UriStylePath, o->
access_key, o->
secret_key,
NULL, o->
host, p, o->
authRegion,
NULL, o->
timeout, &
responseHandler,
NULL);
463 char p[FILENAME_MAX];
465 memset(buf, 0,
sizeof(
struct stat));
482 return S3_stat(path, & buf, options);
488 if(
S3_stat(testFileName, & buf, options) != 0)
return -1;
502 WARN(
"The S3 hostname should be specified");
514 const char* delimiters=
" ,;";
517 char* r= strtok(o->
host, delimiters);
520 r= strtok(
NULL, delimiters);
525 int i=
rank % num_hosts;
531 next= strchr(next,
'\0');
539 int ret = S3_initialize(
NULL, S3_INIT_ALL, o->
host);
540 if(ret != S3StatusOK)
541 FAIL(
"Could not initialize S3 library");
547 for(uint64_t pos = 1; (*r) !=
'\0' ; r++, pos*=10) {
573 S3_create_bucket(o->
s3_protocol, o->
access_key, o->
secret_key,
NULL, o->
host, o->
bucket_context.bucketName, o->
authRegion, S3CannedAclPrivate, o->
locationConstraint,
NULL, o->
timeout, &
responseHandler,
NULL);
577 if ( ret != S3StatusOK ){
578 FAIL(
"S3 error %s", S3_get_status_name(ret));
585 S3_delete_bucket(o->
s3_protocol, S3UriStylePath, o->
access_key, o->
secret_key,
NULL, o->
host, o->
bucket_context.bucketName, o->
authRegion,
NULL, o->
timeout, &
responseHandler,
NULL);
615 .enable_mdtest =
true
static S3MultipartInitialHandler multipart_handler
static int putObjectDataCallback(int bufferSize, char *buffer, void *callbackData)
static IOR_offset_t S3_Xfer(int access, aiori_fd_t *afd, IOR_size_t *buffer, IOR_offset_t length, IOR_offset_t offset, aiori_mod_opt_t *options)
static void S3_Close(aiori_fd_t *afd, aiori_mod_opt_t *options)
S3Status list_delete_cb(int isTruncated, const char *nextMarker, int contentsCount, const S3ListBucketContent *contents, int commonPrefixesCount, const char **commonPrefixes, void *callbackData)
struct benchmark_options o
static S3ErrorDetails s3error
S3BucketContext bucket_context
static aiori_xfer_hint_t * hints
static int S3_check_params(aiori_mod_opt_t *options)
static S3Status statResponsePropertiesCallback(const S3ResponseProperties *properties, void *callbackData)
static S3GetObjectHandler getObjectHandler
static void S3_Fsync(aiori_fd_t *fd, aiori_mod_opt_t *options)
static aiori_fd_t * S3_Open(char *path, int flags, aiori_mod_opt_t *options)
static char * S3_getVersion()
static aiori_fd_t * S3_Create(char *path, int iorflags, aiori_mod_opt_t *options)
static void def_file_name(s3_options_t *o, char *out_name, char const *path)
static void S3_Sync(aiori_mod_opt_t *options)
char * locationConstraint
static S3Status S3ListResponseCallback(const char *ownerId, const char *ownerDisplayName, const char *bucketName, int64_t creationDateSeconds, void *callbackData)
static S3Status responsePropertiesCallback(const S3ResponseProperties *properties, void *callbackData)
static void def_bucket_name(s3_options_t *o, char *out_name, char const *path)
static S3ListServiceHandler listhandler
static option_help options[]
static option_help * S3_options(aiori_mod_opt_t **init_backend_options, aiori_mod_opt_t *init_values)
static S3ListBucketHandler list_delete_handler
static void S3_final(aiori_mod_opt_t *options)
static S3ResponseHandler statResponseHandler
static S3Status S3multipart_handler(const char *upload_id, void *callbackData)
static int S3_stat(const char *path, struct stat *buf, aiori_mod_opt_t *options)
static IOR_offset_t S3_GetFileSize(aiori_mod_opt_t *options, char *testFileName)
static S3Status getObjectDataCallback(int bufferSize, const char *buffer, void *callbackData)
static int S3_mkdir(const char *path, mode_t mode, aiori_mod_opt_t *options)
static void S3_Delete(char *path, aiori_mod_opt_t *options)
static int S3_rmdir(const char *path, aiori_mod_opt_t *options)
static S3PutObjectHandler putObjectHandler
static void S3_init(aiori_mod_opt_t *options)
static void responseCompleteCallback(S3Status status, const S3ErrorDetails *error, void *callbackData)
static void s3_xfer_hints(aiori_xfer_hint_t *params)
static int S3_access(const char *path, int mode, aiori_mod_opt_t *options)
long long int IOR_offset_t
ior_aiori_t S3_libS3_aiori
static int S3_statfs(const char *path, ior_aiori_statfs_t *stat, aiori_mod_opt_t *options)
static S3ResponseHandler responseHandler