Fixed insufficient upload size for mix multipart upload

This commit is contained in:
Takeshi Nakatani 2020-04-20 14:31:22 +00:00 committed by Andrew Gaul
parent 2b4619842d
commit f26a0aa71d
2 changed files with 9 additions and 7 deletions

View File

@ -336,8 +336,10 @@ void PageList::Clear()
bool PageList::Init(off_t size, bool is_loaded, bool is_modified) bool PageList::Init(off_t size, bool is_loaded, bool is_modified)
{ {
Clear(); Clear();
fdpage page(0, size, is_loaded, is_modified); if(0 < size){
pages.push_back(page); fdpage page(0, size, is_loaded, is_modified);
pages.push_back(page);
}
return true; return true;
} }
@ -391,7 +393,7 @@ bool PageList::Parse(off_t new_pos)
// nothing to do // nothing to do
return true; return true;
}else if(iter->offset < new_pos && new_pos < iter->next()){ }else if(iter->offset < new_pos && new_pos < iter->next()){
fdpage page(iter->offset, new_pos - iter->offset, iter->loaded, false); fdpage page(iter->offset, new_pos - iter->offset, iter->loaded, iter->modified);
iter->bytes -= (new_pos - iter->offset); iter->bytes -= (new_pos - iter->offset);
iter->offset = new_pos; iter->offset = new_pos;
pages.insert(iter, page); pages.insert(iter, page);
@ -1732,7 +1734,7 @@ bool FdEntity::SetAllStatus(bool is_loaded)
return true; return true;
} }
int FdEntity::Load(off_t start, off_t size, bool lock_already_held) int FdEntity::Load(off_t start, off_t size, bool lock_already_held, bool is_modified_flag)
{ {
AutoLock auto_lock(&fdent_lock, lock_already_held ? AutoLock::ALREADY_LOCKED : AutoLock::NONE); AutoLock auto_lock(&fdent_lock, lock_already_held ? AutoLock::ALREADY_LOCKED : AutoLock::NONE);
@ -1777,7 +1779,7 @@ int FdEntity::Load(off_t start, off_t size, bool lock_already_held)
break; break;
} }
// Set loaded flag // Set loaded flag
pagelist.SetPageLoadedStatus(iter->offset, iter->bytes, PageList::PAGE_LOADED); pagelist.SetPageLoadedStatus(iter->offset, iter->bytes, (is_modified_flag ? PageList::PAGE_LOAD_MODIFIED : PageList::PAGE_LOADED));
} }
PageList::FreeList(unloaded_list); PageList::FreeList(unloaded_list);
} }
@ -2113,7 +2115,7 @@ int FdEntity::RowFlush(const char* tpath, bool force_sync)
return -1; return -1;
} }
for(fdpage_list_t::const_iterator iter = dlpages.begin(); iter != dlpages.end(); ++iter){ for(fdpage_list_t::const_iterator iter = dlpages.begin(); iter != dlpages.end(); ++iter){
if(0 != (result = Load(iter->offset, iter->bytes, true))){ if(0 != (result = Load(iter->offset, iter->bytes, /*lock_already_held=*/ true, /*is_modified_flag=*/ true))){ // set loaded and modified flag
S3FS_PRN_ERR("failed to get parts(start=%lld, size=%lld) before uploading.", static_cast<long long int>(iter->offset), static_cast<long long int>(iter->bytes)); S3FS_PRN_ERR("failed to get parts(start=%lld, size=%lld) before uploading.", static_cast<long long int>(iter->offset), static_cast<long long int>(iter->bytes));
return result; return result;
} }

View File

@ -189,7 +189,7 @@ class FdEntity
bool SetGId(gid_t gid); bool SetGId(gid_t gid);
bool SetContentType(const char* path); bool SetContentType(const char* path);
int Load(off_t start = 0, off_t size = 0, bool lock_already_held = false); // size=0 means loading to end int Load(off_t start = 0, off_t size = 0, bool lock_already_held = false, bool is_modified_flag = false); // size=0 means loading to end
int NoCacheLoadAndPost(off_t start = 0, off_t size = 0); // size=0 means loading to end int NoCacheLoadAndPost(off_t start = 0, off_t size = 0); // size=0 means loading to end
int NoCachePreMultipartPost(void); int NoCachePreMultipartPost(void);
int NoCacheMultipartPost(int tgfd, off_t start, off_t size); int NoCacheMultipartPost(int tgfd, off_t start, off_t size);