- 论坛徽章:
- 0
|
在2.6中读一个普通文件时会通过下面调用来实现:
sys_read()->vfs_read()->generic_file_read()->__generic_file_aio_read()
->do_generic_file_read()->do_generic_mapping_read()->mpage_readpage()
->do_mpage_readpage()
而在do_mpage_readpage函数中有这么一段:(.../fs/Mpage.c about line 209)
static struct bio *
do_mpage_readpage(struct bio *bio, struct page *page, unsigned nr_pages,
sector_t *last_block_in_bio, get_block_t get_block)
{
......
/* Contiguous blocks? */
if (page_block && blocks[page_block-1] != bh.b_blocknr-1)
goto confused;
......
}
这段代码在判断这个page中相邻的两个block的物理地址是否邻接,
如果不是就跳到一个出错处理的代码段中。
可以说在一个page中的相邻的block的物理地址也是相邻的吗?
但是一些书中都说一个page中的block可以来自不连续的物理块:
Formally, a buffer page is a page of data associated with additional descriptors called "buffer heads ," whose main purpose is to quickly locate the disk address of each individual block in the page. In fact, the chunks of data stored in a page belonging to the page cache are not necessarily adjacent on disk.
《Understanding the Linux Kernel》 3rd Edition. 15.2节
我也觉得没有必要连续,但是上面的代码有应该怎样理解呢?
请各位指点迷津!
谢谢谢谢!! |
|