Commit 4b226454 authored by Linus Torvalds's avatar Linus Torvalds

Add an asynchronous buffer read-ahead facility. Nobody

uses it for now, but I needed it for some tuning tests,
and it is potentially useful for others.
parent d23caa21
......@@ -1447,6 +1447,28 @@ __getblk(struct block_device *bdev, sector_t block, int size)
}
EXPORT_SYMBOL(__getblk);
/*
* Do async read-ahead on a buffer..
*/
void
__breadahead(struct block_device *bdev, sector_t block, int size)
{
struct buffer_head *bh = __getblk(bdev, block, size);
if (!test_set_buffer_locked(bh)) {
if (!buffer_uptodate(bh)) {
/*
* This eats the bh count from __getblk() and
* unlocks when the read is done.
*/
bh->b_end_io = end_buffer_io_sync;
submit_bh(READ, bh);
return;
}
unlock_buffer(bh);
}
brelse(bh);
}
/**
* __bread() - reads a specified block and returns the bh
* @block: number of block
......
......@@ -167,6 +167,7 @@ struct buffer_head *__find_get_block(struct block_device *, sector_t, int);
struct buffer_head * __getblk(struct block_device *, sector_t, int);
void __brelse(struct buffer_head *);
void __bforget(struct buffer_head *);
void __breadahead(struct block_device *, sector_t block, int size);
struct buffer_head *__bread(struct block_device *, sector_t block, int size);
struct buffer_head *alloc_buffer_head(int gfp_flags);
void free_buffer_head(struct buffer_head * bh);
......@@ -241,6 +242,12 @@ sb_bread(struct super_block *sb, sector_t block)
return __bread(sb->s_bdev, block, sb->s_blocksize);
}
static inline void
sb_breadahead(struct super_block *sb, sector_t block)
{
__breadahead(sb->s_bdev, block, sb->s_blocksize);
}
static inline struct buffer_head *
sb_getblk(struct super_block *sb, sector_t block)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment