Chinaunix

标题: page cache 问题 [打印本页]

作者: Fleurer    时间: 2013-05-26 19:07
标题: page cache 问题
本帖最后由 Fleurer 于 2013-05-26 19:10 编辑

请教一下,ULK 第 601 页 "The address_space Object" 一节中:

Quite surprisingly, the page cache may happily contain multiple copies of the same disk data.


磁盘上的一个逻辑块允许同时缓存在n个文件的page cache中,比如 /dev/sda, /home/meow/hello.txt,那么这些冗余的缓存的一致性是怎样保证的呢?
作者: leil    时间: 2013-05-27 09:32
有些时候是需要业务上来保证。
作者: Fleurer    时间: 2013-06-14 19:45
本帖最后由 Fleurer 于 2013-06-14 19:52 编辑
leil 发表于 2013-05-27 09:32
有些时候是需要业务上来保证。


实验了下,确实没有同步(除了meta data):https://gist.github.com/anonymous/5781190

多谢!
作者: chishanmingshen    时间: 2013-06-14 20:49
回复 3# Fleurer

    这结论很意外啊。。。
    求.sh文件的详细指点啊,.sh文件里怎么突然出来了个output目录了?
作者: Fleurer    时间: 2013-06-14 21:05
本帖最后由 Fleurer 于 2013-06-14 21:06 编辑
chishanmingshen 发表于 2013-06-14 20:49
回复 3# Fleurer

    这结论很意外啊。。。


oops, 我把output目录的那几条命令漏掉了 更新一下 https://gist.github.com/5781597

大体是这样的思路:

1. 创建一个镜像文件,通过loopback device将它弄成一个block device file并mount到一个目录
2. 使用dd读取整个block device file,使其中所有的块进入page cache
3. 在mount的目录下新建一个a文件(内容为hello),并通过sync保证它确实写入了device
4. 再次使用dd读取整个block device file产生一个新的镜像,这次读取的内容实际上都位于page cache中
5. mount到output目录,跟之前的镜像文件做比对,如果存在不同(比如没有a存在?),就证明没有同步

得到的结果有点出乎我意料的是, output目录下仍有一个a文件,且文件的size与mount目录下的a文件相同,但它的内容实际上是空的。这一来得出的结论是,文件的metadata总会是同步的,然而冗余的page cache中的文件内容不会同步


作者: chishanmingshen    时间: 2013-06-14 22:34
回复 5# Fleurer

2和4的page cache是同一份啊,怎么会有你说的2份?

   
作者: uusky_cu    时间: 2013-06-15 00:57
实验不能说明问题.
作者: Fleurer    时间: 2013-06-15 08:21
本帖最后由 Fleurer 于 2013-06-15 08:24 编辑
chishanmingshen 发表于 2013-06-14 22:34
回复 5# Fleurer

2和4的page cache是同一份啊,怎么会有你说的2份?


sorry,我描述的还是太不清楚。每个文件都有单独的page cache(struct address_space)。

2和4涉及的都是device file的page cache,3涉及到device file中的文件a的page cache


作者: chishanmingshen    时间: 2013-06-15 09:01
回复 8# Fleurer

THANKS!!!



   




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2