Skip to content

Commit

Permalink
change log level of get inode
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-chaojie committed Nov 10, 2021
1 parent 66ca452 commit 601d963
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 22 deletions.
18 changes: 13 additions & 5 deletions curvefs/src/client/dentry_cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <utility>
#include <unordered_map>

using ::curvefs::metaserver::MetaStatusCode_Name;

namespace curvefs {
namespace client {

Expand Down Expand Up @@ -67,8 +69,9 @@ CURVEFS_ERROR DentryCacheManagerImpl::GetDentry(uint64_t parent,

MetaStatusCode ret = metaClient_->GetDentry(fsId_, parent, name, out);
if (ret != MetaStatusCode::OK) {
LOG_IF(WARNING, ret != MetaStatusCode::NOT_FOUND)
<< "metaClient_ GetDentry failed, ret = " << ret
LOG_IF(ERROR, ret != MetaStatusCode::NOT_FOUND)
<< "metaClient_ GetDentry failed, MetaStatusCode = " << ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", parent = " << parent << ", name = " << name;
return MetaStatusCodeToCurvefsErrCode(ret);
}
Expand All @@ -82,7 +85,9 @@ CURVEFS_ERROR DentryCacheManagerImpl::CreateDentry(const Dentry &dentry) {
curve::common::WriteLockGuard lg(mtx_);
MetaStatusCode ret = metaClient_->CreateDentry(dentry);
if (ret != MetaStatusCode::OK) {
LOG(ERROR) << "metaClient_ CreateDentry failed, ret = " << ret
LOG(ERROR) << "metaClient_ CreateDentry failed, MetaStatusCode = "
<< ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", parent = " << dentry.parentinodeid()
<< ", name = " << dentry.name();
return MetaStatusCodeToCurvefsErrCode(ret);
Expand All @@ -99,7 +104,8 @@ CURVEFS_ERROR DentryCacheManagerImpl::DeleteDentry(uint64_t parent,
dCache_->Remove(key);
MetaStatusCode ret = metaClient_->DeleteDentry(fsId_, parent, name);
if (ret != MetaStatusCode::OK && ret != MetaStatusCode::NOT_FOUND) {
LOG(ERROR) << "metaClient_ DeleteInode failed, ret = " << ret
LOG(ERROR) << "metaClient_ DeleteInode failed, MetaStatusCode = " << ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", parent = " << parent << ", name = " << name;
return MetaStatusCodeToCurvefsErrCode(ret);
}
Expand All @@ -123,7 +129,9 @@ CURVEFS_ERROR DentryCacheManagerImpl::ListDentry(uint64_t parent,
if (MetaStatusCode::NOT_FOUND == ret) {
return CURVEFS_ERROR::OK;
}
LOG(ERROR) << "metaClient_ ListDentry failed, ret = " << ret
LOG(ERROR) << "metaClient_ ListDentry failed, MetaStatusCode = "
<< ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", parent = " << parent << ", last = " << last
<< ", count = " << limit;
return MetaStatusCodeToCurvefsErrCode(ret);
Expand Down
29 changes: 29 additions & 0 deletions curvefs/src/client/error_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,40 @@

#include "curvefs/src/client/error_code.h"

#include <map>
#include <string>

namespace curvefs {
namespace client {

using ::curvefs::metaserver::MetaStatusCode;

std::map<CURVEFS_ERROR, std::string> err2Msg = {
{CURVEFS_ERROR::OK, "OK"},
{CURVEFS_ERROR::INTERNAL, "internal error"},
{CURVEFS_ERROR::UNKNOWN, "unknown"},
{CURVEFS_ERROR::EXISTS, "inode or dentry already exist"},
{CURVEFS_ERROR::NOTEXIST, "inode or dentry not exist"},
{CURVEFS_ERROR::NO_SPACE, "no space to alloc"},
{CURVEFS_ERROR::BAD_FD, "bad fd"},
{CURVEFS_ERROR::INVALIDPARAM, "invalid param"},
{CURVEFS_ERROR::NOPERMISSION, "no permission"},
{CURVEFS_ERROR::NOTEMPTY, "dir not empty"},
{CURVEFS_ERROR::NOFLUSH, "no flush"},
{CURVEFS_ERROR::NOTSUPPORT, "not support"},
{CURVEFS_ERROR::NAMETOOLONG, "name too long"},
{CURVEFS_ERROR::MOUNT_POINT_EXIST, "mount point already exist"},
{CURVEFS_ERROR::MOUNT_FAILED, "mount failed"},
};

std::ostream &operator<<(std::ostream &os, CURVEFS_ERROR code) {
os << static_cast<int>(code)
<< "["
<< err2Msg[code]
<< "]";
return os;
}

CURVEFS_ERROR MetaStatusCodeToCurvefsErrCode(
MetaStatusCode code) {
CURVEFS_ERROR ret = CURVEFS_ERROR::UNKNOWN;
Expand Down
7 changes: 2 additions & 5 deletions curvefs/src/client/error_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@ enum class CURVEFS_ERROR {
MOUNT_FAILED = -14,
};

inline std::ostream &operator<<(std::ostream &os, CURVEFS_ERROR code) {
// TODO(xuchaojie): to print enum name
os << static_cast<int>(code);
return os;
}

std::ostream &operator<<(std::ostream &os, CURVEFS_ERROR code);

CURVEFS_ERROR MetaStatusCodeToCurvefsErrCode(
::curvefs::metaserver::MetaStatusCode code);
Expand Down
14 changes: 11 additions & 3 deletions curvefs/src/client/fuse_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
using ::curvefs::common::S3Info;
using ::curvefs::common::Volume;
using ::curvefs::mds::topology::PartitionTxId;
using ::curvefs::mds::FSStatusCode_Name;

#define RETURN_IF_UNSUCCESS(action) \
do { \
Expand Down Expand Up @@ -160,7 +161,9 @@ CURVEFS_ERROR FuseClient::FuseOpInit(void *userdata,
return ret2;
}
} else {
LOG(ERROR) << "GetFsInfo failed, ret = " << ret
LOG(ERROR) << "GetFsInfo failed, FSStatusCode = " << ret
<< ", FSStatusCode_Name = "
<< FSStatusCode_Name(ret)
<< ", fsName = " << fsName;
return CURVEFS_ERROR::INTERNAL;
}
Expand All @@ -173,7 +176,10 @@ CURVEFS_ERROR FuseClient::FuseOpInit(void *userdata,
}
ret = mdsClient_->MountFs(fsName, mountPointWithHost, &fsInfo);
if (ret != FSStatusCode::OK && ret != FSStatusCode::MOUNT_POINT_EXIST) {
LOG(ERROR) << "MountFs failed, ret = " << ret << ", fsName = " << fsName
LOG(ERROR) << "MountFs failed, FSStatusCode = " << ret
<< ", FSStatusCode_Name = "
<< FSStatusCode_Name(ret)
<< ", fsName = " << fsName
<< ", mountPoint = " << mountPointWithHost;
return CURVEFS_ERROR::MOUNT_FAILED;
}
Expand Down Expand Up @@ -210,7 +216,9 @@ void FuseClient::FuseOpDestroy(void *userdata) {
}
FSStatusCode ret = mdsClient_->UmountFs(fsName, mountPointWithHost);
if (ret != FSStatusCode::OK && ret != FSStatusCode::MOUNT_POINT_NOT_EXIST) {
LOG(ERROR) << "UmountFs failed, ret = " << ret
LOG(ERROR) << "UmountFs failed, FSStatusCode = " << ret
<< ", FSStatusCode_Name = "
<< FSStatusCode_Name(ret)
<< ", fsName = " << fsName
<< ", mountPoint = " << mountPointWithHost;
return;
Expand Down
13 changes: 9 additions & 4 deletions curvefs/src/client/inode_cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <utility>

using ::curvefs::metaserver::Inode;
using ::curvefs::metaserver::MetaStatusCode_Name;

namespace curvefs {
namespace client {
Expand All @@ -52,8 +53,10 @@ CURVEFS_ERROR InodeCacheManagerImpl::GetInode(uint64_t inodeid,
Inode inode;
MetaStatusCode ret2 = metaClient_->GetInode(fsId_, inodeid, &inode);
if (ret2 != MetaStatusCode::OK) {
LOG(ERROR) << "metaClient_ GetInode failed, ret = " << ret2
<< ", inodeid = " << inodeid;
LOG_IF(ERROR, ret2 != MetaStatusCode::NOT_FOUND)
<< "metaClient_ GetInode failed, MetaStatusCode = " << ret2
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret2)
<< ", inodeid = " << inodeid;
return MetaStatusCodeToCurvefsErrCode(ret2);
}

Expand All @@ -79,7 +82,8 @@ CURVEFS_ERROR InodeCacheManagerImpl::CreateInode(
Inode inode;
MetaStatusCode ret = metaClient_->CreateInode(param, &inode);
if (ret != MetaStatusCode::OK) {
LOG(ERROR) << "metaClient_ CreateInode failed, ret = " << ret;
LOG(ERROR) << "metaClient_ CreateInode failed, MetaStatusCode = " << ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret);
return MetaStatusCodeToCurvefsErrCode(ret);
}
uint64_t inodeid = inode.inodeid();
Expand All @@ -103,7 +107,8 @@ CURVEFS_ERROR InodeCacheManagerImpl::DeleteInode(uint64_t inodeid) {
iCache_->Remove(inodeid);
MetaStatusCode ret = metaClient_->DeleteInode(fsId_, inodeid);
if (ret != MetaStatusCode::OK && ret != MetaStatusCode::NOT_FOUND) {
LOG(ERROR) << "metaClient_ DeleteInode failed, ret = " << ret
LOG(ERROR) << "metaClient_ DeleteInode failed, MetaStatusCode = " << ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", inodeid = " << inodeid;
return MetaStatusCodeToCurvefsErrCode(ret);
}
Expand Down
16 changes: 12 additions & 4 deletions curvefs/src/client/inode_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

#include "curvefs/src/client/rpcclient/metaserver_client.h"

using ::curvefs::metaserver::MetaStatusCode_Name;

namespace curvefs {
namespace client {

Expand All @@ -35,7 +37,9 @@ CURVEFS_ERROR InodeWrapper::Sync() {
MetaStatusCode ret = metaClient_->UpdateInode(inode_);

if (ret != MetaStatusCode::OK) {
LOG(ERROR) << "metaClient_ UpdateInode failed, ret = " << ret
LOG(ERROR) << "metaClient_ UpdateInode failed, MetaStatusCode = "
<< ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", inodeid = " << inode_.inodeid();
return MetaStatusCodeToCurvefsErrCode(ret);
}
Expand All @@ -55,7 +59,8 @@ CURVEFS_ERROR InodeWrapper::LinkLocked() {
if (ret != MetaStatusCode::OK) {
inode_.set_nlink(old);
inode_.set_ctime(oldCTime);
LOG(ERROR) << "metaClient_ UpdateInode failed, ret = " << ret
LOG(ERROR) << "metaClient_ UpdateInode failed, MetaStatusCode = " << ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", inodeid = " << inode_.inodeid();
return MetaStatusCodeToCurvefsErrCode(ret);
}
Expand All @@ -78,7 +83,9 @@ CURVEFS_ERROR InodeWrapper::UnLinkLocked() {
VLOG(6) << "UnLinkInode, inodeid = " << inode_.inodeid()
<< ", nlink = " << inode_.nlink();
if (ret != MetaStatusCode::OK) {
LOG(ERROR) << "metaClient_ UpdateInode failed, ret = " << ret
LOG(ERROR) << "metaClient_ UpdateInode failed, MetaStatusCode = "
<< ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", inodeid = " << inode_.inodeid();
return MetaStatusCodeToCurvefsErrCode(ret);
}
Expand Down Expand Up @@ -121,7 +128,8 @@ CURVEFS_ERROR InodeWrapper::SetOpenFlag(bool flag) {
MetaStatusCode ret = metaClient_->UpdateInode(inode_);
if (ret != MetaStatusCode::OK) {
inode_.set_openflag(old);
LOG(ERROR) << "metaClient_ UpdateInode failed, ret = " << ret
LOG(ERROR) << "metaClient_ UpdateInode failed, MetaStatusCode = " << ret
<< ", MetaStatusCode_Name = " << MetaStatusCode_Name(ret)
<< ", inodeid = " << inode_.inodeid();
return MetaStatusCodeToCurvefsErrCode(ret);
}
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/client/s3/client_s3_cache_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ CURVEFS_ERROR DataCache::Flush(uint64_t inodeId, bool force) {
s3ClientAdaptor_->GetInodeCacheManager()->GetInode(
inodeId, inodeWrapper);
if (ret != CURVEFS_ERROR::OK) {
LOG(ERROR) << "get inode fail, ret:" << ret;
LOG(WARNING) << "get inode fail, ret:" << ret;
dirty_.store(true, std::memory_order_release);
return ret;
}
Expand Down

0 comments on commit 601d963

Please sign in to comment.