Skip to content

Commit

Permalink
Fixed a bug in exclusive control of pagelist in FdEntity class
Browse files Browse the repository at this point in the history
  • Loading branch information
ggtakec authored and gaul committed Sep 26, 2023
1 parent 361e10d commit d0c4b5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/fdcache_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ bool FdEntity::RenamePath(const std::string& newpath, std::string& fentmapkey)

bool FdEntity::IsModified() const
{
AutoLock auto_data_lock(&fdent_data_lock);
AutoLock auto_lock(&fdent_lock);
AutoLock auto_data_lock2(&fdent_data_lock);
return pagelist.IsModified();
}

Expand Down Expand Up @@ -1383,7 +1384,8 @@ int FdEntity::NoCacheCompleteMultipartPost(PseudoFdInfo* pseudo_obj)

off_t FdEntity::BytesModified()
{
AutoLock auto_lock(&fdent_data_lock);
AutoLock auto_lock(&fdent_lock);
AutoLock auto_lock2(&fdent_data_lock);
return pagelist.BytesModified();
}

Expand Down Expand Up @@ -2407,6 +2409,7 @@ bool FdEntity::MergeOrgMeta(headers_t& updatemeta)
SetAtime(atime, AutoLock::ALREADY_LOCKED);
}

AutoLock auto_lock2(&fdent_data_lock);
if(pending_status_t::NO_UPDATE_PENDING == pending_status && (IsUploading(AutoLock::ALREADY_LOCKED) || pagelist.IsModified())){
pending_status = pending_status_t::UPDATE_META_PENDING;
}
Expand Down Expand Up @@ -2492,7 +2495,8 @@ bool FdEntity::PunchHole(off_t start, size_t size)
{
S3FS_PRN_DBG("[path=%s][physical_fd=%d][offset=%lld][size=%zu]", path.c_str(), physical_fd, static_cast<long long int>(start), size);

AutoLock auto_lock(&fdent_data_lock);
AutoLock auto_lock(&fdent_lock);
AutoLock auto_lock2(&fdent_data_lock);

if(-1 == physical_fd){
return false;
Expand Down Expand Up @@ -2535,6 +2539,7 @@ bool FdEntity::PunchHole(off_t start, size_t size)
void FdEntity::MarkDirtyNewFile()
{
AutoLock auto_lock(&fdent_lock);
AutoLock auto_lock2(&fdent_data_lock);

pagelist.Init(0, false, true);
pending_status = pending_status_t::CREATE_FILE_PENDING;
Expand Down
3 changes: 2 additions & 1 deletion src/fdcache_entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class FdEntity
ssize_t WriteMixMultipart(PseudoFdInfo* pseudo_obj, const char* bytes, off_t start, size_t size);
ssize_t WriteStreamUpload(PseudoFdInfo* pseudo_obj, const char* bytes, off_t start, size_t size);

bool ReserveDiskSpace(off_t size);

bool AddUntreated(off_t start, off_t size);

public:
Expand Down Expand Up @@ -149,7 +151,6 @@ class FdEntity
ssize_t Read(int fd, char* bytes, off_t start, size_t size, bool force_load = false);
ssize_t Write(int fd, const char* bytes, off_t start, size_t size);

bool ReserveDiskSpace(off_t size);
bool PunchHole(off_t start = 0, size_t size = 0);

void MarkDirtyNewFile();
Expand Down

0 comments on commit d0c4b5c

Please sign in to comment.