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 },
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');
111 if(((c >=
'0' && c <=
'9') || (c >=
'a' && c <=
'z') )){
114 }
else if(c >=
'A' && c <=
'Z'){
115 *out_name = *path + (
'a' -
'A');
148 #define CHECK_ERROR(p) \ 149 if (s3status != S3StatusOK){ \ 150 EWARNF("S3 %s:%d (path:%s) \"%s\": %s %s", __FUNCTION__, __LINE__, p, S3_get_status_name(s3status), s3error.message, s3error.furtherDetails ? s3error.furtherDetails : ""); \ 172 static S3Status
S3ListResponseCallback(
const char *ownerId,
const char *ownerDisplayName,
const char *bucketName, int64_t creationDateSeconds,
void *callbackData){
173 uint64_t * count = (uint64_t*) callbackData;
189 uint64_t buckets = 0;
199 *((
char const**)(callbackData)) = upload_id;
211 const int64_t
size = dh->
size > bufferSize ? bufferSize : dh->
size;
212 if(size == 0)
return 0;
213 memcpy(buffer, dh->
buf, size);
226 char p[FILENAME_MAX];
232 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);
251 struct stat *
buf = (
struct stat*) callbackData;
253 buf->st_size = properties->contentLength;
254 buf->st_mtime = properties->lastModified;
268 WARN(
"S3 IOR_WRONLY is not supported");
271 WARN(
"S3 IOR_RDWR is not supported");
275 char p[FILENAME_MAX];
298 const int64_t
size = dh->
size > bufferSize ? bufferSize : dh->
size;
299 memcpy(dh->
buf, buffer, size);
313 char p[FILENAME_MAX];
318 sprintf(p,
"%ld-%ld", (
long) offset, (
long) length);
324 sprintf(p,
"%s-%ld-%ld", fd->
object, (
long) offset, (
long) length);
326 sprintf(p,
"%s", fd->
object);
355 S3Status
list_delete_cb(
int isTruncated,
const char *nextMarker,
int contentsCount,
const S3ListBucketContent *contents,
int commonPrefixesCount,
const char **commonPrefixes,
void *callbackData){
357 for(
int i=0; i < contentsCount; i++){
372 char p[FILENAME_MAX];
382 S3_delete_bucket(o->
s3_protocol, S3UriStylePath, o->
access_key, o->
secret_key, NULL, o->
host, p, o->
authRegion, NULL, o->
timeout, &
responseHandler, NULL);
395 char p[FILENAME_MAX];
400 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);
415 char p[FILENAME_MAX];
419 S3_delete_bucket(o->
s3_protocol, S3UriStylePath, o->
access_key, o->
secret_key,
NULL, o->
host, p, o->
authRegion,
NULL, o->
timeout, &
responseHandler,
NULL);
431 char p[FILENAME_MAX];
433 memset(buf, 0,
sizeof(
struct stat));
450 return S3_stat(path, & buf, options);
456 if(
S3_stat(testFileName, & buf, options) != 0)
return -1;
470 WARN(
"The S3 hostname should be specified");
477 int ret = S3_initialize(
NULL, S3_INIT_ALL, o->
host);
478 if(ret != S3StatusOK)
479 FAIL(
"Could not initialize S3 library");
485 for(uint64_t pos = 1; (*r) !=
'\0' ; r++, pos*=10) {
511 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);
515 if ( ret != S3StatusOK ){
516 FAIL(
"S3 error %s", S3_get_status_name(ret));
523 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);
553 .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