Closed GoogleCodeExporter closed 9 years ago
具体地方找到了,我们的append_log有bug,当时,我们设计有点�
��忽,以下这种情况,append_log
就会出现问题。
假设,我们追加了10次log(每次追加4096B),
并且打了10个快照(T1---T10),然后我们卸载hlfs.
我们启动hlfs,回滚到T5处,
然后继续追加log并相应的进行快照,当进行到T12就会出现问��
�,具体分析如下:
测试源码
========
http://cloudxy.googlecode.com/svn/branches/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots.c
执行结果
=========
预期结果
--------------
无断言,一切正常
实际结果
---------------
jiawei@jiawei-laptop:~/workshop15/snapshot/src/snapshot/unittest/build$
./test_hlfs_tree_snapshots
/misc/hlfs_take_snapshot: ** Message: key file data :
[METADATA]
uri=local:///home/jiawei/workshop15/snapshot/src/snapshot/unittest/build/testfs
block_size=8192
segment_size=67108864
max_fs_size=1024
** Message: sb file path
/home/jiawei/workshop15/snapshot/src/snapshot/unittest/build/testfs/superblock
** Message: sb file path
1/home/jiawei/workshop15/snapshot/src/snapshot/unittest/build/testfs/superblock
** Message: sb file path
2/home/jiawei/workshop15/snapshot/src/snapshot/unittest/build/testfs/superblock
** Message: append size:148
**
ERROR:/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snap
shots.c:248:test_hlfs_tree_snapshots: assertion failed (ret1 == REQ_SIZE): (-1
== 4096)
已放弃
bug分析
=========
给出部分log
[....]
20120111 18:37:10.491 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/common/logger.c][append_log][436]entry
func: append_log
20120111 18:37:10.491 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/utils/address.c][ib_amount][78]ib_amount
db_start is 0
20120111 18:37:10.491 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/utils/address.c][ib_amount][79]ib_amount
db_end is 0
20120111 18:37:10.491 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/utils/address.c][ib_amount][106]ib_amount
we need 0 ibs
20120111 18:37:10.491 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/common/logger.c][append_log][466]
db_data_len:8192 ib_data_len:0 BLOCKSIZE:8192
20120111 18:37:10.492 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/common/logger.c][append_log][471]
db_cur_no:0 db_offset:48
20120111 18:37:10.492 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/common/logger.c][append_log][473] is
level1 -- db_cur_no:0 db_offset:48
20120111 18:37:10.492 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/common/logger.c][append_log][476] idx:0
20120111 18:37:10.492 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/utils/address.c][set_segno][19]harry dbg
*address is 8468
20120111 18:37:10.492 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/utils/address.c][set_segno][20]harry dbg
segno is 0
20120111 18:37:10.492 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/utils/address.c][set_segno][24]harry dbg
after set segno *address is 8468
20120111 18:37:10.492 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/common/logger.c][append_log][479]inode.blo
ck[0]'s storage addr:48
[......]
以下是T5快照对应的inode相关信息:
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][237]fixture->ctrl->imap_entry.inode_addr is
41920, inode_no is 77, iblock is 0, doubly_iblock is 0, triply_iblock is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[0] is 8468
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[1] is 25308
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[2] is 33728
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[3] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[4] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[5] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[6] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[7] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[8] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[9] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[10] is 0
20120111 18:37:10.490 DEBUG hlfslog-
[/home/jiawei/workshop15/snapshot/src/snapshot/unittest/test_hlfs_tree_snapshots
.c][test_hlfs_tree_snapshots][240]fixture->ctrl->inode.blocks[11] is 0
可以看出来T5 快照对应的inode直接索引信息是 blocks[0]是 8468
blocks[1]是25308
blocks[2] 是 33728, 但是经过第一次set_offset, blocks[0]变为了 48,
这就导致了后面
的错误。
bug目前状态
===========
目前还未想到很好的办法来处理这个bug ;-)
Original comment by harryxi...@gmail.com
on 11 Jan 2012 at 7:14
以上问题都解决了,现在我对以上问题进行总结一下:
1, 最早的测试用例有点问题,应该去掉
deinit_hlfs(fixture->ctrl);
fixture->ctrl = NULL;
fixture->ctrl = init_hlfs(fixture->uri);
g_assert(fixture->ctrl != NULL);
因为我们卸载hlfs,只需要hlfs_close, 重新挂载
我们只需进行 hlfs_open_by_inode。所以不需要
denit_hlfs 和 init_hlfs。
2, hlfs_close 中关闭了相应的 cur_write_file 和 cur_read_file
相应句柄也应置为 NULL
3, hlfs_close 中把 后台县城的 "阀门" 关了, hlfs_open_by_inode
需要进行开 “阀门”,具体可参见代码。
以上bug全部修复了,详见diffs, 目前可以正常构建树形快照了
;-)
Original comment by harryxi...@gmail.com
on 12 Jan 2012 at 2:18
Original issue reported on code.google.com by
harryxi...@gmail.com
on 11 Jan 2012 at 12:26