Skip to content

Commit

Permalink
curvefs/client: fix bug of io hang
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhongsong committed Apr 29, 2022
1 parent ae566eb commit 65bca6d
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions curvefs/src/client/s3/client_s3_cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ CURVEFS_ERROR FileCacheManager::Flush(bool force, bool toS3) {
};
std::vector<std::shared_ptr<FlushChunkCacheContext>> flushTasks;
auto iter = tmp.begin();
VLOG(6) << "flush size is: " << tmp.size();
VLOG(0) << "whs: flush size is: " << tmp.size();
for (; iter != tmp.end(); iter++) {
auto context = std::make_shared<FlushChunkCacheContext>();
context->inode = inode_;
Expand All @@ -999,13 +999,12 @@ CURVEFS_ERROR FileCacheManager::Flush(bool force, bool toS3) {
flushTasks.emplace_back(context);
}
pendingReq.fetch_add(flushTasks.size(), std::memory_order_seq_cst);
for (auto iter = flushTasks.begin();
iter != flushTasks.end(); ++iter) {
s3ClientAdaptor_->Enqueue(*iter);
}

if (pendingReq.load(std::memory_order_seq_cst)) {
VLOG(6) << "wait for pendingReq";
for (auto iter = flushTasks.begin();
iter != flushTasks.end(); ++iter) {
s3ClientAdaptor_->Enqueue(*iter);
}
cond.Wait();
}
VLOG(6) << "file cache flush over";
Expand Down

0 comments on commit 65bca6d

Please sign in to comment.