Closed GoogleCodeExporter closed 9 years ago
该问题的修复方案应该这样更合理:
hlfs_open时,首先判断是否存在snapshot.txt文件,如果该文件存��
�则alive_shopshot.txt必然存在,而且有内容——如果不成立则报�
��退出。如果snapshot不存在,则不用检查alive
shopshot.txt了,直接启动即可。
Original comment by kanghua...@gmail.com
on 30 Jan 2012 at 10:36
这个bug,我增加了一个判断snapshot.txt和alive_snapshot.txt是否存��
�的函数,再需要的地方进行
提前判断,并做相应的处理即可解决问题,具体修复如下:
1, snapshot_helper.c 中增加如下公共函数
==================================
int is_first_start(struct back_storage *storage,
const char * snapshot_file,
const char *alive_snapshot_file) {
if (EHLFS_NOFILE == storage->bs_file_is_exist(storage,snapshot_file) &&
EHLFS_NOFILE == storage->bs_file_is_exist(storage,alive_snapshot_file)) {
HLOG_DEBUG("first start hlfs ...");
return HLFS_FS;
}
if (EHLFS_NOFILE != storage->bs_file_is_exist(storage,snapshot_file) &&
EHLFS_NOFILE == storage->bs_file_is_exist(storage,alive_snapshot_file)) {
HLOG_ERROR("Can not find alive snapshot file!");
return EHLFS_UNKNOWN;
}
if (EHLFS_NOFILE == storage->bs_file_is_exist(storage,snapshot_file) &&
EHLFS_NOFILE != storage->bs_file_is_exist(storage,alive_snapshot_file)) {
HLOG_ERROR("Can not find snapshot file!");
return EHLFS_UNKNOWN;
}
return 0;
}
2, hlfs_open 增加如下代码:
========================
[...]
if (HLFS_FS == (ret = is_first_start(ctrl->storage, SNAPSHOT_FILE, ALIVE_SNAPSHOT_FILE))) {
ss = (struct snapshot *)g_malloc0(sizeof(struct snapshot));
if (NULL == ss) {
HLOG_ERROR("Allocate Error!");
return EHLFS_MEM;
}
sprintf(ss->sname, "%s", FIRST_UP_NAME);
goto out;
} else if (EHLFS_UNKNOWN == ret) {
HLOG_ERROR("is first start error");
return EHLFS_UNKNOWN;
}
[...]
测试正常。
Original comment by harryxi...@gmail.com
on 31 Jan 2012 at 6:06
Original issue reported on code.google.com by
harryxi...@gmail.com
on 30 Jan 2012 at 7:29