HarryWei / cloudxy

Automatically exported from code.google.com/p/cloudxy
6 stars 3 forks source link

[Bug]hlfs_find_inode_before_time get the incoorect resule in light of our wiki description #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
bug概述
========
hlfs_find_inode_before_time主要负责用户在模糊时间下找到这个时��
�
之前的一个inode addr, 严格来说只能找到之前的inode addr, 
如果之前
没有inode,那么就返回一个错误信息了,但是目前我们的hlfs_f
ind_inode_before_time
实现上有所偏差,需要进行修复。

具体hlfs_find_inode_before_time实现细节如下:
回滚到检查点(只知道模糊时间点):调用find_inode_before_time获��
�inode结构体,
然后调用get_inode_info() 
获取inode信息,根据该信息判断是否满足用户要求,
则启动回滚——调用init_hlfs()获得全局控制结构,并以只读或
者是可写模式调用
hlfs_open_by_inode()

测试代码
=========
http://cloudxy.googlecode.com/svn/branches/snapshot/src/snapshot/unittest/test_h
lfs_find_inode_before_time.c

测试结果
=========
jiawei@jiawei-laptop:~/workshop15/cloudxy1/branches/snapshot/src/snapshot/unitte
st/build$ ./test_hlfs_find_inode_before_time
** Message: enter func main
** Message: leave func main
[snipped]
** Message: current time [0], inode addr is [8240]
** Message: current time [1328112969626], inode addr is [16660]
** Message: current time [1328112970028], inode addr is [84020]
** Message: leave func test_hlfs_find_inode_before_time
clean dir path: 
/home/jiawei/workshop15/cloudxy1/branches/snapshot/src/snapshot/unittest/build
OK

jiawei@jiawei-laptop:~/workshop15/cloudxy1/branches/snapshot/src/snapshot/unitte
st/build$ cat testfs/snapshot.txt
+T0@@##$$1328112969644@@##$$8240@@##$$
+T1@@##$$1328112969689@@##$$16660@@##$$T0
+T2@@##$$1328112969724@@##$$25080@@##$$T1
+T3@@##$$1328112969769@@##$$33500@@##$$T2
+T4@@##$$1328112969814@@##$$41920@@##$$T3
+T5@@##$$1328112969858@@##$$50340@@##$$T4
+T6@@##$$1328112969903@@##$$58760@@##$$T5

测试分析
========
对比测试运行结果和 
snapshot.txt文件就可以看出来确实有问题,
当时间为0时居然还找到了一个inode 
addr,显然不对,再看看下面
的一个也存在问题。

bug状态
=======
这个bug目前还未修复,马上进行修复,如果你对此bug还存在��
�他更好的
建议,大家可以进行讨论,我们采用最优方式。

Original issue reported on code.google.com by harryxi...@gmail.com on 1 Feb 2012 at 5:16

GoogleCodeExporter commented 9 years ago
我给出两种解决方案,自己感觉不是很smart,但是比较直接,
有效,
需要康师哥 review 一下,如果合适再进行fix,具体方案如下:

方案一[前提是,每个段中的log中的inode的mtime不是按照从小到
大的自然顺序]
--------------------------------------------------------------------------------
------------------------------------
我们可以把选定段中的每个log中的inode的按照mtime 
从大到小进行排序,
(注意:从大到小有序) 
然后与timestamp进行比较,这样如果碰到第一个
小于timestamp的inode,则是我们需要找的。

方案二[前提是,每个段中的log中的inode的mtime是按照从小到大
的自然顺序]
--------------------------------------------------------------------------------
-------------------------------------
这就简单了,省去排序的步骤了,直接从每个段得最后提取lo
g即可。

我更偏向于方案二,目前还没想出方案一是否存在。如果方��
�一的前提存在,那么
解决起来可能复杂一点了  ;-)

Original comment by harryxi...@gmail.com on 1 Feb 2012 at 6:30