Skip to content

Commit

Permalink
curvefs/client: fix RefreshInode do not refresh when inode exist
Browse files Browse the repository at this point in the history
Signed-off-by: ilixiaocui <ilixiaocui@163.com>
  • Loading branch information
ilixiaocui committed Aug 10, 2022
1 parent 207f26b commit c585e47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions curvefs/src/client/inode_cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ InodeCacheManagerImpl::RefreshInode(uint64_t inodeId) {
option_.maxDataSize, option_.refreshDataIntervalSec);
} else {
lgGuard = out->GetUniqueLock();
streaming = true;
}

// refresh data
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/client/inode_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void InodeWrapper::AsyncS3(MetaServerClientDone *done, bool internal) {
LockSyncingS3ChunkInfo();
DataIndices indices;
if (!s3ChunkInfoAdd_.empty()) {
indices.s3ChunkInfoMap = std::move(s3ChunkInfoAdd_);
indices.s3ChunkInfoMap = s3ChunkInfoAdd_;
}
metaClient_->UpdateInodeWithOutNlinkAsync(
inode_, new UpdateInodeAsyncS3Done{shared_from_this(), done},
Expand Down
9 changes: 9 additions & 0 deletions curvefs/test/client/test_inode_cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ TEST_F(TestInodeCacheManager, RefreshInode) {
iCacheManager_->GetInode(inodeId, inodeWrapper));
ASSERT_EQ(inodenew.length(), inodeWrapper->GetLength());

// cache hit, refresh s3-inode from metaserver, need streaming
EXPECT_CALL(*metaClient_, GetInode(fsId_, inodeId, _, _))
.WillOnce(DoAll(SetArgPointee<2>(inodenew), SetArgPointee<3>(true),
Return(MetaStatusCode::OK)));
EXPECT_CALL(*metaClient_,
GetOrModifyS3ChunkInfo(fsId_, inodeId, _, true, _, _))
.WillOnce(Return(MetaStatusCode::OK));
ASSERT_EQ(CURVEFS_ERROR::OK, iCacheManager_->RefreshInode(inodeId));

// cache miss, get file-inode from metaserver
Inode inodefile;
uint64_t inodefileid = 300;
Expand Down

0 comments on commit c585e47

Please sign in to comment.