Skip to content

Commit

Permalink
Revert "client/chunkserver/curve-nbd: support 512 aligned IO requests"
Browse files Browse the repository at this point in the history
This reverts commit de2a121.
  • Loading branch information
wu-hanqing committed Jun 23, 2022
1 parent 7d2dc7d commit 6bab185
Show file tree
Hide file tree
Showing 57 changed files with 121 additions and 1,874 deletions.
2 changes: 0 additions & 2 deletions conf/chunkserver.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ global.chunk_size=16777216
global.meta_page_size=4096
# clone chunk允许的最长location长度
global.location_limit=3000
# minimum alignment for io request
global.min_io_alignment=512

#
# MDS settings
Expand Down
7 changes: 0 additions & 7 deletions conf/client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,3 @@ discard.enable=true
discard.granularity=4096
# discard cleanup task delay times in millisecond
discard.taskDelayMs=60000

##### alignment #####
# default alignment
global.alignment.commonVolume=512
# alignment for clone volume
# default is 4096, because lazy clone chunk bitmap granularity is 4096
global.alignment.cloneVolume=4096
7 changes: 0 additions & 7 deletions conf/cs_client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,3 @@ discard.enable=false
discard.granularity=4096
# discard cleanup task delay times in millisecond
discard.taskDelayMs=60000

##### alignment #####
# default alignment
global.alignment.commonVolume=512
# alignment for clone volume
# default is 4096, because lazy clone chunk bitmap granularity is 4096
global.alignment.cloneVolume=4096
7 changes: 0 additions & 7 deletions conf/py_client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,3 @@ discard.enable=false
discard.granularity=4096
# discard cleanup task delay times in millisecond
discard.taskDelayMs=60000

##### alignment #####
# default alignment
global.alignment.commonVolume=512
# alignment for clone volume
# default is 4096, because lazy clone chunk bitmap granularity is 4096
global.alignment.cloneVolume=4096
7 changes: 0 additions & 7 deletions conf/snap_client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,3 @@ discard.enable=false
discard.granularity=4096
# discard cleanup task delay times in millisecond
discard.taskDelayMs=60000

##### alignment #####
# default alignment
global.alignment.commonVolume=512
# alignment for clone volume
# default is 4096, because lazy clone chunk bitmap granularity is 4096
global.alignment.cloneVolume=4096
3 changes: 0 additions & 3 deletions curve-ansible/roles/generate_config/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ chunkserver_walfilepool_retry_times: 5
chunkserver_trash_expire_after_sec: 300
chunkserver_trash_scan_period_sec: 120
chunkserver_common_log_dir: ./runlog/
chunkserver_min_io_alignment: 512

# 快照克隆配置默认值
snap_client_config_path: /etc/curve/snap_client.conf
Expand Down Expand Up @@ -244,8 +243,6 @@ client_throttle_enable: false
client_discard_enable: true
client_discard_granularity: 4096
client_discard_task_delay_ms: 60000
client_alignment_common: 512
client_alignment_clone: 4096

# nebd默认配置
client_config_path: /etc/curve/client.conf
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ global.chunk_size={{ chunk_size }}
global.meta_page_size={{ chunkserver_meta_page_size }}
# clone chunk允许的最长location长度
global.location_limit={{ chunkserver_location_limit }}
# minimum alignment for io request
global.min_io_alignment={{ chunkserver_min_io_alignment }}

#
# MDS settings
Expand Down
7 changes: 0 additions & 7 deletions curve-ansible/roles/generate_config/templates/client.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,3 @@ discard.enable={{ client_discard_enable }}
discard.granularity={{ client_discard_granularity }}
# discard cleanup task delay times in millisecond
discard.taskDelayMs={{ client_discard_task_delay_ms }}

##### alignment #####
# default alignment
global.alignment.commonVolume={{ client_alignment_common }}
# alignment for clone volume
# default is 4096, because lazy clone chunk bitmap granularity is 4096
global.alignment.cloneVolume={{ client_alignment_clone }}
2 changes: 0 additions & 2 deletions deploy/local/chunkserver/conf/chunkserver.conf.0
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ global.chunk_size=16777216
global.meta_page_size=4096
global.location_limit=3000

global.min_io_alignment=512

#
# MDS settings
#
Expand Down
2 changes: 0 additions & 2 deletions deploy/local/chunkserver/conf/chunkserver.conf.1
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ global.chunk_size=16777216
global.meta_page_size=4096
global.location_limit=3000

global.min_io_alignment=512

#
# MDS settings
#
Expand Down
2 changes: 0 additions & 2 deletions deploy/local/chunkserver/conf/chunkserver.conf.2
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ global.chunk_size=16777216
global.meta_page_size=4096
global.location_limit=3000

global.min_io_alignment=512

#
# MDS settings
#
Expand Down
3 changes: 3 additions & 0 deletions include/chunkserver/chunkserver_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ inline std::string ToGroupIdString(const LogicPoolID &logicPoolId,
}
#define ToGroupIdStr ToGroupIdString

