Skip to content

Commit

Permalink
curvefs/quota: code format
Browse files Browse the repository at this point in the history
Signed-off-by: h0hmj <h0hmjcn@gmail.com>
  • Loading branch information
h0hmj committed Oct 25, 2023
1 parent 37da6d0 commit 7f4a097
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 50 deletions.
4 changes: 2 additions & 2 deletions curvefs/src/client/fuse_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
#include "curvefs/src/client/filesystem/xattr.h"
#include "curvefs/src/client/fuse_common.h"
#include "curvefs/src/client/inode_wrapper.h"
#include "curvefs/src/client/rpcclient/fsdelta_updater.h"
#include "curvefs/src/client/rpcclient/fsquota_checker.h"
#include "curvefs/src/client/warmup/warmup_manager.h"
#include "curvefs/src/client/xattr_manager.h"
#include "curvefs/src/common/define.h"
#include "src/client/client_common.h"
#include "src/common/dummyserver.h"
#include "src/common/net_common.h"
#include "curvefs/src/client/rpcclient/fsdelta_updater.h"
#include "curvefs/src/client/rpcclient/fsquota_checker.h"

#define PORT_LIMIT 65535

Expand Down
1 change: 1 addition & 0 deletions curvefs/src/client/rpcclient/fsquota_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

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

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

namespace curvefs {
Expand Down
8 changes: 5 additions & 3 deletions curvefs/src/client/rpcclient/mds_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
* Author: lixiaocui
*/

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

#include <map>
#include <utility>
#include <vector>

#include "curvefs/proto/space.pb.h"
#include "curvefs/src/client/rpcclient/mds_client.h"
#include "curvefs/src/common/metric_utils.h"
#include "curvefs/src/client/rpcclient/fsdelta_updater.h"
#include "curvefs/src/client/rpcclient/fsquota_checker.h"
#include "curvefs/src/common/metric_utils.h"

namespace curvefs {
namespace client {
Expand Down Expand Up @@ -516,7 +517,8 @@ MdsClientImpl::RefreshSession(const std::vector<PartitionTxId> &txIds,
request.set_fsname(fsName);
*request.mutable_mountpoint() = mountpoint;
curvefs::mds::FsDelta fsDelta;
fsDelta.set_bytes(FsDeltaUpdater::GetInstance().GetDeltaBytesAndReset());
fsDelta.set_bytes(
FsDeltaUpdater::GetInstance().GetDeltaBytesAndReset());
*request.mutable_fsdelta() = std::move(fsDelta);

mdsbasecli_->RefreshSession(request, &response, cntl, channel);
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/client/s3/client_s3_adaptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
#include <utility>

#include "absl/memory/memory.h"
#include "curvefs/src/common/s3util.h"
#include "curvefs/src/client/rpcclient/fsdelta_updater.h"
#include "curvefs/src/client/rpcclient/fsquota_checker.h"
#include "curvefs/src/common/s3util.h"

namespace curvefs {
namespace client {
Expand Down
10 changes: 5 additions & 5 deletions curvefs/src/mds/codec/codec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ namespace curvefs {
namespace mds {
namespace codec {

using ::curve::common::EncodeBigEndian;
using ::curve::common::EncodeBigEndian_uint32;
using ::curvefs::mds::BLOCKGROUP_KEY_END;
using ::curvefs::mds::BLOCKGROUP_KEY_PREFIX;
using ::curvefs::mds::COMMON_PREFIX_LENGTH;
using ::curvefs::mds::FS_NAME_KEY_PREFIX;
using ::curvefs::mds::BLOCKGROUP_KEY_PREFIX;
using ::curvefs::mds::BLOCKGROUP_KEY_END;
using ::curvefs::mds::FS_USAGE_KEY_PREFIX;
using ::curvefs::mds::FS_USAGE_KEY_END;
using ::curve::common::EncodeBigEndian;
using ::curve::common::EncodeBigEndian_uint32;
using ::curvefs::mds::FS_USAGE_KEY_PREFIX;

std::string EncodeFsName(const std::string& fsName) {
std::string key;
Expand Down
4 changes: 2 additions & 2 deletions curvefs/src/mds/fs_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,8 +896,8 @@ void FsManager::GetAllFsInfo(
LOG(INFO) << "get all fsinfo.";
}

FSStatusCode FsManager::UpdateFsUsedBytes(const std::string& fsName,
int64_t deltaBytes) {
FSStatusCode FsManager::UpdateFsUsedBytes(
const std::string& fsName, int64_t deltaBytes) {
WriteLockGuard wlock(fsUsageMutex_);

FsUsage usage;
Expand Down
4 changes: 2 additions & 2 deletions curvefs/src/mds/fs_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ class FsManager {

bool TestS3(const std::string& fsName);

FSStatusCode UpdateFsUsedBytes(const std::string& fsName,
int64_t deltaBytes);
FSStatusCode UpdateFsUsedBytes(
const std::string& fsName, int64_t deltaBytes);

private:
std::shared_ptr<FsStorage> fsStorage_;
Expand Down
16 changes: 8 additions & 8 deletions curvefs/src/mds/fs_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ void MemoryFsStorage::GetAll(std::vector<FsInfoWrapper>* fsInfoVec) {
}
}

FSStatusCode MemoryFsStorage::SetFsUsage(const std::string& fsName,
const FsUsage& fsUsage) {
FSStatusCode MemoryFsStorage::SetFsUsage(
const std::string& fsName, const FsUsage& fsUsage) {
WriteLockGuard writeLockGuard(fsUsedUsageLock_);
fsUsageMap_[fsName] = fsUsage;
return FSStatusCode::OK;
}

FSStatusCode MemoryFsStorage::GetFsUsage(const std::string& fsName,
FsUsage* usage, bool fromCache) {
FSStatusCode MemoryFsStorage::GetFsUsage(
const std::string& fsName, FsUsage* usage, bool fromCache) {
ReadLockGuard readLockGuard(fsUsedUsageLock_);
auto it = fsUsageMap_.find(fsName);
if (it == fsUsageMap_.end()) {
Expand Down Expand Up @@ -502,8 +502,8 @@ void PersisKVStorage::GetAll(std::vector<FsInfoWrapper>* fsInfoVec) {
}
}

FSStatusCode PersisKVStorage::SetFsUsage(const std::string& fsName,
const FsUsage& usage) {
FSStatusCode PersisKVStorage::SetFsUsage(
const std::string& fsName, const FsUsage& usage) {
std::string key = codec::EncodeFsUsageKey(fsName);
std::string value;
if (!codec::EncodeProtobufMessage(usage, &value)) {
Expand All @@ -521,8 +521,8 @@ FSStatusCode PersisKVStorage::SetFsUsage(const std::string& fsName,
return FSStatusCode::OK;
}

FSStatusCode PersisKVStorage::GetFsUsage(const std::string& fsName,
FsUsage* usage, bool fromCache) {
FSStatusCode PersisKVStorage::GetFsUsage(
const std::string& fsName, FsUsage* usage, bool fromCache) {
if (fromCache) {
ReadLockGuard lock(fsUsageCacheMutex_);
if (fsUsageCache_.find(fsName) != fsUsageCache_.end()) {
Expand Down
24 changes: 12 additions & 12 deletions curvefs/src/mds/fs_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class FsStorage {
virtual uint64_t NextFsId() = 0;
virtual void GetAll(std::vector<FsInfoWrapper>* fsInfoVec) = 0;

virtual FSStatusCode SetFsUsage(const std::string& fsName,
const FsUsage& usage) = 0;
virtual FSStatusCode GetFsUsage(const std::string& fsName, FsUsage* fsUsage,
bool fromCache) = 0;
virtual FSStatusCode SetFsUsage(
const std::string& fsName, const FsUsage& usage) = 0;
virtual FSStatusCode GetFsUsage(
const std::string& fsName, FsUsage* fsUsage, bool fromCache) = 0;
virtual FSStatusCode DeleteFsUsage(const std::string& fsName) = 0;
};

Expand Down Expand Up @@ -176,10 +176,10 @@ class MemoryFsStorage : public FsStorage {
*/
void GetAll(std::vector<FsInfoWrapper>* fsInfoVec) override;

FSStatusCode SetFsUsage(const std::string& fsName,
const FsUsage& usage) override;
FSStatusCode GetFsUsage(const std::string& fsName, FsUsage*,
bool fromCache) override;
FSStatusCode SetFsUsage(
const std::string& fsName, const FsUsage& usage) override;
FSStatusCode GetFsUsage(
const std::string& fsName, FsUsage*, bool fromCache) override;
FSStatusCode DeleteFsUsage(const std::string& fsName) override;

private:
Expand Down Expand Up @@ -219,10 +219,10 @@ class PersisKVStorage : public FsStorage {

void GetAll(std::vector<FsInfoWrapper>* fsInfoVec) override;

FSStatusCode SetFsUsage(const std::string& fsName,
const FsUsage& usage) override;
FSStatusCode GetFsUsage(const std::string& fsName, FsUsage*,
bool fromCache) override;
FSStatusCode SetFsUsage(
const std::string& fsName, const FsUsage& usage) override;
FSStatusCode GetFsUsage(
const std::string& fsName, FsUsage*, bool fromCache) override;
FSStatusCode DeleteFsUsage(const std::string& fsName) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/tools/curvefs_tool_define.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ DEFINE_uint64(s3_chunksize, 4194304, "s3 chunk size");
DEFINE_uint32(s3_objectPrefix, 0, "object prefix");
DEFINE_bool(enableSumInDir, false, "statistic info in xattr");
DEFINE_uint64(capacity, (uint64_t)0,
"capacity of fs, unit is bytes, default 0 to disable quota");
"capacity of fs, unit is bytes, default 0 to disable quota");
DEFINE_string(user, "anonymous", "user of request");
DEFINE_string(inodeId, "1,2,3", "inodes id");

Expand Down
8 changes: 4 additions & 4 deletions curvefs/test/client/test_fuse_s3_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3941,12 +3941,12 @@ TEST_F(TestFuseS3Client, FuseOpUnlink_EnableSummary) {
EXPECT_CALL(*inodeManager_, GetInode(_, _))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(SetArgReferee<1>(parentInodeWrapper),
Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(
SetArgReferee<1>(parentInodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(SetArgReferee<1>(parentInodeWrapper),
Return(CURVEFS_ERROR::OK)));
.WillOnce(DoAll(
SetArgReferee<1>(parentInodeWrapper), Return(CURVEFS_ERROR::OK)));
EXPECT_CALL(*metaClient_, GetInodeAttr(_, _, _))
.WillOnce(DoAll(SetArgPointee<2>(attr), Return(MetaStatusCode::OK)));
EXPECT_CALL(*metaClient_, UpdateInodeAttr(_, _, _))
Expand Down
16 changes: 8 additions & 8 deletions curvefs/test/client/test_fuse_volume_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ TEST_F(TestFuseVolumeClient, FuseOpUnlink) {
EXPECT_CALL(*inodeManager_, GetInode(_, _))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(SetArgReferee<1>(parentInodeWrapper),
Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(
SetArgReferee<1>(parentInodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)));
EXPECT_CALL(*metaClient_, GetInodeAttr(_, _, _))
Expand Down Expand Up @@ -634,8 +634,8 @@ TEST_F(TestFuseVolumeClient, FuseOpRmDir) {
EXPECT_CALL(*inodeManager_, GetInode(_, _))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(SetArgReferee<1>(parentInodeWrapper),
Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(
SetArgReferee<1>(parentInodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)));
EXPECT_CALL(*metaClient_, GetInodeAttr(_, _, _))
Expand Down Expand Up @@ -701,13 +701,13 @@ TEST_F(TestFuseVolumeClient, FuseOpUnlinkFailed) {
EXPECT_CALL(*inodeManager_, GetInode(_, _))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(SetArgReferee<1>(parentInodeWrapper),
Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(
SetArgReferee<1>(parentInodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(Return(CURVEFS_ERROR::INTERNAL))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(SetArgReferee<1>(parentInodeWrapper),
Return(CURVEFS_ERROR::OK)))
.WillOnce(DoAll(
SetArgReferee<1>(parentInodeWrapper), Return(CURVEFS_ERROR::OK)))
.WillOnce(
DoAll(SetArgReferee<1>(inodeWrapper), Return(CURVEFS_ERROR::OK)));
EXPECT_CALL(*metaClient_, GetInodeAttr(_, _, _))
Expand Down
4 changes: 2 additions & 2 deletions curvefs/test/mds/mock/mock_fs_stroage.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class MockFsStorage : public FsStorage {
MOCK_METHOD0(NextFsId, uint64_t());
MOCK_METHOD1(GetAll, void(std::vector<FsInfoWrapper>* fsInfoVec));
MOCK_METHOD2(SetFsUsage, FSStatusCode(const std::string&, const FsUsage&));
MOCK_METHOD3(GetFsUsage,
FSStatusCode(const std::string&, FsUsage*, bool fromCache));
MOCK_METHOD3(
GetFsUsage, FSStatusCode(const std::string&, FsUsage*, bool fromCache));
MOCK_METHOD1(DeleteFsUsage, FSStatusCode(const std::string&));
};

Expand Down

0 comments on commit 7f4a097

Please sign in to comment.