fix mixupload return EntityTooSmall while a copypart is less than 5MB after split (#1809)

* fix  mixupload return EntityTooSmall while a copypart is less than 5MB after split
* fix possible part exceeds 5GB when multipart_copy_size is set to 5120MB
* Update curl.cpp
Co-authored-by: liubingrun <liubr1@chinatelecom.cn>
This commit is contained in:
LiuBingrun 2021-11-27 15:53:26 +08:00 committed by GitHub
parent 07e2e3f72a
commit 85ca2a3e45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1453,10 +1453,21 @@ int S3fsCurl::ParallelMixMultipartUploadRequest(const char* tpath, headers_t& me
}
}else{
// Multipart copy
for(off_t i = 0; i < iter->bytes; i += GetMultipartCopySize()){
for(off_t i = 0, bytes = 0; i < iter->bytes; i += bytes){
S3fsCurl* s3fscurl_para = new S3fsCurl(true);
off_t bytes = std::min(static_cast<off_t>(GetMultipartCopySize()), iter->bytes - i);
bytes = std::min(static_cast<off_t>(GetMultipartCopySize()), iter->bytes - i);
/* every part should be larger than MIN_MULTIPART_SIZE and smaller than FIVE_GB */
off_t remain_bytes = iter->bytes - i - bytes;
if ((MIN_MULTIPART_SIZE > remain_bytes) && (0 < remain_bytes)){
if(FIVE_GB < (bytes + remain_bytes)){
bytes = (bytes + remain_bytes)/2;
} else{
bytes += remain_bytes;
}
}
std::ostringstream strrange;
strrange << "bytes=" << (iter->offset + i) << "-" << (iter->offset + i + bytes - 1);
meta["x-amz-copy-source-range"] = strrange.str();