Skip to content
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

client/mds: merge stripe feature and unit test #211

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

baijiaruo
Copy link

What problem does this PR solve?

Issue Number: close #xxx

Problem Summary:

What is changed and how it works?

What's Changed: add stripe feature

How it Works:

Side effects(Breaking backward compatibility? Performance regression?):

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

# See the License for the specific language governing permissions and
# limitations under the License.
#

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么把license删掉了?

Copy link
Author

@baijiaruo baijiaruo Jan 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个文件重新生成的时候默认没有,已补充

* See the License for the specific language governing permissions and
* limitations under the License.
*/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么去掉了license?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

if (val) *val = static_cast< unsigned int >(v);
}
}
return res;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这一段是做什么的

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个是swig -c++ -python curvefs.i自动生成的

}

if (stripeUnit > defaultChunkSize_) {
LOG(ERROR) << "stripeUnit more then chunksize.stripeUnit:"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more than

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已改


return StatusCode::kOK;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stripeCount是不是不能大于chunksize/stripeSize?

Copy link
Author

@baijiaruo baijiaruo Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stripeCount理论上只需要满足defaultChunkSize_ % stripeCount = 0就可以了,但是实际使用上太大没有意义,不做修改

uint64_t curChunkSetIndex = stripeIndex / stripesPerChunk;
uint64_t curChunkIndex = curChunkSetIndex * stripeCount + stripepos;

uint64_t blockInChunkStart = (stripeIndex % stripesPerChunk)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个应该叫blockStartOff?

Copy link
Author

@baijiaruo baijiaruo Jan 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个表示的是某个block在chunk的起始位置,即start位置,已改成blockInChunkStartOff


FInfo_t fi;
uint64_t offset = 1 * 1024 * 1024 - 64 * 1024;
uint64_t length = 128 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

增加一个跨chunkset的用例吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -1,19 +1,3 @@
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个版权也加回去吧

* @param: filename文件名
* @param: userinfo是当前打开或创建时携带的user信息
* @param: size文件长度,当create为true的时候以size长度创建文件
* @param:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里stripe的两个参数注释没加

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增的部分都使用英文注释

*/
int Create2(const char* filename,
const C_UserInfo_t* userinfo,
size_t size, uint64_t stripeUnit, uint64_t stripeCount);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个用uint32_t就行了吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考虑扩展性,可不改

@@ -376,6 +378,8 @@ LIBCURVE_ERROR MDSClient::GetFileInfo(const std::string& filename,

if (response.has_fileinfo()) {
FileInfo finfo = response.fileinfo();
LOG(INFO) << "stripeUnit:" << finfo.stripeunit()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个日志可以去掉吧?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -5695,8 +5806,8 @@ SWIGINTERN PyObject *_wrap_GetClusterId(PyObject *SWIGUNUSEDPARM(self), PyObject
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
int result;
int retlen;

int retlen;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

缩进

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

testIORead = true;
}
std::unique_lock<std::mutex> lk(resumeMtx);
resumeCV.notify_all();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里没有delete context

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


readThread.join();
ASSERT_TRUE(testIORead);
ASSERT_EQ(strcmp(writebuf, readbuf), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strcmp依赖末尾的\0,这里可能会出问题。用strncmp吧

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writebuf的内容是不会出现\0的,只会是26个字母

* @return: 数据是否一致
*/
void VerifyDataConsistency(int fd, uint64_t offset, uint64_t size) {
char* writebuf = new char[size];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个buffer没有delete

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

currentChunkOffset, requestLength, mdsclient,
fileInfo, currentChunkIndex)) {
LOG(ERROR) << "request split failed"
if (!isStripe) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里如果不是条带的情况,stripeUnit设置成chunksize,stripeCount设置为1,else里面的逻辑是不是统一的?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

逻辑是统一的,我这里建议可以优化一下isStripe的判断加一个或上stripeCount=1的情况

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同 上。非stripe是stripe的一种特殊形式,统一处理看起来更清晰些。

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为了保持原来非条带代码的独立性,将条带逻辑进行区分,但是对于stripeCount=1的场景按非条带流程走

@@ -54,6 +54,12 @@ int CBDClient::Create(const char* filename, UserInfo_t* userInfo, size_t size) {
return client_->Create(filename, ToCurveClientUserInfo(userInfo), size);
}

int CBDClient::Create2(const char* filename, UserInfo_t* userInfo, size_t size,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit message的形式:模块名:***
client/mds:stripe feature

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @param: filename文件名
* @param: userinfo是当前打开或创建时携带的user信息
* @param: size文件长度,当create为true的时候以size长度创建文件
* @param:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增的部分都使用英文注释

@@ -111,6 +111,21 @@ class FileClient {
const UserInfo_t& userinfo,
size_t size);

/**
* 创建带条带的文件
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新增代码都使用英文注释

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -54,6 +54,8 @@ void MDSClientBase::OpenFile(const std::string& filename,
void MDSClientBase::CreateFile(const std::string& filename,
const UserInfo_t& userinfo,
size_t size,
uint32_t stripeUnit,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的参数顺序跟下面不一样,调用的时候会不会容易出错
LIBCURVE_ERROR CreateFile(const std::string& filename,
const UserInfo_t& userinfo, const UserInfo_t& userinfo,
size_t size = 0, size_t size = 0,
bool normalFile = true); bool normalFile = true,
uint32_t stripeUnit = 0,
uint32_t stripeCount = 0);

currentChunkOffset, requestLength, mdsclient,
fileInfo, currentChunkIndex)) {
LOG(ERROR) << "request split failed"
if (!isStripe) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同 上。非stripe是stripe的一种特殊形式,统一处理看起来更清晰些。

} else {
if (stripeCount == 1) {
LOG(INFO) << "stripe count is one, stripe size == chunk size";
stripeUnit = chunksize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果传入的stripeUnit跟chunksize不一致,才需要重新赋值?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以不用判断,这一块改成设置isStripe为false

uint64_t curChunkOffset = blockInChunkStart + blockOff;
uint64_t requestLength = std::min((stripeUnit - blockOff), left);

/*LOG(INFO) << "request split curChunkIndex = " << curChunkIndex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接删掉

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

if ((defaultChunkSize_ % stripeUnit != 0) ||
(defaultChunkSize_ % stripeCount != 0)) {
LOG(ERROR) << "is not divisible by chunksize. stripeUnit:"
<< stripeUnit << ",stripeCount:" << stripeCount;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有很多error的情况,是否只列出ok,其余返回error?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok的条件也比较多,场景一:stripeUnit和stripeCount同时等于0。场景二:strpeUnit小于defaultChunkSize_且stripeUnit和stripeCount都能被defaultChunkSize_整除,这里还要防止输入参数其中一个为0的情况出错。我认为写起来条理没有当前清晰

@ilixiaocui ilixiaocui changed the title merge stripe feature and unit test client/mds: merge stripe feature and unit test Feb 3, 2021
@@ -134,6 +134,8 @@ typedef struct FileStatInfo {
char filename[NAME_MAX_SIZE];
char owner[NAME_MAX_SIZE];
int fileStatus;
uint32_t stripeUnit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么这里stripUnit和stripeCount定义的uint32_t, 下面是uint64_t类型,下面也有很多地方是混用的

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

统一为uint64_t

* @param: size file size
* @param: stripeUnit block in stripe size
* @param stripeCount stripe count in one stripe
* @return: success return 0, fail teturn less than 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

currentChunkOffset, requestLength, mdsclient,
fileInfo, currentChunkIndex)) {
LOG(ERROR) << "request split failed"
if (!isStripe) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isStripe的两种情况是否可以封装为两个函数:StripeHandle NormalHandle?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前没有多处使用该部分代码逻辑,目前先不封装

@baijiaruo baijiaruo force-pushed the stripe branch 3 times, most recently from 0bc6e68 to 22cb6e7 Compare February 4, 2021 01:52
if (!AssignInternal(iotracker, metaCache, targetlist, data,
currentChunkOffset, requestLength, mdsclient,
fileInfo, currentChunkIndex)) {
LOG(ERROR) << "request split failed"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没对齐

@ilixiaocui ilixiaocui merged commit 70ff82d into opencurve:master Feb 5, 2021
ilixiaocui pushed a commit to ilixiaocui/curve that referenced this pull request Feb 6, 2023
cm: q2: Fluentd: add project idea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants