Beispiel #1
0
/*
 * bread_page reads four buffers into memory at the desired address. It's
 * a function of its own, as there is some speed to be got by reading them
 * all at the same time, not waiting for one to be read, and then another
 * etc. This also allows us to optimize memory usage by sharing code pages
 * and filesystem buffers..
 */
unsigned long bread_page(unsigned long address, dev_t dev, int b[], int size, int prot)
{
	struct buffer_head * bh[8];
	unsigned long where;
	int i, j;

	if (!(prot & PAGE_RW)) {
		where = try_to_share_buffers(address,dev,b,size);
		if (where)
			return where;
	}
	++current->maj_flt;
 	for (i=0, j=0; j<PAGE_SIZE ; i++, j+= size) {
		bh[i] = NULL;
		if (b[i])
			bh[i] = getblk(dev, b[i], size);
	}
	read_buffers(bh,i);
	where = address;
 	for (i=0, j=0; j<PAGE_SIZE ; i++, j += size,address += size) {
		if (bh[i]) {
			if (bh[i]->b_uptodate)
				COPYBLK(size, (unsigned long) bh[i]->b_data,address);
			brelse(bh[i]);
		}
	}
	return where;
}
Beispiel #2
0
/*
 * bread_page reads four buffers into memory at the desired address. It's
 * a function of its own, as there is some speed to be got by reading them
 * all at the same time, not waiting for one to be read, and then another
 * etc.
 */
void bread_page(unsigned long address,int dev,int b[4])
{
	struct buffer_head * bh[4];
	int i;

	for (i=0 ; i<4 ; i++)
		if (b[i]) {
			if (bh[i] = getblk(dev, b[i], 1024))
				if (!bh[i]->b_uptodate)
					ll_rw_block(READ,bh[i]);
		} else
			bh[i] = NULL;
	for (i=0 ; i<4 ; i++,address += BLOCK_SIZE)
		if (bh[i]) {
			wait_on_buffer(bh[i]);
			if (bh[i]->b_uptodate)
				COPYBLK((unsigned long) bh[i]->b_data,address);
			brelse(bh[i]);
		}
}
Beispiel #3
0
//// 读设备上一个页面(4 个缓冲块)的内容到内存指定的地址。
void
bread_page( unsigned long address, int dev, int b[4] )
{
	struct buffer_head	*bh[4];
	int					i;

// 循环执行4 次,读一页内容。
	for( i = 0; i < 4; i++ )
	{
		if( b[i] )
		{
// 取高速缓冲中指定设备和块号的缓冲区,如果该缓冲区数据无效则产生读设备请求。
			if( bh[i] = getblk( dev, b[i] ) )
			{
				if( !bh[i]->b_uptodate )
				{
					ll_rw_block( READ, bh[i] );
				}
			}
		}else
		{
			bh[i] = NULL;
		}
	}
// 将4 块缓冲区上的内容顺序复制到指定地址处。
	for( i = 0; i < 4; i++, address += BLOCK_SIZE )
	{
		if( bh[i] )
		{
			wait_on_buffer( bh[i] );    // 等待缓冲区解锁(如果已被上锁的话)。
			if( bh[i]->b_uptodate )     // 如果该缓冲区中数据有效的话,则复制。
			{
				COPYBLK( (unsigned long)bh[i]->b_data, address );
			}
			brelse( bh[i] );            // 释放该缓冲区。
		}
	}
}