-
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
client/mds: merge stripe feature and unit test #211
Conversation
curvefs_python/curvefs.py
Outdated
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
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.
为什么把license删掉了?
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.
这个文件重新生成的时候默认没有,已补充
curvefs_python/curvefs_wrap.cxx
Outdated
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
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.
为什么去掉了license?
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.
同上
if (val) *val = static_cast< unsigned int >(v); | ||
} | ||
} | ||
return res; |
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.
这个是swig -c++ -python curvefs.i自动生成的
src/mds/nameserver2/curvefs.cpp
Outdated
} | ||
|
||
if (stripeUnit > defaultChunkSize_) { | ||
LOG(ERROR) << "stripeUnit more then chunksize.stripeUnit:" |
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.
more than
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 StatusCode::kOK; | ||
} | ||
|
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.
stripeCount是不是不能大于chunksize/stripeSize?
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.
stripeCount理论上只需要满足defaultChunkSize_ % stripeCount = 0就可以了,但是实际使用上太大没有意义,不做修改
src/client/splitor.cpp
Outdated
uint64_t curChunkSetIndex = stripeIndex / stripesPerChunk; | ||
uint64_t curChunkIndex = curChunkSetIndex * stripeCount + stripepos; | ||
|
||
uint64_t blockInChunkStart = (stripeIndex % stripesPerChunk) |
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.
这个应该叫blockStartOff?
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.
这个表示的是某个block在chunk的起始位置,即start位置,已改成blockInChunkStartOff
|
||
FInfo_t fi; | ||
uint64_t offset = 1 * 1024 * 1024 - 64 * 1024; | ||
uint64_t length = 128 * 1024; |
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.
增加一个跨chunkset的用例吧
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
curvefs_python/curvefs.py
Outdated
@@ -1,19 +1,3 @@ | |||
# |
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.
这个版权也加回去吧
include/client/libcurve.h
Outdated
* @param: filename文件名 | ||
* @param: userinfo是当前打开或创建时携带的user信息 | ||
* @param: size文件长度,当create为true的时候以size长度创建文件 | ||
* @param: |
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.
这里stripe的两个参数注释没加
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.
新增的部分都使用英文注释
*/ | ||
int Create2(const char* filename, | ||
const C_UserInfo_t* userinfo, | ||
size_t size, uint64_t stripeUnit, uint64_t stripeCount); |
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.
这两个用uint32_t就行了吧
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.
考虑扩展性,可不改
src/client/mds_client.cpp
Outdated
@@ -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() |
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.
done
curvefs_python/curvefs_wrap.cxx
Outdated
@@ -5695,8 +5806,8 @@ SWIGINTERN PyObject *_wrap_GetClusterId(PyObject *SWIGUNUSEDPARM(self), PyObject | |||
PyObject * obj0 = 0 ; | |||
PyObject * obj1 = 0 ; | |||
int result; | |||
int retlen; | |||
|
|||
int retlen; |
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.
done
testIORead = true; | ||
} | ||
std::unique_lock<std::mutex> lk(resumeMtx); | ||
resumeCV.notify_all(); |
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.
这里没有delete context
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
|
||
readThread.join(); | ||
ASSERT_TRUE(testIORead); | ||
ASSERT_EQ(strcmp(writebuf, readbuf), 0); |
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.
strcmp依赖末尾的\0
,这里可能会出问题。用strncmp吧
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.
writebuf的内容是不会出现\0的,只会是26个字母
* @return: 数据是否一致 | ||
*/ | ||
void VerifyDataConsistency(int fd, uint64_t offset, uint64_t size) { | ||
char* writebuf = new char[size]; |
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.
这两个buffer没有delete
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
currentChunkOffset, requestLength, mdsclient, | ||
fileInfo, currentChunkIndex)) { | ||
LOG(ERROR) << "request split failed" | ||
if (!isStripe) { |
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.
这里如果不是条带的情况,stripeUnit设置成chunksize,stripeCount设置为1,else里面的逻辑是不是统一的?
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.
逻辑是统一的,我这里建议可以优化一下isStripe的判断加一个或上stripeCount=1的情况
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.
同 上。非stripe是stripe的一种特殊形式,统一处理看起来更清晰些。
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.
为了保持原来非条带代码的独立性,将条带逻辑进行区分,但是对于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, |
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.
commit message的形式:模块名:***
client/mds:stripe feature
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
include/client/libcurve.h
Outdated
* @param: filename文件名 | ||
* @param: userinfo是当前打开或创建时携带的user信息 | ||
* @param: size文件长度,当create为true的时候以size长度创建文件 | ||
* @param: |
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.
新增的部分都使用英文注释
src/client/libcurve_file.h
Outdated
@@ -111,6 +111,21 @@ class FileClient { | |||
const UserInfo_t& userinfo, | |||
size_t size); | |||
|
|||
/** | |||
* 创建带条带的文件 |
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.
done
src/client/mds_client_base.cpp
Outdated
@@ -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, |
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.
这里的参数顺序跟下面不一样,调用的时候会不会容易出错
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) { |
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.
同 上。非stripe是stripe的一种特殊形式,统一处理看起来更清晰些。
src/client/splitor.cpp
Outdated
} else { | ||
if (stripeCount == 1) { | ||
LOG(INFO) << "stripe count is one, stripe size == chunk size"; | ||
stripeUnit = chunksize; |
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.
如果传入的stripeUnit跟chunksize不一致,才需要重新赋值?
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.
可以不用判断,这一块改成设置isStripe为false
src/client/splitor.cpp
Outdated
uint64_t curChunkOffset = blockInChunkStart + blockOff; | ||
uint64_t requestLength = std::min((stripeUnit - blockOff), left); | ||
|
||
/*LOG(INFO) << "request split curChunkIndex = " << curChunkIndex |
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.
done
if ((defaultChunkSize_ % stripeUnit != 0) || | ||
(defaultChunkSize_ % stripeCount != 0)) { | ||
LOG(ERROR) << "is not divisible by chunksize. stripeUnit:" | ||
<< stripeUnit << ",stripeCount:" << stripeCount; |
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.
这里有很多error的情况,是否只列出ok,其余返回error?
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.
ok的条件也比较多,场景一:stripeUnit和stripeCount同时等于0。场景二:strpeUnit小于defaultChunkSize_且stripeUnit和stripeCount都能被defaultChunkSize_整除,这里还要防止输入参数其中一个为0的情况出错。我认为写起来条理没有当前清晰
include/client/libcurve.h
Outdated
@@ -134,6 +134,8 @@ typedef struct FileStatInfo { | |||
char filename[NAME_MAX_SIZE]; | |||
char owner[NAME_MAX_SIZE]; | |||
int fileStatus; | |||
uint32_t stripeUnit; |
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.
为什么这里stripUnit和stripeCount定义的uint32_t, 下面是uint64_t类型,下面也有很多地方是混用的
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.
统一为uint64_t
src/client/libcurve_file.h
Outdated
* @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 |
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
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
currentChunkOffset, requestLength, mdsclient, | ||
fileInfo, currentChunkIndex)) { | ||
LOG(ERROR) << "request split failed" | ||
if (!isStripe) { |
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.
isStripe的两种情况是否可以封装为两个函数:StripeHandle NormalHandle?
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.
目前没有多处使用该部分代码逻辑,目前先不封装
0bc6e68
to
22cb6e7
Compare
if (!AssignInternal(iotracker, metaCache, targetlist, data, | ||
currentChunkOffset, requestLength, mdsclient, | ||
fileInfo, currentChunkIndex)) { | ||
LOG(ERROR) << "request split failed" |
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.
没对齐
cm: q2: Fluentd: add project idea
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