// TODO(wudmeiao): 是否需要考虑可配置
const uint32_t kOpRequestAlignSize = 4096;

} // namespace chunkserver
} // namespace curve

Expand Down
6 changes: 3 additions & 3 deletions nbd/src/NBDController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ int IOController::InitDevAttr(NBDConfig* config, uint64_t size,
int ret = -1;

do {
ret = ioctl(nbdFd_, NBD_SET_BLKSIZE, config->block_size);
ret = ioctl(nbdFd_, NBD_SET_BLKSIZE, CURVE_NBD_BLKSIZE);
if (ret < 0) {
break;
}
Expand Down Expand Up @@ -259,7 +259,7 @@ int NetLinkController::SetUp(NBDConfig* config, int sockfd,
if (index < 0) {
return index;
}
ret = check_block_size(index, config->block_size);
ret = check_block_size(index, CURVE_NBD_BLKSIZE);
if (ret < 0) {
return ret;
}
Expand Down Expand Up @@ -393,7 +393,7 @@ int NetLinkController::ConnectInternal(NBDConfig* config, int sockfd,
NLA_PUT_U64(msg, NBD_ATTR_TIMEOUT, config->timeout);
}
NLA_PUT_U64(msg, NBD_ATTR_SIZE_BYTES, size);
NLA_PUT_U64(msg, NBD_ATTR_BLOCK_SIZE_BYTES, config->block_size);
NLA_PUT_U64(msg, NBD_ATTR_BLOCK_SIZE_BYTES, CURVE_NBD_BLKSIZE);
NLA_PUT_U64(msg, NBD_ATTR_SERVER_FLAGS, flags);

sock_attr = nla_nest_start(msg, NBD_ATTR_SOCKETS);
Expand Down
4 changes: 1 addition & 3 deletions nbd/src/define.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ namespace nbd {

#define HELP_INFO 1
#define VERSION_INFO 2
#define CURVE_NBD_BLKSIZE 4096UL // CURVE后端当前支持4096大小对齐的IO

#define NBD_MAX_PATH "/sys/module/nbd/parameters/nbds_max"
#define PROCESS_NAME "curve-nbd"
Expand Down Expand Up @@ -89,8 +90,6 @@ struct NBDConfig {
int retry_times = 25;
// unmap重试之间的睡眠间隔
int sleep_ms = 200;
// device's block size
int block_size = 4096;
// libnebd config file path
std::string nebd_conf;

Expand Down Expand Up @@ -170,7 +169,6 @@ inline std::string NBDConfig::MapOptions() const {
opts.append(KeyValueOption("max_part", max_part, 255, &firstOpt));
opts.append(BoolOption("try-netlink", try_netlink, &firstOpt));
opts.append(KeyValueOption("timeout", timeout, 3600, &firstOpt));
opts.append(KeyValueOption("block-size", block_size, 4096, &firstOpt));
opts.append(KeyValueOption("nebd-conf", nebd_conf, {}, &firstOpt));
opts.append(BoolOption("no-exclusive", !exclusive, &firstOpt));

Expand Down
1 change: 0 additions & 1 deletion nbd/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ static void Usage() {
<< " --max_part <limit> Override for module param max_part\n"
<< " --timeout <seconds> Set nbd request timeout\n"
<< " --try-netlink Use the nbd netlink interface\n"
<< " --block-size NBD Devices's block size, default is 4096, support 512 and 4096\n" // NOLINT
<< " --nebd-conf LibNebd config file\n"
<< " --no-exclusive Map image non exclusive\n"
<< "\n"
Expand Down
12 changes: 1 addition & 11 deletions nbd/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,6 @@ int parse_args(std::vector<const char*>& args, std::ostream *err_msg, // NOLIN
*err_msg << "curve-nbd: Invalid argument for sleep_ms!";
return -EINVAL;
}
} else if (argparse_witharg(args, i, &cfg->block_size, err, "--block_size", (char*)(NULL))) { // NOLINT
if (!err.str().empty()) {
*err_msg << "curve-nbd: " << err.str();
return -EINVAL;
}

if (cfg->block_size != 512 && cfg->block_size != 4096) {
*err_msg << "curve-nbd: Invalid block size, only support 512 "
"or 4096";
return -EINVAL;
}
} else if (argparse_witharg(args, i, &cfg->nebd_conf, err, "--nebd-conf", (char*)(NULL))) { // NOLINT
if (!err.str().empty()) {
*err_msg << "curve-nbd: " << err.str();
Expand Down Expand Up @@ -340,6 +329,7 @@ int check_size_from_file(const std::string &path, uint64_t expected_size,

uint64_t size = 0;
ifs >> size;
size *= CURVE_NBD_BLKSIZE;

if (size == 0) {
// Newer kernel versions will report real size only after nbd
Expand Down
37 changes: 15 additions & 22 deletions robot/curve_robot.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1449,11 +1449,11 @@ read write iosize 512
${fd} open libcurve file
${new_fd} Convert To Integer ${fd}
${rc} write libcurve file error ${new_fd} length=512
${expect_rc} evaluate int(512)
${expect_rc} evaluate int(-22)
should be equal ${rc} ${expect_rc}
${rc} read libcurve file ${new_fd} length=512
${expect_rc} evaluate int(-22)
should be equal ${rc} ${expect_rc}
${content} read libcurve file ${new_fd} length=512
${expect_content} evaluate str("a")*512
should be equal ${content} ${expect_content}
[Teardown] file clean ${new_fd}


Expand All @@ -1480,11 +1480,11 @@ read write iosize 512
${fd} open libcurve file
${new_fd} Convert To Integer ${fd}
${rc} write libcurve file error ${new_fd} length=512
${expect_rc} evaluate int(512)
${expect_rc} evaluate int(-22)
should be equal ${rc} ${expect_rc}
${rc} read libcurve file ${new_fd} length=512
${expect_rc} evaluate int(-22)
should be equal ${rc} ${expect_rc}
${content} read libcurve file ${new_fd} length=512
${expect_content} evaluate str("a")*512
should be equal ${content} ${expect_content}
[Teardown] file clean ${new_fd}

read write iosize 1k
Expand All @@ -1493,22 +1493,9 @@ read write iosize 1k
${fd} open libcurve file
${new_fd} Convert To Integer ${fd}
${rc} write libcurve file error ${new_fd} length=1024
${expect_rc} evaluate int(1024)
should be equal ${rc} ${expect_rc}
${content} read libcurve file ${new_fd} length=1024
${expect_content} evaluate str("a")*1024
should be equal ${content} ${expect_content}
[Teardown] file clean ${new_fd}

read write iosize not 512 alignment
[Tags] P0 base first release
[Setup] file init
${fd} open libcurve file
${new_fd} Convert To Integer ${fd}
${rc} write libcurve file error ${new_fd} length=511
${expect_rc} evaluate int(-22)
should be equal ${rc} ${expect_rc}
${rc} read libcurve file ${new_fd} length=511
${rc} read libcurve file ${new_fd} length=1024
${expect_rc} evaluate int(-22)
should be equal ${rc} ${expect_rc}
[Teardown] file clean ${new_fd}
Expand Down Expand Up @@ -2565,3 +2552,9 @@ check chunkserver should be exsits
start mds with sleep
start mds
Sleep 5s






15 changes: 11 additions & 4 deletions src/chunkserver/chunk_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include "src/chunkserver/op_request.h"
#include "src/chunkserver/chunk_service_closure.h"

#include "src/common/fast_align.h"

namespace curve {
namespace chunkserver {

Expand Down Expand Up @@ -543,8 +541,17 @@ bool ChunkServiceImpl::CheckRequestOffsetAndLength(uint32_t offset,
return false;
}

return common::is_aligned(offset, FLAGS_minIoAlignment) &&
common::is_aligned(len, FLAGS_minIoAlignment);
// 检查offset是否对齐
if (offset % kOpRequestAlignSize != 0) {
return false;
}

// 检查len是否对齐
if (len % kOpRequestAlignSize != 0) {
return false;
}

return true;
}

} // namespace chunkserver
Expand Down
12 changes: 0 additions & 12 deletions src/chunkserver/chunkserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,6 @@ int ChunkServer::Run(int argc, char** argv) {
// ============================初始化各模块==========================//
LOG(INFO) << "Initializing ChunkServer modules";

LOG_IF(FATAL, !conf.GetUInt32Value("global.min_io_alignment",
&FLAGS_minIoAlignment))
<< "Failed to get global.min_io_alignment";
LOG_IF(FATAL, !common::is_aligned(FLAGS_minIoAlignment, 512))
<< "minIoAlignment should align to 512";

// 优先初始化 metric 收集模块
ChunkServerMetricOptions metricOptions;
InitMetricOptions(&conf, &metricOptions);
Expand Down Expand Up @@ -569,8 +563,6 @@ void ChunkServer::InitCopysetNodeOptions(
&copysetNodeOptions->maxChunkSize));
LOG_IF(FATAL, !conf->GetUInt32Value("global.location_limit",
&copysetNodeOptions->locationLimit));
LOG_IF(FATAL, !conf->GetUInt32Value("global.meta_page_size",
&copysetNodeOptions->pageSize));
LOG_IF(FATAL, !conf->GetUInt32Value("copyset.load_concurrency",
&copysetNodeOptions->loadConcurrency));
LOG_IF(FATAL, !conf->GetUInt32Value("copyset.check_retrytimes",
Expand Down Expand Up @@ -845,10 +837,6 @@ void ChunkServer::LoadConfigFromCmdline(common::Configuration *conf) {
conf->SetIntValue("copyset.load_concurrency",
FLAGS_copysetLoadConcurrency);
}

if (GetCommandLineFlagInfo("minIoAlignment", &info) && !info.is_default) {
conf->SetUInt32Value("global.min_io_alignment", FLAGS_minIoAlignment);
}
}

int ChunkServer::GetChunkServerMetaFromLocal(
Expand Down
Loading

0 comments on commit 6bab185

Please sign in to comment.