Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curvefs: support space deallocate for curvebs volume as backend #2313

Merged
merged 1 commit into from
Jul 20, 2023

Conversation

ilixiaocui
Copy link
Contributor

@ilixiaocui ilixiaocui commented Mar 15, 2023

What problem does this PR solve?

Issue Number: #2160

Problem Summary: #2294

What is changed and how it works?

What's Changed:

How it Works:

Side effects(Breaking backward compatibility? Performance regression?):

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@ilixiaocui ilixiaocui force-pushed the volumespacerecycle branch 17 times, most recently from be3376e to 60cbecd Compare March 22, 2023 03:33
@ilixiaocui ilixiaocui force-pushed the volumespacerecycle branch 13 times, most recently from d9c6864 to 8a06440 Compare March 24, 2023 10:05
@@ -50,8 +49,13 @@ FsInfoWrapper::FsInfoWrapper(const ::curvefs::mds::CreateFsRequest* request,
fsInfo.set_enablesumindir(request->enablesumindir());
fsInfo.set_txsequence(0);
fsInfo.set_txowner("");
// TODO(@lixiaocui1): Currently, curveadm does not support setting recycling
Copy link
Contributor

@Wine93 Wine93 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be supported.
BTW: is there a default value for recyleTimeHour if user not specified?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recycleTimeHour is optional in message FsInfo. it doesn't have a default value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

recycleTimeHour is optional in message FsInfo. it doesn't have a default value.

Okay~ i will give a default value (1 hours) in curveadm.

if (wrapper.GetFsType() == FSType::TYPE_VOLUME) {
auto volumeSpace = spaceManager_->GetVolumeSpace(wrapper.GetFsId());
if (volumeSpace == nullptr) {
LOG(ERROR) << "handle fs mount point timeout fail, get volume "
Copy link
Contributor

@Wine93 Wine93 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it can be more readable:

LOG(ERROR) << "handle fs mount point timeout fail, get volume "
           << "space fail, fsName = " << fsName
           << ", mountpoint = " << mountpoint.ShortDebugString();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the default fomat result.

if (ret != space::SpaceOk) {
LOG(ERROR)
<< "handle fs mount point timeout fail,release block groups "
"fail, fsName = "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -156,8 +172,10 @@ SpaceErrCode VolumeSpace::AllocateBlockGroups(
return err;
}

for (auto& group : *blockGroups) {
for (auto &group : *blockGroups) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better to use const auto&.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@@ -317,6 +352,8 @@ SpaceErrCode VolumeSpace::ReleaseBlockGroups(
LockGuard lk(mtx_);

for (auto& group : blockGroups) {
VLOG(3) << "VolumeSpace need release block group:"
<< group.DebugString();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated. fix

@@ -267,6 +286,22 @@ SpaceErrCode VolumeSpace::AcquireBlockGroup(uint64_t blockGroupOffset,
SpaceErrCode VolumeSpace::AcquireBlockGroupInternal(uint64_t blockGroupOffset,
const std::string& owner,
BlockGroup* group) {
if (owner.empty()) {
Copy link
Contributor

@Wine93 Wine93 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it can be more readable:

if (owner.empty()) {
    auto it = deallocatingGroups_.find(blockGroupOffset);
    if (it == deallocatingGroups_.end()) {
        return SpaceErrNotFound;
    }

    *group = it->second;
    VLOG(6) << "VolumeSpace recieve acquire blockgroup="
            << group->DebugString()
            << " rquest from metaserver, current block group is under "
                "deallocating";
    return SpaceOk;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. fix.

@@ -571,5 +620,207 @@ MetaStatusCode InodeStorage::GetVolumeExtentByOffset(uint32_t fsId,
return MetaStatusCode::STORAGE_INTERNAL_ERROR;
}

MetaStatusCode InodeStorage::GeAllBlockGroup(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: GetAllBlockGroup

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

}
}

#define PRECHECK(fsId, inodeId) \
do { \
if (!IsInodeBelongs((fsId), (inodeId))) { \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation for \

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

} \
} while (0)

#define PRECHECKFSID(fsId) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe PRECHECK_FSID is more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix


// key is volume offset
DeallocatableBlockGroupMap increase;
while (iter->Valid()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (iter->SeekToFirst(); iter->Valid(); iter->Next()) {
    // do something
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

if (it == spaceManagers_.end()) {
if (!GenerateSpaceManager(fsId)) {
return nullptr;
}
Copy link
Contributor

@Wine93 Wine93 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it return spaceManagers_[fsId] if GenerateSpaceManager return true even if the item not exist in the spaceManagers_?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. GenerateSpaceManager will insert new generated manager to spaceManagers_.

std::string Key4DeallocatableBlockGroup::SerializeToString() const {
return absl::StrCat(keyType_, kDelimiter, fsId, kDelimiter, volumeOffset);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

@Wine93
Copy link
Contributor

Wine93 commented Jul 2, 2023

If willing, please requested review from me again after all problem solved and all suggestion has been handled :)

@ilixiaocui ilixiaocui force-pushed the volumespacerecycle branch 2 times, most recently from a2bfc88 to b6742eb Compare July 13, 2023 09:26
@ilixiaocui
Copy link
Contributor Author

If willing, please requested review from me again after all problem solved and all suggestion has been handled :)

okok

@ilixiaocui ilixiaocui force-pushed the volumespacerecycle branch 3 times, most recently from 666ff36 to 40bfa91 Compare July 13, 2023 11:18
@ilixiaocui
Copy link
Contributor Author

cicheck

Copy link
Contributor

@Wine93 Wine93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ilixiaocui ilixiaocui force-pushed the volumespacerecycle branch 2 times, most recently from 8ae2b6a to 64daf02 Compare July 19, 2023 06:21
@ilixiaocui
Copy link
Contributor Author

cicheck

<< MetaStatusCode_Name(st)
<< ", inodeid: " << inode_->GetInodeId();
inode_->MarkInodeError();
if (inode_ != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inode may be evicted by mistake, here is a defense.

evict an inode won't cause inode_ to become a nullptr, the reason might be UpdateVolumeExtentClosure was created from a null inode.

}

if (item.has_increase()) {
if (!out.IsInitialized()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!s.ok() && !s.IsNotFound() means status wrongand inode is found

At this point, we either found a DeallocatableBlockGroup or not found and without any error.

And if we found one, then out must be initialized, otherwise out is not initialized if it isn't found.

If this is true, using s.IsNotFound() will be more explicit, because people may not know why we test out is initialized here.

Comment on lines +186 to +194
MetaStatusCode Increase(Transaction txn, uint32_t fsId,
const IncreaseDeallocatableBlockGroup &increase,
DeallocatableBlockGroup *out);

MetaStatusCode Decrease(const DecreaseDeallocatableBlockGroup &decrease,
DeallocatableBlockGroup *out);

MetaStatusCode Mark(const MarkDeallocatableBlockGroup &mark,
DeallocatableBlockGroup *out);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these functions are all private, which are used for processing corresponding to different fields in message DeallocatableBlockGroup.

Although they're private, member functions should access or modify data members not just
function parameters. And another good reason to put them outside of this class is it'll be more test friendly.

<< ", blockGroupOffset:" << blockGroupOffset
<< ", to sliceList:" << sliceList.DebugString()
<< " failed";
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's still leaked in this case, BTW, you don't have to allocate closure on heap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix

extents->begin(), extents->end(),
[&](const VolumeExtent &extent) {
bool res = (extent.volumeoffset() >= blockGroupOffset) &&
(extent.volumeoffset() < boundary);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because of the existence of 4k headers, the length of the extent will not cross the block group, so there is no need to add length to judge.

consider add a comment to explain this implicit condition

@@ -31,6 +31,13 @@ enum BitmapLocation {
AtEnd = 2;
}

message EmptyMsg {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just include google/protobuf/empty.pb.h header where used and protobuf dependency should have been satisfied

image

Signed-off-by: ilixiaocui <ilixiaocui@163.com>
@ilixiaocui
Copy link
Contributor Author

cicheck

@ilixiaocui ilixiaocui merged commit f011606 into opencurve:master Jul 20, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants