Skip to content

Commit 6512503

Browse files
Lijiachen1018lijiachen
andauthored
[bug fix] fix recycleNum when less than 1 (#327)
fix gc Co-authored-by: lijiachen <lijiachen19@huawei.com>
1 parent 022e187 commit 6512503

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

ucm/store/nfsstore/cc/domain/space/space_manager.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ Status SpaceManager::Setup(const std::vector<std::string>& storageBackends, cons
5252
auto status = this->layout_->Setup(storageBackends);
5353
if (status.Failure()) { return status; }
5454
status = this->property_.Setup(this->layout_->ClusterPropertyFilePath());
55+
if (status.Failure()) { return status; }
5556
if (recycleEnable && storageCapacity > 0) {
5657
auto totalBlocks = storageCapacity / blockSize;
5758
status = this->recycle_.Setup(this->GetSpaceLayout(), totalBlocks, [this] {
5859
this->property_.DecreaseCapacity(this->blockSize_);
5960
});
6061
if (status.Failure()) { return status; }
6162
}
62-
if (status.Failure()) { return status; }
63+
6364
this->blockSize_ = blockSize;
6465
this->capacity_ = storageCapacity;
6566
this->recycleEnable_ = recycleEnable;

ucm/store/nfsstore/cc/domain/space/space_recycle.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ Status SpaceRecycle::Setup(const SpaceLayout* layout, const size_t totalNumber,
8888
RecycleOneBlockDone done) {
8989
this->layout_ = layout;
9090
this->recycleNum_ = totalNumber * recyclePercent;
91+
if (this->recycleNum_ == 0) {
92+
this->recycleNum_ = 1;
93+
}
9194
this->recycleOneBlockDone_ = done;
9295
if (this->recycleNum_ > maxRecycleNum) {
9396
this->recycleNum_ = maxRecycleNum;

ucm/store/nfsstore/cc/domain/space/space_shard_layout.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void SpaceShardLayout::ShardBlockId(const std::string& blockId, uint64_t& front,
196196
std::string SpaceShardLayout::StorageBackend() const { return this->storageBackends_.front(); }
197197
std::string SpaceShardLayout::ClusterPropertyFilePath() const
198198
{
199-
return fmt::format("{}{}/{}.bin", this->StorageBackend(), this->ClusterFileRoot(), "uc_property.bin");
199+
return fmt::format("{}{}/{}.bin", this->StorageBackend(), this->ClusterFileRoot(), "uc_property");
200200
}
201201

202202
std::shared_ptr<SpaceLayout::DataIterator> SpaceShardLayout::CreateFilePathIterator() const

ucm/store/nfsstore/nfsstore_connector.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def __init__(self, config: Dict):
5151
if transfer_enable:
5252
param.transferDeviceId = config["device"]
5353
param.transferIoSize = config["io_size"]
54+
55+
param.storageCapacity = config.get("storageCapacity", 0)
56+
param.recycleEnable = True if config.get("recycleEnable", 0) == 1 else False
57+
if param.recycleEnable:
58+
param.recycleThresholdRatio = config.get("recycleThresholdRatio", 0.7)
59+
5460
ret = self.store.Setup(param)
5561
if ret != 0:
5662
msg = f"Failed to initialize ucmnfsstore, errcode: {ret}."

0 commit comments

Comments
 (0)