-
Notifications
You must be signed in to change notification settings - Fork 526
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
zeroize memory copy #78
Conversation
* @return 返回错误码 | ||
*/ | ||
virtual int AioRead(int fd, CurveAioContext* aioctx); | ||
virtual int AioRead(int fd, CurveAioContext* aioctx, UserDataType dataType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是否要改成const引用?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个只是个枚举类型,没有必要加。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个只是个枚举类型,没有必要加。
* @return 返回错误码 | ||
*/ | ||
virtual int AioWrite(int fd, CurveAioContext* aioctx); | ||
virtual int AioWrite(int fd, CurveAioContext* aioctx, | ||
UserDataType dataType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
namespace curve { | ||
namespace client { | ||
|
||
const char* OpTypeToString(OpType optype) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么移动到头文件了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个文件就一个函数,而且函数逻辑不复杂,就改成inline放到头文件了。
src/client/io_tracker.cpp
Outdated
reqlist_.reserve(length_ / Splitor::IOSplitSize() + 1); | ||
|
||
int ret = Splitor::IO2ChunkRequests( | ||
this, mc_, &reqlist_, nullptr, offset_, length_, mdsclient, fi); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么改成了传nullptr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修改之前的splitor,需要传入用户buffer,拆分的sub-io的buffer会指向用户buffer不同的offset。
- 写请求会把sub-io的buffer中的数据复制到rpc controller中。
- 读请求读到的数据,会从rpc controller复制到sub-io的buffer中。这里当所有的sub-io完成后,用户buffer里面就存储了需要读取的数据。
修改之后,小io的buffer,改成了IOBuf。
- 写请求,需要把用户IOBuf中的内容cut到sub-io的iobuf中,然后传给rpc controller。
- 读请求,只需要把rpc controller中的iobuf复制给sub-io的iobuf中就可以了。当所有sub-io完成后,会把所有sub-io的iobuf按顺序拼接到一起,返回给用户。
IOTracker* temp = new IOTracker(this, &mc_, scheduler_); | ||
temp->SetUserDataType(UserDataType::RawBuffer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么是RawBuffer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是直接读快照chunk,接口传入的是char* buf。
src/client/iomanager4file.cpp
Outdated
return -LIBCURVE_ERROR::FAILED; | ||
} | ||
|
||
memcpy(buf, data.to_string().c_str(), length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同步的改不了零拷贝吗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
需要零拷贝的只有nebd使用的接口。上层nbd/qemu都是使用的异步读写接口,所以同步这里就没修改了。
5303c14
to
c4c20f2
Compare
c4c20f2
to
455cbec
Compare
src/client/io_tracker.cpp
Outdated
type_ = OpType::WRITE; | ||
type_ = OpType::WRITE; | ||
|
||
DVLOG(9) << "aiowrite op, offset = " << offset << ", length = " << length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个日志,不是aiowrite吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Change-Id: I2d389b24446623e8f639642a2b354120f20dbe56
455cbec
to
d98a59d
Compare
Change-Id: I2d389b24446623e8f639642a2b354120f20dbe56
What problem does this PR solve?
Issue Number: None
Problem Summary:
What is changed and how it works?
What's Changed: zeroize memory copy between nebd and curve-client
How it Works:
Side effects(Breaking backward compatibility? Performance regression?):
Check List