From ac73df01b483979f0425647d7a58d04b6ee98673 Mon Sep 17 00:00:00 2001 From: swj <1186093704@qq.com> Date: Tue, 10 Oct 2023 11:46:03 +0800 Subject: [PATCH] [fix] curvefs: mds: createfs error Signed-off-by: swj <1186093704@qq.com> --- curvefs/src/mds/fs_manager.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/curvefs/src/mds/fs_manager.cpp b/curvefs/src/mds/fs_manager.cpp index 3af5b118d3..1d5a3852d1 100644 --- a/curvefs/src/mds/fs_manager.cpp +++ b/curvefs/src/mds/fs_manager.cpp @@ -808,15 +808,29 @@ int FsManager::IsExactlySameOrCreateUnComplete(const std::string& fsName, return google::protobuf::util::MessageDifferencer::Equals(lhs, rhs); }; - auto checkFsInfo = [fsType, volumeInfoComparator](const FsDetail& lhs, - const FsDetail& rhs) { + auto s3InfoComparator = [](common::S3Info lhs, common::S3Info rhs) { + // for compatible with old clients + if (lhs.has_objectprefix() && !rhs.has_objectprefix() && + lhs.objectprefix() != 0) { + return false; + } + if (rhs.has_objectprefix() && !lhs.has_objectprefix() && + rhs.objectprefix() != 0) { + return false; + } + + return google::protobuf::util::MessageDifferencer::Equals(lhs, rhs); + }; + + auto checkFsInfo = [fsType, volumeInfoComparator, s3InfoComparator]( + const FsDetail& lhs, const FsDetail& rhs) { switch (fsType) { case curvefs::common::FSType::TYPE_S3: - return MessageDifferencer::Equals(lhs.s3info(), rhs.s3info()); + return s3InfoComparator(lhs.s3info(), rhs.s3info()); case curvefs::common::FSType::TYPE_VOLUME: return volumeInfoComparator(lhs.volume(), rhs.volume()); case curvefs::common::FSType::TYPE_HYBRID: - return MessageDifferencer::Equals(lhs.s3info(), rhs.s3info()) && + return s3InfoComparator(lhs.s3info(), rhs.s3info()) && volumeInfoComparator(lhs.volume(), rhs.volume()); }