2014-09-07 15:08:27 +00:00
|
|
|
/*
|
|
|
|
* s3fs - FUSE-based file system backed by Amazon S3
|
|
|
|
*
|
2017-05-07 11:24:17 +00:00
|
|
|
* Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
|
2014-09-07 15:08:27 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2016-02-07 05:41:56 +00:00
|
|
|
|
2011-03-01 19:35:55 +00:00
|
|
|
#ifndef S3FS_CURL_H_
|
|
|
|
#define S3FS_CURL_H_
|
|
|
|
|
2016-04-22 06:57:31 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
2018-11-15 00:48:57 +00:00
|
|
|
#include "psemaphore.h"
|
2020-08-20 02:09:49 +00:00
|
|
|
#include "types.h"
|
2018-11-15 00:48:57 +00:00
|
|
|
|
2019-03-22 10:47:42 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// Avoid dependency on libcurl version
|
|
|
|
//----------------------------------------------
|
|
|
|
// [NOTE]
|
|
|
|
// The following symbols (enum) depend on the version of libcurl.
|
|
|
|
// CURLOPT_TCP_KEEPALIVE 7.25.0 and later
|
|
|
|
// CURLOPT_SSL_ENABLE_ALPN 7.36.0 and later
|
|
|
|
// CURLOPT_KEEP_SENDING_ON_ERROR 7.51.0 and later
|
|
|
|
//
|
|
|
|
// s3fs uses these, if you build s3fs with the old libcurl,
|
|
|
|
// substitute the following symbols to avoid errors.
|
|
|
|
// If the version of libcurl linked at runtime is old,
|
|
|
|
// curl_easy_setopt results in an error(CURLE_UNKNOWN_OPTION) and
|
|
|
|
// a message is output.
|
|
|
|
//
|
|
|
|
#if defined(HAVE_CURLOPT_TCP_KEEPALIVE) && (HAVE_CURLOPT_TCP_KEEPALIVE == 1)
|
|
|
|
#define S3FS_CURLOPT_TCP_KEEPALIVE CURLOPT_TCP_KEEPALIVE
|
|
|
|
#else
|
|
|
|
#define S3FS_CURLOPT_TCP_KEEPALIVE static_cast<CURLoption>(213)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_CURLOPT_SSL_ENABLE_ALPN) && (HAVE_CURLOPT_SSL_ENABLE_ALPN == 1)
|
|
|
|
#define S3FS_CURLOPT_SSL_ENABLE_ALPN CURLOPT_SSL_ENABLE_ALPN
|
|
|
|
#else
|
|
|
|
#define S3FS_CURLOPT_SSL_ENABLE_ALPN static_cast<CURLoption>(226)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_CURLOPT_KEEP_SENDING_ON_ERROR) && (HAVE_CURLOPT_KEEP_SENDING_ON_ERROR == 1)
|
|
|
|
#define S3FS_CURLOPT_KEEP_SENDING_ON_ERROR CURLOPT_KEEP_SENDING_ON_ERROR
|
|
|
|
#else
|
|
|
|
#define S3FS_CURLOPT_KEEP_SENDING_ON_ERROR static_cast<CURLoption>(245)
|
|
|
|
#endif
|
|
|
|
|
2015-10-20 15:19:04 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// Symbols
|
|
|
|
//----------------------------------------------
|
2017-11-18 03:50:36 +00:00
|
|
|
static const int MIN_MULTIPART_SIZE = 5 * 1024 * 1024;
|
2015-10-20 15:19:04 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// class BodyData
|
|
|
|
//----------------------------------------------
|
2013-04-11 01:49:00 +00:00
|
|
|
// memory class for curl write memory callback
|
2013-07-05 02:28:31 +00:00
|
|
|
//
|
2013-04-11 01:49:00 +00:00
|
|
|
class BodyData
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
char* text;
|
|
|
|
size_t lastpos;
|
|
|
|
size_t bufsize;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool IsSafeSize(size_t addbytes) const {
|
|
|
|
return ((lastpos + addbytes + 1) > bufsize ? false : true);
|
|
|
|
}
|
|
|
|
bool Resize(size_t addbytes);
|
|
|
|
|
|
|
|
public:
|
|
|
|
BodyData() : text(NULL), lastpos(0), bufsize(0) {}
|
|
|
|
~BodyData() {
|
|
|
|
Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Clear(void);
|
|
|
|
bool Append(void* ptr, size_t bytes);
|
|
|
|
bool Append(void* ptr, size_t blockSize, size_t numBlocks) {
|
|
|
|
return Append(ptr, (blockSize * numBlocks));
|
|
|
|
}
|
|
|
|
const char* str() const;
|
|
|
|
size_t size() const {
|
|
|
|
return lastpos;
|
|
|
|
}
|
2011-03-01 19:35:55 +00:00
|
|
|
};
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// Utility structs & typedefs
|
|
|
|
//----------------------------------------------
|
2013-07-10 06:24:06 +00:00
|
|
|
typedef std::vector<std::string> etaglist_t;
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
// Each part information for Multipart upload
|
|
|
|
struct filepart
|
|
|
|
{
|
2013-07-12 00:33:36 +00:00
|
|
|
bool uploaded; // does finish uploading
|
|
|
|
std::string etag; // expected etag value
|
2015-07-10 18:50:40 +00:00
|
|
|
int fd; // base file(temporary full file) descriptor
|
2013-07-12 00:33:36 +00:00
|
|
|
off_t startpos; // seek fd point for uploading
|
2019-06-14 09:04:57 +00:00
|
|
|
off_t size; // uploading size
|
2013-07-10 06:24:06 +00:00
|
|
|
etaglist_t* etaglist; // use only parallel upload
|
|
|
|
int etagpos; // use only parallel upload
|
|
|
|
|
2013-07-12 00:33:36 +00:00
|
|
|
filepart() : uploaded(false), fd(-1), startpos(0), size(-1), etaglist(NULL), etagpos(-1) {}
|
2013-07-10 06:24:06 +00:00
|
|
|
~filepart()
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
2013-07-05 02:28:31 +00:00
|
|
|
|
Changes codes for performance(part 3)
* Summay
This revision includes big change about temporary file and local cache file.
By this big change, s3fs works with good performance when s3fs opens/
closes/syncs/reads object.
I made a big change about the handling about temporary file and local cache
file to do this implementation.
* Detail
1) About temporary file(local file)
s3fs uses a temporary file on local file system when s3fs does download/
upload/open/seek object on S3.
After this revision, s3fs calls ftruncate() function when s3fs makes the
temporary file.
In this way s3fs can set a file size of precisely length without downloading.
(Notice - ftruncate function is for XSI-compliant systems, so that possibly
you have a problem on non-XSI-compliant systems.)
By this change, s3fs can download a part of a object by requesting with
"Range" http header. It seems like downloading by each block unit.
The default block(part) size is 50MB, it is caused the result which is default
parallel requests count(5) by default multipart upload size(10MB).
If you need to change this block size, you can change by new option
"fd_page_size". This option can take from 1MB(1024 * 1024) to any bytes.
So that, you have to take care about that fdcache.cpp(and fdcache.h) were
changed a lot.
2) About local cache
Local cache files which are in directory specified by "use_cache" option do
not have always all of object data.
This cause is that s3fs uses ftruncate function and reads(writes) each block
unit of a temporary file.
s3fs manages each block unit's status which are "downloaded area" or "not".
For this status, s3fs makes new temporary file in cache directory which is
specified by "use_cache" option. This status files is in a directory which is
named "<use_cache sirectory>/.<bucket_name>/".
When s3fs opens this status file, s3fs locks this file for exclusive control by
calling flock function. You need to take care about this, the status files can
not be laid on network drive(like NFS).
This revision changes about file open mode, s3fs always opens a local cache
file and each status file with writable mode.
Last, this revision adds new option "del_cache", this option means that s3fs
deletes all local cache file when s3fs starts and exits.
3) Uploading
When s3fs writes data to file descriptor through FUSE request, old s3fs
revision downloads all of the object. But new revision does not download all,
it downloads only small percial area(some block units) including writing data
area.
And when s3fs closes or flushes the file descriptor, s3fs downloads other area
which is not downloaded from server. After that, s3fs uploads all of data.
Already r456 revision has parallel upload function, then this revision with
r456 and r457 are very big change for performance.
4) Downloading
By changing a temporary file and a local cache file, when s3fs downloads a
object, it downloads only the required range(some block units).
And s3fs downloads units by parallel GET request, it is same as a case of
uploading. (Maximum parallel request count and each download size are
specified same parameters for uploading.)
In the new revision, when s3fs opens file, s3fs returns file descriptor soon.
Because s3fs only opens(makes) the file descriptor with no downloading
data. And when s3fs reads a data, s3fs downloads only some block unit
including specified area.
This result is good for performance.
5) Changes option name
The option "parallel_upload" which added at r456 is changed to new option
name as "parallel_count". This reason is this option value is not only used by
uploading object, but a uploading object also uses this option. (For a while,
you can use old option name "parallel_upload" for compatibility.)
git-svn-id: http://s3fs.googlecode.com/svn/trunk@458 df820570-a93a-0410-bd06-b72b767a4274
2013-07-23 16:01:48 +00:00
|
|
|
void clear(void)
|
2013-07-10 06:24:06 +00:00
|
|
|
{
|
|
|
|
uploaded = false;
|
|
|
|
etag = "";
|
2013-07-12 00:33:36 +00:00
|
|
|
fd = -1;
|
|
|
|
startpos = 0;
|
|
|
|
size = -1;
|
2013-07-10 06:24:06 +00:00
|
|
|
etaglist = NULL;
|
|
|
|
etagpos = - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void add_etag_list(etaglist_t* list)
|
|
|
|
{
|
|
|
|
if(list){
|
|
|
|
list->push_back(std::string(""));
|
|
|
|
etaglist = list;
|
|
|
|
etagpos = list->size() - 1;
|
|
|
|
}else{
|
|
|
|
etaglist = NULL;
|
|
|
|
etagpos = - 1;
|
|
|
|
}
|
|
|
|
}
|
2011-03-01 19:35:55 +00:00
|
|
|
};
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
// for progress
|
|
|
|
struct case_insensitive_compare_func
|
|
|
|
{
|
2014-01-05 02:24:27 +00:00
|
|
|
bool operator()(const std::string& a, const std::string& b) const {
|
2013-07-05 02:28:31 +00:00
|
|
|
return strcasecmp(a.c_str(), b.c_str()) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
typedef std::map<std::string, std::string, case_insensitive_compare_func> mimes_t;
|
|
|
|
typedef std::pair<double, double> progress_t;
|
|
|
|
typedef std::map<CURL*, time_t> curltime_t;
|
|
|
|
typedef std::map<CURL*, progress_t> curlprogress_t;
|
2011-03-01 19:35:55 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
class S3fsMultiCurl;
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2016-04-22 06:57:31 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// class CurlHandlerPool
|
|
|
|
//----------------------------------------------
|
2019-02-25 12:47:10 +00:00
|
|
|
typedef std::list<CURL*> hcurllist_t;
|
2016-04-22 06:57:31 +00:00
|
|
|
|
|
|
|
class CurlHandlerPool
|
|
|
|
{
|
|
|
|
public:
|
2019-02-25 12:47:10 +00:00
|
|
|
explicit CurlHandlerPool(int maxHandlers) : mMaxHandlers(maxHandlers)
|
2016-04-22 06:57:31 +00:00
|
|
|
{
|
|
|
|
assert(maxHandlers > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Init();
|
|
|
|
bool Destroy();
|
|
|
|
|
2019-02-25 12:47:10 +00:00
|
|
|
CURL* GetHandler(bool only_pool);
|
|
|
|
void ReturnHandler(CURL* hCurl, bool restore_pool);
|
2016-04-22 06:57:31 +00:00
|
|
|
|
|
|
|
private:
|
2019-02-25 12:47:10 +00:00
|
|
|
int mMaxHandlers;
|
2016-04-22 06:57:31 +00:00
|
|
|
pthread_mutex_t mLock;
|
2019-02-25 12:47:10 +00:00
|
|
|
hcurllist_t mPool;
|
2016-04-22 06:57:31 +00:00
|
|
|
};
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// class S3fsCurl
|
|
|
|
//----------------------------------------------
|
2020-06-21 18:04:49 +00:00
|
|
|
#include "fdcache.h" // for fdpage_list_t
|
|
|
|
|
2019-02-25 12:47:10 +00:00
|
|
|
class S3fsCurl;
|
|
|
|
|
2019-03-09 08:45:10 +00:00
|
|
|
// Prototype function for lazy setup options for curl handle
|
|
|
|
typedef bool (*s3fscurl_lazy_setup)(S3fsCurl* s3fscurl);
|
2019-02-25 12:47:10 +00:00
|
|
|
|
2013-10-06 13:45:32 +00:00
|
|
|
typedef std::map<std::string, std::string> iamcredmap_t;
|
2014-07-19 19:02:55 +00:00
|
|
|
typedef std::map<std::string, std::string> sseckeymap_t;
|
|
|
|
typedef std::list<sseckeymap_t> sseckeylist_t;
|
2013-10-06 13:45:32 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
// Class for lapping curl
|
|
|
|
//
|
|
|
|
class S3fsCurl
|
|
|
|
{
|
|
|
|
friend class S3fsMultiCurl;
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
private:
|
2013-08-21 07:43:32 +00:00
|
|
|
enum REQTYPE {
|
|
|
|
REQTYPE_UNSET = -1,
|
|
|
|
REQTYPE_DELETE = 0,
|
|
|
|
REQTYPE_HEAD,
|
|
|
|
REQTYPE_PUTHEAD,
|
|
|
|
REQTYPE_PUT,
|
|
|
|
REQTYPE_GET,
|
|
|
|
REQTYPE_CHKBUCKET,
|
|
|
|
REQTYPE_LISTBUCKET,
|
|
|
|
REQTYPE_PREMULTIPOST,
|
|
|
|
REQTYPE_COMPLETEMULTIPOST,
|
|
|
|
REQTYPE_UPLOADMULTIPOST,
|
|
|
|
REQTYPE_COPYMULTIPOST,
|
2013-10-06 13:45:32 +00:00
|
|
|
REQTYPE_MULTILIST,
|
2013-11-11 13:45:35 +00:00
|
|
|
REQTYPE_IAMCRED,
|
2016-05-06 04:37:32 +00:00
|
|
|
REQTYPE_ABORTMULTIUPLOAD,
|
|
|
|
REQTYPE_IAMROLE
|
2013-08-21 07:43:32 +00:00
|
|
|
};
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
// class variables
|
2013-08-27 08:12:01 +00:00
|
|
|
static pthread_mutex_t curl_handles_lock;
|
2020-08-18 12:37:02 +00:00
|
|
|
static struct callback_locks_t {
|
|
|
|
pthread_mutex_t dns;
|
|
|
|
pthread_mutex_t ssl_session;
|
|
|
|
} callback_locks;
|
2013-08-27 08:12:01 +00:00
|
|
|
static bool is_initglobal_done;
|
2016-04-22 06:57:31 +00:00
|
|
|
static CurlHandlerPool* sCurlPool;
|
|
|
|
static int sCurlPoolSize;
|
2013-08-27 08:12:01 +00:00
|
|
|
static CURLSH* hCurlShare;
|
2015-05-20 15:32:36 +00:00
|
|
|
static bool is_cert_check;
|
2013-08-27 08:12:01 +00:00
|
|
|
static bool is_dns_cache;
|
2013-09-14 21:50:39 +00:00
|
|
|
static bool is_ssl_session_cache;
|
2013-08-27 08:12:01 +00:00
|
|
|
static long connect_timeout;
|
|
|
|
static time_t readwrite_timeout;
|
|
|
|
static int retries;
|
|
|
|
static bool is_public_bucket;
|
2019-08-09 20:51:01 +00:00
|
|
|
static acl_t default_acl;
|
2015-09-17 20:10:45 +00:00
|
|
|
static storage_class_t storage_class;
|
2014-07-19 19:02:55 +00:00
|
|
|
static sseckeylist_t sseckeys;
|
2015-10-06 14:46:14 +00:00
|
|
|
static std::string ssekmsid;
|
|
|
|
static sse_type_t ssetype;
|
2013-08-27 08:12:01 +00:00
|
|
|
static bool is_content_md5;
|
|
|
|
static bool is_verbose;
|
2020-05-24 07:23:27 +00:00
|
|
|
static bool is_dump_body;
|
2013-08-27 08:12:01 +00:00
|
|
|
static std::string AWSAccessKeyId;
|
|
|
|
static std::string AWSSecretAccessKey;
|
2013-10-06 13:45:32 +00:00
|
|
|
static std::string AWSAccessToken;
|
|
|
|
static time_t AWSAccessTokenExpire;
|
2017-11-05 19:24:02 +00:00
|
|
|
static bool is_ecs;
|
2019-04-14 16:19:34 +00:00
|
|
|
static bool is_use_session_token;
|
2017-11-23 08:46:24 +00:00
|
|
|
static bool is_ibm_iam_auth;
|
|
|
|
static std::string IAM_cred_url;
|
|
|
|
static size_t IAM_field_count;
|
|
|
|
static std::string IAM_token_field;
|
|
|
|
static std::string IAM_expiry_field;
|
2013-10-06 13:45:32 +00:00
|
|
|
static std::string IAM_role;
|
2013-08-27 08:12:01 +00:00
|
|
|
static long ssl_verify_hostname;
|
|
|
|
static curltime_t curl_times;
|
|
|
|
static curlprogress_t curl_progress;
|
|
|
|
static std::string curl_ca_bundle;
|
|
|
|
static mimes_t mimeTypes;
|
2017-09-17 09:16:05 +00:00
|
|
|
static std::string userAgent;
|
2013-08-27 08:12:01 +00:00
|
|
|
static int max_parallel_cnt;
|
2019-01-19 01:16:56 +00:00
|
|
|
static int max_multireq;
|
2014-03-30 07:53:41 +00:00
|
|
|
static off_t multipart_size;
|
2015-01-28 17:13:11 +00:00
|
|
|
static bool is_sigv4;
|
2016-04-17 07:44:03 +00:00
|
|
|
static bool is_ua; // User-Agent
|
2019-11-18 11:38:16 +00:00
|
|
|
static bool requester_pays;
|
2013-07-05 02:28:31 +00:00
|
|
|
|
|
|
|
// variables
|
|
|
|
CURL* hCurl;
|
2013-08-21 07:43:32 +00:00
|
|
|
REQTYPE type; // type of request
|
|
|
|
std::string path; // target object path
|
|
|
|
std::string base_path; // base path (for multi curl head request)
|
|
|
|
std::string saved_path; // saved path = cache key (for multi curl head request)
|
|
|
|
std::string url; // target object path(url)
|
2013-07-05 02:28:31 +00:00
|
|
|
struct curl_slist* requestHeaders;
|
2013-08-21 07:43:32 +00:00
|
|
|
headers_t responseHeaders; // header data by HeaderCallback
|
2019-08-03 21:54:21 +00:00
|
|
|
BodyData bodydata; // body data by WriteMemoryCallback
|
|
|
|
BodyData headdata; // header data by WriteMemoryCallback
|
2019-08-22 15:22:57 +00:00
|
|
|
volatile long LastResponseCode;
|
2013-08-21 07:43:32 +00:00
|
|
|
const unsigned char* postdata; // use by post method and read callback function.
|
|
|
|
int postdata_remaining; // use by post method and read callback function.
|
|
|
|
filepart partdata; // use by multipart upload/get object callback
|
|
|
|
bool is_use_ahbe; // additional header by extension
|
2013-11-11 13:45:35 +00:00
|
|
|
int retry_count; // retry count for multipart
|
2013-08-21 07:43:32 +00:00
|
|
|
FILE* b_infile; // backup for retrying
|
|
|
|
const unsigned char* b_postdata; // backup for retrying
|
|
|
|
int b_postdata_remaining; // backup for retrying
|
|
|
|
off_t b_partdata_startpos; // backup for retrying
|
|
|
|
ssize_t b_partdata_size; // backup for retrying
|
2015-10-06 14:46:14 +00:00
|
|
|
int b_ssekey_pos; // backup for retrying
|
|
|
|
std::string b_ssevalue; // backup for retrying
|
|
|
|
sse_type_t b_ssetype; // backup for retrying
|
2019-08-11 15:45:57 +00:00
|
|
|
std::string b_from; // backup for retrying(for copy request)
|
|
|
|
headers_t b_meta; // backup for retrying(for copy request)
|
2017-10-26 14:21:48 +00:00
|
|
|
std::string op; // the HTTP verb of the request ("PUT", "GET", etc.)
|
|
|
|
std::string query_string; // request query string
|
2018-11-15 00:48:57 +00:00
|
|
|
Semaphore *sem;
|
2019-01-28 20:14:04 +00:00
|
|
|
pthread_mutex_t *completed_tids_lock;
|
|
|
|
std::vector<pthread_t> *completed_tids;
|
2019-03-09 08:45:10 +00:00
|
|
|
s3fscurl_lazy_setup fpLazySetup; // curl options for lazy setting function
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
public:
|
|
|
|
// constructor/destructor
|
2015-08-06 06:38:06 +00:00
|
|
|
explicit S3fsCurl(bool ahbe = false);
|
2013-07-05 02:28:31 +00:00
|
|
|
~S3fsCurl();
|
2013-06-15 15:29:08 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
private:
|
|
|
|
// class methods
|
2013-08-27 08:12:01 +00:00
|
|
|
static bool InitGlobalCurl(void);
|
|
|
|
static bool DestroyGlobalCurl(void);
|
|
|
|
static bool InitShareCurl(void);
|
|
|
|
static bool DestroyShareCurl(void);
|
2013-07-05 02:28:31 +00:00
|
|
|
static void LockCurlShare(CURL* handle, curl_lock_data nLockData, curl_lock_access laccess, void* useptr);
|
|
|
|
static void UnlockCurlShare(CURL* handle, curl_lock_data nLockData, void* useptr);
|
2013-08-27 08:12:01 +00:00
|
|
|
static bool InitCryptMutex(void);
|
|
|
|
static bool DestroyCryptMutex(void);
|
2013-07-05 02:28:31 +00:00
|
|
|
static int CurlProgress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
|
|
|
|
|
|
|
static bool LocateBundle(void);
|
|
|
|
static size_t HeaderCallback(void *data, size_t blockSize, size_t numBlocks, void *userPtr);
|
|
|
|
static size_t WriteMemoryCallback(void *ptr, size_t blockSize, size_t numBlocks, void *data);
|
|
|
|
static size_t ReadCallback(void *ptr, size_t size, size_t nmemb, void *userp);
|
2013-07-12 00:33:36 +00:00
|
|
|
static size_t UploadReadCallback(void *ptr, size_t size, size_t nmemb, void *userp);
|
Changes codes for performance(part 3)
* Summay
This revision includes big change about temporary file and local cache file.
By this big change, s3fs works with good performance when s3fs opens/
closes/syncs/reads object.
I made a big change about the handling about temporary file and local cache
file to do this implementation.
* Detail
1) About temporary file(local file)
s3fs uses a temporary file on local file system when s3fs does download/
upload/open/seek object on S3.
After this revision, s3fs calls ftruncate() function when s3fs makes the
temporary file.
In this way s3fs can set a file size of precisely length without downloading.
(Notice - ftruncate function is for XSI-compliant systems, so that possibly
you have a problem on non-XSI-compliant systems.)
By this change, s3fs can download a part of a object by requesting with
"Range" http header. It seems like downloading by each block unit.
The default block(part) size is 50MB, it is caused the result which is default
parallel requests count(5) by default multipart upload size(10MB).
If you need to change this block size, you can change by new option
"fd_page_size". This option can take from 1MB(1024 * 1024) to any bytes.
So that, you have to take care about that fdcache.cpp(and fdcache.h) were
changed a lot.
2) About local cache
Local cache files which are in directory specified by "use_cache" option do
not have always all of object data.
This cause is that s3fs uses ftruncate function and reads(writes) each block
unit of a temporary file.
s3fs manages each block unit's status which are "downloaded area" or "not".
For this status, s3fs makes new temporary file in cache directory which is
specified by "use_cache" option. This status files is in a directory which is
named "<use_cache sirectory>/.<bucket_name>/".
When s3fs opens this status file, s3fs locks this file for exclusive control by
calling flock function. You need to take care about this, the status files can
not be laid on network drive(like NFS).
This revision changes about file open mode, s3fs always opens a local cache
file and each status file with writable mode.
Last, this revision adds new option "del_cache", this option means that s3fs
deletes all local cache file when s3fs starts and exits.
3) Uploading
When s3fs writes data to file descriptor through FUSE request, old s3fs
revision downloads all of the object. But new revision does not download all,
it downloads only small percial area(some block units) including writing data
area.
And when s3fs closes or flushes the file descriptor, s3fs downloads other area
which is not downloaded from server. After that, s3fs uploads all of data.
Already r456 revision has parallel upload function, then this revision with
r456 and r457 are very big change for performance.
4) Downloading
By changing a temporary file and a local cache file, when s3fs downloads a
object, it downloads only the required range(some block units).
And s3fs downloads units by parallel GET request, it is same as a case of
uploading. (Maximum parallel request count and each download size are
specified same parameters for uploading.)
In the new revision, when s3fs opens file, s3fs returns file descriptor soon.
Because s3fs only opens(makes) the file descriptor with no downloading
data. And when s3fs reads a data, s3fs downloads only some block unit
including specified area.
This result is good for performance.
5) Changes option name
The option "parallel_upload" which added at r456 is changed to new option
name as "parallel_count". This reason is this option value is not only used by
uploading object, but a uploading object also uses this option. (For a while,
you can use old option name "parallel_upload" for compatibility.)
git-svn-id: http://s3fs.googlecode.com/svn/trunk@458 df820570-a93a-0410-bd06-b72b767a4274
2013-07-23 16:01:48 +00:00
|
|
|
static size_t DownloadWriteCallback(void* ptr, size_t size, size_t nmemb, void* userp);
|
2013-07-05 02:28:31 +00:00
|
|
|
|
2013-07-10 06:24:06 +00:00
|
|
|
static bool UploadMultipartPostCallback(S3fsCurl* s3fscurl);
|
2019-01-29 07:39:11 +00:00
|
|
|
static bool CopyMultipartPostCallback(S3fsCurl* s3fscurl);
|
2019-09-26 02:30:58 +00:00
|
|
|
static bool MixMultipartPostCallback(S3fsCurl* s3fscurl);
|
2013-07-10 06:24:06 +00:00
|
|
|
static S3fsCurl* UploadMultipartPostRetryCallback(S3fsCurl* s3fscurl);
|
2019-01-29 07:39:11 +00:00
|
|
|
static S3fsCurl* CopyMultipartPostRetryCallback(S3fsCurl* s3fscurl);
|
2019-09-26 02:30:58 +00:00
|
|
|
static S3fsCurl* MixMultipartPostRetryCallback(S3fsCurl* s3fscurl);
|
Changes codes for performance(part 3)
* Summay
This revision includes big change about temporary file and local cache file.
By this big change, s3fs works with good performance when s3fs opens/
closes/syncs/reads object.
I made a big change about the handling about temporary file and local cache
file to do this implementation.
* Detail
1) About temporary file(local file)
s3fs uses a temporary file on local file system when s3fs does download/
upload/open/seek object on S3.
After this revision, s3fs calls ftruncate() function when s3fs makes the
temporary file.
In this way s3fs can set a file size of precisely length without downloading.
(Notice - ftruncate function is for XSI-compliant systems, so that possibly
you have a problem on non-XSI-compliant systems.)
By this change, s3fs can download a part of a object by requesting with
"Range" http header. It seems like downloading by each block unit.
The default block(part) size is 50MB, it is caused the result which is default
parallel requests count(5) by default multipart upload size(10MB).
If you need to change this block size, you can change by new option
"fd_page_size". This option can take from 1MB(1024 * 1024) to any bytes.
So that, you have to take care about that fdcache.cpp(and fdcache.h) were
changed a lot.
2) About local cache
Local cache files which are in directory specified by "use_cache" option do
not have always all of object data.
This cause is that s3fs uses ftruncate function and reads(writes) each block
unit of a temporary file.
s3fs manages each block unit's status which are "downloaded area" or "not".
For this status, s3fs makes new temporary file in cache directory which is
specified by "use_cache" option. This status files is in a directory which is
named "<use_cache sirectory>/.<bucket_name>/".
When s3fs opens this status file, s3fs locks this file for exclusive control by
calling flock function. You need to take care about this, the status files can
not be laid on network drive(like NFS).
This revision changes about file open mode, s3fs always opens a local cache
file and each status file with writable mode.
Last, this revision adds new option "del_cache", this option means that s3fs
deletes all local cache file when s3fs starts and exits.
3) Uploading
When s3fs writes data to file descriptor through FUSE request, old s3fs
revision downloads all of the object. But new revision does not download all,
it downloads only small percial area(some block units) including writing data
area.
And when s3fs closes or flushes the file descriptor, s3fs downloads other area
which is not downloaded from server. After that, s3fs uploads all of data.
Already r456 revision has parallel upload function, then this revision with
r456 and r457 are very big change for performance.
4) Downloading
By changing a temporary file and a local cache file, when s3fs downloads a
object, it downloads only the required range(some block units).
And s3fs downloads units by parallel GET request, it is same as a case of
uploading. (Maximum parallel request count and each download size are
specified same parameters for uploading.)
In the new revision, when s3fs opens file, s3fs returns file descriptor soon.
Because s3fs only opens(makes) the file descriptor with no downloading
data. And when s3fs reads a data, s3fs downloads only some block unit
including specified area.
This result is good for performance.
5) Changes option name
The option "parallel_upload" which added at r456 is changed to new option
name as "parallel_count". This reason is this option value is not only used by
uploading object, but a uploading object also uses this option. (For a while,
you can use old option name "parallel_upload" for compatibility.)
git-svn-id: http://s3fs.googlecode.com/svn/trunk@458 df820570-a93a-0410-bd06-b72b767a4274
2013-07-23 16:01:48 +00:00
|
|
|
static S3fsCurl* ParallelGetObjectRetryCallback(S3fsCurl* s3fscurl);
|
2013-07-10 06:24:06 +00:00
|
|
|
|
2019-03-09 08:45:10 +00:00
|
|
|
// lazy functions for set curl options
|
2019-02-25 12:47:10 +00:00
|
|
|
static bool UploadMultipartPostSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
static bool CopyMultipartPostSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
static bool PreGetObjectRequestSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
static bool PreHeadRequestSetCurlOpts(S3fsCurl* s3fscurl);
|
|
|
|
|
2013-10-06 13:45:32 +00:00
|
|
|
static bool ParseIAMCredentialResponse(const char* response, iamcredmap_t& keyval);
|
|
|
|
static bool SetIAMCredentials(const char* response);
|
2016-05-06 04:37:32 +00:00
|
|
|
static bool ParseIAMRoleFromMetaDataResponse(const char* response, std::string& rolename);
|
|
|
|
static bool SetIAMRoleFromMetaData(const char* response);
|
2015-10-06 14:46:14 +00:00
|
|
|
static bool LoadEnvSseCKeys(void);
|
|
|
|
static bool LoadEnvSseKmsid(void);
|
2014-08-26 17:11:10 +00:00
|
|
|
static bool PushbackSseKeys(std::string& onekey);
|
2016-04-17 07:44:03 +00:00
|
|
|
static bool AddUserAgent(CURL* hCurl);
|
2013-10-06 13:45:32 +00:00
|
|
|
|
2015-09-30 19:41:27 +00:00
|
|
|
static int CurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
2020-05-24 07:23:27 +00:00
|
|
|
static int CurlDebugBodyInFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
|
|
|
static int CurlDebugBodyOutFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr);
|
|
|
|
static int RawCurlDebugFunc(CURL* hcurl, curl_infotype type, char* data, size_t size, void* userptr, curl_infotype datatype);
|
2015-09-30 19:41:27 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
// methods
|
2020-08-17 00:10:49 +00:00
|
|
|
bool ResetHandle(bool lock_already_held = false);
|
2013-08-21 07:43:32 +00:00
|
|
|
bool RemakeHandle(void);
|
2013-07-05 02:28:31 +00:00
|
|
|
bool ClearInternalData(void);
|
2017-10-26 14:21:48 +00:00
|
|
|
void insertV4Headers();
|
|
|
|
void insertV2Headers();
|
2017-11-23 08:46:24 +00:00
|
|
|
void insertIBMIAMHeaders();
|
2017-10-26 14:21:48 +00:00
|
|
|
void insertAuthHeaders();
|
2015-08-17 04:42:45 +00:00
|
|
|
std::string CalcSignatureV2(const std::string& method, const std::string& strMD5, const std::string& content_type, const std::string& date, const std::string& resource);
|
|
|
|
std::string CalcSignature(const std::string& method, const std::string& canonical_uri, const std::string& query_string, const std::string& strdate, const std::string& payload_hash, const std::string& date8601);
|
2013-10-06 13:45:32 +00:00
|
|
|
int GetIAMCredentials(void);
|
2013-07-05 02:28:31 +00:00
|
|
|
|
2015-08-17 04:42:45 +00:00
|
|
|
int UploadMultipartPostSetup(const char* tpath, int part_num, const std::string& upload_id);
|
2019-09-23 10:49:49 +00:00
|
|
|
int CopyMultipartPostSetup(const char* from, const char* to, int part_num, const std::string& upload_id, headers_t& meta);
|
2017-04-02 07:27:43 +00:00
|
|
|
bool UploadMultipartPostComplete();
|
2019-01-29 07:39:11 +00:00
|
|
|
bool CopyMultipartPostComplete();
|
2019-09-26 02:30:58 +00:00
|
|
|
bool MixMultipartPostComplete();
|
2013-06-15 15:29:08 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
public:
|
|
|
|
// class methods
|
2020-03-19 15:13:21 +00:00
|
|
|
static bool InitS3fsCurl(void);
|
|
|
|
static bool InitMimeType(const std::string& strFile);
|
2013-08-27 08:12:01 +00:00
|
|
|
static bool DestroyS3fsCurl(void);
|
2014-08-26 17:11:10 +00:00
|
|
|
static int ParallelMultipartUploadRequest(const char* tpath, headers_t& meta, int fd);
|
2020-06-21 18:04:49 +00:00
|
|
|
static int ParallelMixMultipartUploadRequest(const char* tpath, headers_t& meta, int fd, const fdpage_list_t& mixuppages);
|
Changes codes for performance(part 3)
* Summay
This revision includes big change about temporary file and local cache file.
By this big change, s3fs works with good performance when s3fs opens/
closes/syncs/reads object.
I made a big change about the handling about temporary file and local cache
file to do this implementation.
* Detail
1) About temporary file(local file)
s3fs uses a temporary file on local file system when s3fs does download/
upload/open/seek object on S3.
After this revision, s3fs calls ftruncate() function when s3fs makes the
temporary file.
In this way s3fs can set a file size of precisely length without downloading.
(Notice - ftruncate function is for XSI-compliant systems, so that possibly
you have a problem on non-XSI-compliant systems.)
By this change, s3fs can download a part of a object by requesting with
"Range" http header. It seems like downloading by each block unit.
The default block(part) size is 50MB, it is caused the result which is default
parallel requests count(5) by default multipart upload size(10MB).
If you need to change this block size, you can change by new option
"fd_page_size". This option can take from 1MB(1024 * 1024) to any bytes.
So that, you have to take care about that fdcache.cpp(and fdcache.h) were
changed a lot.
2) About local cache
Local cache files which are in directory specified by "use_cache" option do
not have always all of object data.
This cause is that s3fs uses ftruncate function and reads(writes) each block
unit of a temporary file.
s3fs manages each block unit's status which are "downloaded area" or "not".
For this status, s3fs makes new temporary file in cache directory which is
specified by "use_cache" option. This status files is in a directory which is
named "<use_cache sirectory>/.<bucket_name>/".
When s3fs opens this status file, s3fs locks this file for exclusive control by
calling flock function. You need to take care about this, the status files can
not be laid on network drive(like NFS).
This revision changes about file open mode, s3fs always opens a local cache
file and each status file with writable mode.
Last, this revision adds new option "del_cache", this option means that s3fs
deletes all local cache file when s3fs starts and exits.
3) Uploading
When s3fs writes data to file descriptor through FUSE request, old s3fs
revision downloads all of the object. But new revision does not download all,
it downloads only small percial area(some block units) including writing data
area.
And when s3fs closes or flushes the file descriptor, s3fs downloads other area
which is not downloaded from server. After that, s3fs uploads all of data.
Already r456 revision has parallel upload function, then this revision with
r456 and r457 are very big change for performance.
4) Downloading
By changing a temporary file and a local cache file, when s3fs downloads a
object, it downloads only the required range(some block units).
And s3fs downloads units by parallel GET request, it is same as a case of
uploading. (Maximum parallel request count and each download size are
specified same parameters for uploading.)
In the new revision, when s3fs opens file, s3fs returns file descriptor soon.
Because s3fs only opens(makes) the file descriptor with no downloading
data. And when s3fs reads a data, s3fs downloads only some block unit
including specified area.
This result is good for performance.
5) Changes option name
The option "parallel_upload" which added at r456 is changed to new option
name as "parallel_count". This reason is this option value is not only used by
uploading object, but a uploading object also uses this option. (For a while,
you can use old option name "parallel_upload" for compatibility.)
git-svn-id: http://s3fs.googlecode.com/svn/trunk@458 df820570-a93a-0410-bd06-b72b767a4274
2013-07-23 16:01:48 +00:00
|
|
|
static int ParallelGetObjectRequest(const char* tpath, int fd, off_t start, ssize_t size);
|
2013-10-06 13:45:32 +00:00
|
|
|
static bool CheckIAMCredentialUpdate(void);
|
2013-07-05 02:28:31 +00:00
|
|
|
|
2014-04-05 05:11:55 +00:00
|
|
|
// class methods(variables)
|
2015-08-17 04:42:45 +00:00
|
|
|
static std::string LookupMimeType(const std::string& name);
|
2015-05-20 15:32:36 +00:00
|
|
|
static bool SetCheckCertificate(bool isCertCheck);
|
2013-07-05 02:28:31 +00:00
|
|
|
static bool SetDnsCache(bool isCache);
|
2013-09-14 21:50:39 +00:00
|
|
|
static bool SetSslSessionCache(bool isCache);
|
2013-07-05 02:28:31 +00:00
|
|
|
static long SetConnectTimeout(long timeout);
|
|
|
|
static time_t SetReadwriteTimeout(time_t timeout);
|
|
|
|
static time_t GetReadwriteTimeout(void) { return S3fsCurl::readwrite_timeout; }
|
|
|
|
static int SetRetries(int count);
|
|
|
|
static bool SetPublicBucket(bool flag);
|
|
|
|
static bool IsPublicBucket(void) { return S3fsCurl::is_public_bucket; }
|
2019-08-09 20:51:01 +00:00
|
|
|
static acl_t SetDefaultAcl(acl_t acl);
|
|
|
|
static acl_t GetDefaultAcl();
|
2015-09-17 20:10:45 +00:00
|
|
|
static storage_class_t SetStorageClass(storage_class_t storage_class);
|
|
|
|
static storage_class_t GetStorageClass() { return S3fsCurl::storage_class; }
|
2015-10-06 14:46:14 +00:00
|
|
|
static bool LoadEnvSse(void) { return (S3fsCurl::LoadEnvSseCKeys() && S3fsCurl::LoadEnvSseKmsid()); }
|
|
|
|
static sse_type_t SetSseType(sse_type_t type);
|
|
|
|
static sse_type_t GetSseType(void) { return S3fsCurl::ssetype; }
|
2020-08-20 02:09:49 +00:00
|
|
|
static bool IsSseDisable(void) { return (sse_type_t::SSE_DISABLE == S3fsCurl::ssetype); }
|
|
|
|
static bool IsSseS3Type(void) { return (sse_type_t::SSE_S3 == S3fsCurl::ssetype); }
|
|
|
|
static bool IsSseCType(void) { return (sse_type_t::SSE_C == S3fsCurl::ssetype); }
|
|
|
|
static bool IsSseKmsType(void) { return (sse_type_t::SSE_KMS == S3fsCurl::ssetype); }
|
2015-10-06 14:46:14 +00:00
|
|
|
static bool FinalCheckSse(void);
|
|
|
|
static bool SetSseCKeys(const char* filepath);
|
|
|
|
static bool SetSseKmsid(const char* kmsid);
|
|
|
|
static bool IsSetSseKmsId(void) { return !S3fsCurl::ssekmsid.empty(); }
|
|
|
|
static const char* GetSseKmsId(void) { return S3fsCurl::ssekmsid.c_str(); }
|
2014-07-19 19:02:55 +00:00
|
|
|
static bool GetSseKey(std::string& md5, std::string& ssekey);
|
|
|
|
static bool GetSseKeyMd5(int pos, std::string& md5);
|
|
|
|
static int GetSseKeyCount(void);
|
2013-07-05 02:28:31 +00:00
|
|
|
static bool SetContentMd5(bool flag);
|
2013-08-23 16:28:50 +00:00
|
|
|
static bool SetVerbose(bool flag);
|
|
|
|
static bool GetVerbose(void) { return S3fsCurl::is_verbose; }
|
2020-05-24 07:23:27 +00:00
|
|
|
static bool SetDumpBody(bool flag);
|
|
|
|
static bool IsDumpBody(void) { return S3fsCurl::is_dump_body; }
|
2013-07-05 02:28:31 +00:00
|
|
|
static bool SetAccessKey(const char* AccessKeyId, const char* SecretAccessKey);
|
2019-04-14 16:19:34 +00:00
|
|
|
static bool SetAccessKeyWithSessionToken(const char* AccessKeyId, const char* SecretAccessKey, const char * SessionToken);
|
2017-11-23 08:46:24 +00:00
|
|
|
static bool IsSetAccessKeyID(void){
|
|
|
|
return (0 < S3fsCurl::AWSAccessKeyId.size());
|
|
|
|
}
|
|
|
|
static bool IsSetAccessKeys(void){
|
|
|
|
return (0 < S3fsCurl::IAM_role.size() || ((0 < S3fsCurl::AWSAccessKeyId.size() || S3fsCurl::is_ibm_iam_auth) && 0 < S3fsCurl::AWSSecretAccessKey.size()));
|
2013-10-06 13:45:32 +00:00
|
|
|
}
|
2013-07-05 02:28:31 +00:00
|
|
|
static long SetSslVerifyHostname(long value);
|
|
|
|
static long GetSslVerifyHostname(void) { return S3fsCurl::ssl_verify_hostname; }
|
2019-01-19 01:16:56 +00:00
|
|
|
// maximum parallel GET and PUT requests
|
Changes codes for performance(part 3)
* Summay
This revision includes big change about temporary file and local cache file.
By this big change, s3fs works with good performance when s3fs opens/
closes/syncs/reads object.
I made a big change about the handling about temporary file and local cache
file to do this implementation.
* Detail
1) About temporary file(local file)
s3fs uses a temporary file on local file system when s3fs does download/
upload/open/seek object on S3.
After this revision, s3fs calls ftruncate() function when s3fs makes the
temporary file.
In this way s3fs can set a file size of precisely length without downloading.
(Notice - ftruncate function is for XSI-compliant systems, so that possibly
you have a problem on non-XSI-compliant systems.)
By this change, s3fs can download a part of a object by requesting with
"Range" http header. It seems like downloading by each block unit.
The default block(part) size is 50MB, it is caused the result which is default
parallel requests count(5) by default multipart upload size(10MB).
If you need to change this block size, you can change by new option
"fd_page_size". This option can take from 1MB(1024 * 1024) to any bytes.
So that, you have to take care about that fdcache.cpp(and fdcache.h) were
changed a lot.
2) About local cache
Local cache files which are in directory specified by "use_cache" option do
not have always all of object data.
This cause is that s3fs uses ftruncate function and reads(writes) each block
unit of a temporary file.
s3fs manages each block unit's status which are "downloaded area" or "not".
For this status, s3fs makes new temporary file in cache directory which is
specified by "use_cache" option. This status files is in a directory which is
named "<use_cache sirectory>/.<bucket_name>/".
When s3fs opens this status file, s3fs locks this file for exclusive control by
calling flock function. You need to take care about this, the status files can
not be laid on network drive(like NFS).
This revision changes about file open mode, s3fs always opens a local cache
file and each status file with writable mode.
Last, this revision adds new option "del_cache", this option means that s3fs
deletes all local cache file when s3fs starts and exits.
3) Uploading
When s3fs writes data to file descriptor through FUSE request, old s3fs
revision downloads all of the object. But new revision does not download all,
it downloads only small percial area(some block units) including writing data
area.
And when s3fs closes or flushes the file descriptor, s3fs downloads other area
which is not downloaded from server. After that, s3fs uploads all of data.
Already r456 revision has parallel upload function, then this revision with
r456 and r457 are very big change for performance.
4) Downloading
By changing a temporary file and a local cache file, when s3fs downloads a
object, it downloads only the required range(some block units).
And s3fs downloads units by parallel GET request, it is same as a case of
uploading. (Maximum parallel request count and each download size are
specified same parameters for uploading.)
In the new revision, when s3fs opens file, s3fs returns file descriptor soon.
Because s3fs only opens(makes) the file descriptor with no downloading
data. And when s3fs reads a data, s3fs downloads only some block unit
including specified area.
This result is good for performance.
5) Changes option name
The option "parallel_upload" which added at r456 is changed to new option
name as "parallel_count". This reason is this option value is not only used by
uploading object, but a uploading object also uses this option. (For a while,
you can use old option name "parallel_upload" for compatibility.)
git-svn-id: http://s3fs.googlecode.com/svn/trunk@458 df820570-a93a-0410-bd06-b72b767a4274
2013-07-23 16:01:48 +00:00
|
|
|
static int SetMaxParallelCount(int value);
|
2014-03-30 07:53:41 +00:00
|
|
|
static int GetMaxParallelCount(void) { return S3fsCurl::max_parallel_cnt; }
|
2019-01-19 01:16:56 +00:00
|
|
|
// maximum parallel HEAD requests
|
|
|
|
static int SetMaxMultiRequest(int max);
|
|
|
|
static int GetMaxMultiRequest(void) { return S3fsCurl::max_multireq; }
|
2017-11-05 19:24:02 +00:00
|
|
|
static bool SetIsECS(bool flag);
|
2017-11-23 08:46:24 +00:00
|
|
|
static bool SetIsIBMIAMAuth(bool flag);
|
|
|
|
static size_t SetIAMFieldCount(size_t field_count);
|
|
|
|
static std::string SetIAMCredentialsURL(const char* url);
|
|
|
|
static std::string SetIAMTokenField(const char* token_field);
|
|
|
|
static std::string SetIAMExpiryField(const char* expiry_field);
|
2013-10-06 13:45:32 +00:00
|
|
|
static std::string SetIAMRole(const char* role);
|
|
|
|
static const char* GetIAMRole(void) { return S3fsCurl::IAM_role.c_str(); }
|
2014-03-30 07:53:41 +00:00
|
|
|
static bool SetMultipartSize(off_t size);
|
|
|
|
static off_t GetMultipartSize(void) { return S3fsCurl::multipart_size; }
|
2015-02-17 00:49:53 +00:00
|
|
|
static bool SetSignatureV4(bool isset) { bool bresult = S3fsCurl::is_sigv4; S3fsCurl::is_sigv4 = isset; return bresult; }
|
2015-01-28 17:13:11 +00:00
|
|
|
static bool IsSignatureV4(void) { return S3fsCurl::is_sigv4; }
|
2016-04-17 07:44:03 +00:00
|
|
|
static bool SetUserAgentFlag(bool isset) { bool bresult = S3fsCurl::is_ua; S3fsCurl::is_ua = isset; return bresult; }
|
|
|
|
static bool IsUserAgentFlag(void) { return S3fsCurl::is_ua; }
|
2017-09-17 09:16:05 +00:00
|
|
|
static void InitUserAgent(void);
|
2019-11-18 11:38:16 +00:00
|
|
|
static bool SetRequesterPays(bool flag) { bool old_flag = S3fsCurl::requester_pays; S3fsCurl::requester_pays = flag; return old_flag; }
|
|
|
|
static bool IsRequesterPays(void) { return S3fsCurl::requester_pays; }
|
2013-07-05 02:28:31 +00:00
|
|
|
|
|
|
|
// methods
|
2019-02-25 12:47:10 +00:00
|
|
|
bool CreateCurlHandle(bool only_pool = false, bool remake = false);
|
|
|
|
bool DestroyCurlHandle(bool restore_pool = true, bool clear_internal_data = true);
|
2013-07-05 02:28:31 +00:00
|
|
|
|
2016-05-06 04:37:32 +00:00
|
|
|
bool LoadIAMRoleFromMetaData(void);
|
2015-10-06 14:46:14 +00:00
|
|
|
bool AddSseRequestHead(sse_type_t ssetype, std::string& ssevalue, bool is_only_c, bool is_copy);
|
2019-02-25 12:47:10 +00:00
|
|
|
bool GetResponseCode(long& responseCode, bool from_curl_handle = true);
|
2020-01-31 07:48:37 +00:00
|
|
|
int RequestPerform(bool dontAddAuthHeaders=false);
|
2013-07-05 02:28:31 +00:00
|
|
|
int DeleteRequest(const char* tpath);
|
2014-07-19 19:02:55 +00:00
|
|
|
bool PreHeadRequest(const char* tpath, const char* bpath = NULL, const char* savedpath = NULL, int ssekey_pos = -1);
|
|
|
|
bool PreHeadRequest(std::string& tpath, std::string& bpath, std::string& savedpath, int ssekey_pos = -1) {
|
|
|
|
return PreHeadRequest(tpath.c_str(), bpath.c_str(), savedpath.c_str(), ssekey_pos);
|
2013-06-15 15:29:08 +00:00
|
|
|
}
|
2013-07-05 02:28:31 +00:00
|
|
|
int HeadRequest(const char* tpath, headers_t& meta);
|
2014-08-26 17:11:10 +00:00
|
|
|
int PutHeadRequest(const char* tpath, headers_t& meta, bool is_copy);
|
|
|
|
int PutRequest(const char* tpath, headers_t& meta, int fd);
|
2015-10-06 14:46:14 +00:00
|
|
|
int PreGetObjectRequest(const char* tpath, int fd, off_t start, ssize_t size, sse_type_t ssetype, std::string& ssevalue);
|
Changes codes for performance(part 3)
* Summay
This revision includes big change about temporary file and local cache file.
By this big change, s3fs works with good performance when s3fs opens/
closes/syncs/reads object.
I made a big change about the handling about temporary file and local cache
file to do this implementation.
* Detail
1) About temporary file(local file)
s3fs uses a temporary file on local file system when s3fs does download/
upload/open/seek object on S3.
After this revision, s3fs calls ftruncate() function when s3fs makes the
temporary file.
In this way s3fs can set a file size of precisely length without downloading.
(Notice - ftruncate function is for XSI-compliant systems, so that possibly
you have a problem on non-XSI-compliant systems.)
By this change, s3fs can download a part of a object by requesting with
"Range" http header. It seems like downloading by each block unit.
The default block(part) size is 50MB, it is caused the result which is default
parallel requests count(5) by default multipart upload size(10MB).
If you need to change this block size, you can change by new option
"fd_page_size". This option can take from 1MB(1024 * 1024) to any bytes.
So that, you have to take care about that fdcache.cpp(and fdcache.h) were
changed a lot.
2) About local cache
Local cache files which are in directory specified by "use_cache" option do
not have always all of object data.
This cause is that s3fs uses ftruncate function and reads(writes) each block
unit of a temporary file.
s3fs manages each block unit's status which are "downloaded area" or "not".
For this status, s3fs makes new temporary file in cache directory which is
specified by "use_cache" option. This status files is in a directory which is
named "<use_cache sirectory>/.<bucket_name>/".
When s3fs opens this status file, s3fs locks this file for exclusive control by
calling flock function. You need to take care about this, the status files can
not be laid on network drive(like NFS).
This revision changes about file open mode, s3fs always opens a local cache
file and each status file with writable mode.
Last, this revision adds new option "del_cache", this option means that s3fs
deletes all local cache file when s3fs starts and exits.
3) Uploading
When s3fs writes data to file descriptor through FUSE request, old s3fs
revision downloads all of the object. But new revision does not download all,
it downloads only small percial area(some block units) including writing data
area.
And when s3fs closes or flushes the file descriptor, s3fs downloads other area
which is not downloaded from server. After that, s3fs uploads all of data.
Already r456 revision has parallel upload function, then this revision with
r456 and r457 are very big change for performance.
4) Downloading
By changing a temporary file and a local cache file, when s3fs downloads a
object, it downloads only the required range(some block units).
And s3fs downloads units by parallel GET request, it is same as a case of
uploading. (Maximum parallel request count and each download size are
specified same parameters for uploading.)
In the new revision, when s3fs opens file, s3fs returns file descriptor soon.
Because s3fs only opens(makes) the file descriptor with no downloading
data. And when s3fs reads a data, s3fs downloads only some block unit
including specified area.
This result is good for performance.
5) Changes option name
The option "parallel_upload" which added at r456 is changed to new option
name as "parallel_count". This reason is this option value is not only used by
uploading object, but a uploading object also uses this option. (For a while,
you can use old option name "parallel_upload" for compatibility.)
git-svn-id: http://s3fs.googlecode.com/svn/trunk@458 df820570-a93a-0410-bd06-b72b767a4274
2013-07-23 16:01:48 +00:00
|
|
|
int GetObjectRequest(const char* tpath, int fd, off_t start = -1, ssize_t size = -1);
|
2013-07-05 02:28:31 +00:00
|
|
|
int CheckBucket(void);
|
|
|
|
int ListBucketRequest(const char* tpath, const char* query);
|
2015-10-18 17:03:41 +00:00
|
|
|
int PreMultipartPostRequest(const char* tpath, headers_t& meta, std::string& upload_id, bool is_copy);
|
2019-09-23 10:49:49 +00:00
|
|
|
int CompleteMultipartPostRequest(const char* tpath, const std::string& upload_id, etaglist_t& parts);
|
2015-08-17 04:42:45 +00:00
|
|
|
int UploadMultipartPostRequest(const char* tpath, int part_num, const std::string& upload_id);
|
2013-07-05 02:28:31 +00:00
|
|
|
int MultipartListRequest(std::string& body);
|
2019-09-23 10:49:49 +00:00
|
|
|
int AbortMultipartUpload(const char* tpath, const std::string& upload_id);
|
2014-08-26 17:11:10 +00:00
|
|
|
int MultipartHeadRequest(const char* tpath, off_t size, headers_t& meta, bool is_copy);
|
|
|
|
int MultipartUploadRequest(const char* tpath, headers_t& meta, int fd, bool is_copy);
|
2019-06-14 09:04:57 +00:00
|
|
|
int MultipartUploadRequest(const std::string& upload_id, const char* tpath, int fd, off_t offset, off_t size, etaglist_t& list);
|
2013-07-05 02:28:31 +00:00
|
|
|
int MultipartRenameRequest(const char* from, const char* to, headers_t& meta, off_t size);
|
|
|
|
|
2014-04-05 05:11:55 +00:00
|
|
|
// methods(variables)
|
2013-07-05 02:28:31 +00:00
|
|
|
CURL* GetCurlHandle(void) const { return hCurl; }
|
|
|
|
std::string GetPath(void) const { return path; }
|
|
|
|
std::string GetBasePath(void) const { return base_path; }
|
|
|
|
std::string GetSpacialSavedPath(void) const { return saved_path; }
|
|
|
|
std::string GetUrl(void) const { return url; }
|
2018-05-22 13:26:24 +00:00
|
|
|
std::string GetOp(void) const { return op; }
|
2013-07-05 02:28:31 +00:00
|
|
|
headers_t* GetResponseHeaders(void) { return &responseHeaders; }
|
2019-08-03 21:54:21 +00:00
|
|
|
BodyData* GetBodyData(void) { return &bodydata; }
|
|
|
|
BodyData* GetHeadData(void) { return &headdata; }
|
2013-07-05 02:28:31 +00:00
|
|
|
long GetLastResponseCode(void) const { return LastResponseCode; }
|
Fixed Issue 229 and Changes codes
1) Set metadata "Content-Encoding" automatically(Issue 292)
For this issue, s3fs is added new option "ahbe_conf".
New option means the configuration file path, and this file specifies
additional HTTP header by file(object) extension.
Thus you can specify any HTTP header for each object by extension.
* ahbe_conf file format:
-----------
line = [file suffix] HTTP-header [HTTP-header-values]
file suffix = file(object) suffix, if this field is empty,
it means "*"(all object).
HTTP-header = additional HTTP header name
HTTP-header-values = additional HTTP header value
-----------
* Example:
-----------
.gz Content-Encoding gzip
.Z Content-Encoding compress
X-S3FS-MYHTTPHEAD myvalue
-----------
A sample configuration file is uploaded in "test" directory.
If ahbe_conf parameter is specified, s3fs loads it's configuration
and compares extension(suffix) of object(file) when uploading
(PUT/POST) it. If the extension is same, s3fs adds/sends specified
HTTP header and value.
A case of sample configuration file, if a object(it's extension is
".gz") which already has Content-Encoding HTTP header is renamed
to ".txt" extension, s3fs does not set Content-Encoding. Because
".txt" is not match any line in configuration file.
So, s3fs matches the extension by each PUT/POST action.
* Please take care about "Content-Encoding".
This new option allows setting ANY HTTP header by object extension.
For example, you can specify "Content-Encoding" for ".gz"/etc
extension in configuration. But this means that S3 always returns
"Content-Encoding: gzip" when a client requests with other
"Accept-Encoding:" header. It SHOULD NOT be good.
Please see RFC 2616.
2) Changes about allow_other/uid/gid option for mount point
I reviewed about mount point permission and allow_other/uid/gid
options, and found bugs about these.
s3fs is fixed bugs and changed to the following specifications.
* s3fs only allows uid(gid) options as 0(root), when the effective
user is zero(root).
* A mount point(directory) must have a permission to allow
accessing by effective user/group.
* If allow_other option is specified, the mount point permission
is set 0777(all users allow all access).
In another case, the mount point is set 0700(only allows
effective user).
* When uid/gid option is specified, the mount point owner/group
is set uid/gid option value.
If uid/gid is not set, it is set effective user/group id.
This changes maybe fixes some issue(321, 338).
3) Changes a logic about (Issue 229)
The chmod command returns -EIO when changing the mount point.
It is correct, s3fs can not changed owner/group/mtime for the
mount point, but s3fs sends a request for changing the bucket.
This revision does not send the request, and returns EIO as
soon as possible.
git-svn-id: http://s3fs.googlecode.com/svn/trunk@465 df820570-a93a-0410-bd06-b72b767a4274
2013-08-16 19:24:01 +00:00
|
|
|
bool SetUseAhbe(bool ahbe);
|
|
|
|
bool EnableUseAhbe(void) { return SetUseAhbe(true); }
|
|
|
|
bool DisableUseAhbe(void) { return SetUseAhbe(false); }
|
|
|
|
bool IsUseAhbe(void) const { return is_use_ahbe; }
|
2013-11-11 13:45:35 +00:00
|
|
|
int GetMultipartRetryCount(void) const { return retry_count; }
|
|
|
|
void SetMultipartRetryCount(int retrycnt) { retry_count = retrycnt; }
|
|
|
|
bool IsOverMultipartRetryCount(void) const { return (retry_count >= S3fsCurl::retries); }
|
2014-07-19 19:02:55 +00:00
|
|
|
int GetLastPreHeadSeecKeyPos(void) const { return b_ssekey_pos; }
|
2013-03-30 13:37:14 +00:00
|
|
|
};
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// class S3fsMultiCurl
|
|
|
|
//----------------------------------------------
|
|
|
|
// Class for lapping multi curl
|
|
|
|
//
|
2019-02-25 12:47:10 +00:00
|
|
|
typedef std::vector<S3fsCurl*> s3fscurllist_t;
|
2013-07-05 02:28:31 +00:00
|
|
|
typedef bool (*S3fsMultiSuccessCallback)(S3fsCurl* s3fscurl); // callback for succeed multi request
|
2014-10-01 10:42:39 +00:00
|
|
|
typedef S3fsCurl* (*S3fsMultiRetryCallback)(S3fsCurl* s3fscurl); // callback for failure and retrying
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
class S3fsMultiCurl
|
|
|
|
{
|
|
|
|
private:
|
2019-01-19 01:16:56 +00:00
|
|
|
const int maxParallelism;
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2019-02-25 12:47:10 +00:00
|
|
|
s3fscurllist_t clist_all; // all of curl requests
|
|
|
|
s3fscurllist_t clist_req; // curl requests are sent
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
S3fsMultiSuccessCallback SuccessCallback;
|
|
|
|
S3fsMultiRetryCallback RetryCallback;
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2019-01-28 20:14:04 +00:00
|
|
|
pthread_mutex_t completed_tids_lock;
|
|
|
|
std::vector<pthread_t> completed_tids;
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
private:
|
2013-09-14 21:50:39 +00:00
|
|
|
bool ClearEx(bool is_all);
|
2013-07-05 02:28:31 +00:00
|
|
|
int MultiPerform(void);
|
|
|
|
int MultiRead(void);
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2017-03-29 07:13:05 +00:00
|
|
|
static void* RequestPerformWrapper(void* arg);
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
public:
|
2019-01-19 01:16:56 +00:00
|
|
|
explicit S3fsMultiCurl(int maxParallelism);
|
2013-07-05 02:28:31 +00:00
|
|
|
~S3fsMultiCurl();
|
2013-03-30 13:37:14 +00:00
|
|
|
|
2019-01-19 01:16:56 +00:00
|
|
|
int GetMaxParallelism() { return maxParallelism; }
|
2013-05-27 01:15:48 +00:00
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
S3fsMultiSuccessCallback SetSuccessCallback(S3fsMultiSuccessCallback function);
|
|
|
|
S3fsMultiRetryCallback SetRetryCallback(S3fsMultiRetryCallback function);
|
2013-09-14 21:50:39 +00:00
|
|
|
bool Clear(void) { return ClearEx(true); }
|
2013-07-05 02:28:31 +00:00
|
|
|
bool SetS3fsCurlObject(S3fsCurl* s3fscurl);
|
|
|
|
int Request(void);
|
2013-03-30 13:37:14 +00:00
|
|
|
};
|
|
|
|
|
2013-07-05 02:28:31 +00:00
|
|
|
//----------------------------------------------
|
|
|
|
// Utility Functions
|
|
|
|
//----------------------------------------------
|
2013-05-16 02:02:55 +00:00
|
|
|
std::string GetContentMD5(int fd);
|
2013-08-19 06:29:24 +00:00
|
|
|
unsigned char* md5hexsum(int fd, off_t start, ssize_t size);
|
|
|
|
std::string md5sum(int fd, off_t start, ssize_t size);
|
2013-07-05 02:28:31 +00:00
|
|
|
struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* data);
|
2015-01-28 17:13:11 +00:00
|
|
|
struct curl_slist* curl_slist_sort_insert(struct curl_slist* list, const char* key, const char* value);
|
|
|
|
std::string get_sorted_header_keys(const struct curl_slist* list);
|
|
|
|
std::string get_canonical_headers(const struct curl_slist* list, bool only_amz = false);
|
2017-10-26 14:21:48 +00:00
|
|
|
std::string get_header_value(const struct curl_slist* list, const std::string &key);
|
2013-07-05 02:28:31 +00:00
|
|
|
bool MakeUrlResource(const char* realpath, std::string& resourcepath, std::string& url);
|
2014-12-06 23:51:36 +00:00
|
|
|
std::string prepare_url(const char* url);
|
2015-10-06 14:46:14 +00:00
|
|
|
bool get_object_sse_type(const char* path, sse_type_t& ssetype, std::string& ssevalue); // implement in s3fs.cpp
|
2011-03-01 19:35:55 +00:00
|
|
|
|
|
|
|
#endif // S3FS_CURL_H_
|
2014-09-07 15:08:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
2020-08-19 12:03:46 +00:00
|
|
|
* tab-width: 2
|
|
|
|
* c-basic-offset: 2
|
2014-09-07 15:08:27 +00:00
|
|
|
* End:
|
2020-08-19 12:03:46 +00:00
|
|
|
* vim600: expandtab sw=2 ts=2 fdm=marker
|
|
|
|
* vim<600: expandtab sw=2 ts=2
|
2014-09-07 15:08:27 +00:00
|
|
|
*/
|