aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorArne Jansen <sensille@gmx.net>2011-05-23 08:25:41 -0400
committerArne Jansen <sensille@gmx.net>2011-10-02 02:47:57 -0400
commitab0fff03055d2d1b01a7581badeba18db9c4f55c (patch)
tree3bc6fbbdc7188623783db379eff8fbf23cdcb514 /fs/btrfs/disk-io.c
parentbb82ab88dfdb12948af58989c75bfe904bc1b09d (diff)
btrfs: add READAHEAD extent buffer flag
Add a READAHEAD extent buffer flag. Add a function to trigger a read with this flag set. Changes v2: - use extent buffer flags instead of extent state flags Changes v5: - adapt to changed read_extent_buffer_pages interface - don't return eb from reada_tree_block_flagged if it has CORRUPT flag set Signed-off-by: Arne Jansen <sensille@gmx.net>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e6170e142cad..1220d04072c8 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -980,6 +980,38 @@ int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
980 return ret; 980 return ret;
981} 981}
982 982
983int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize,
984 int mirror_num, struct extent_buffer **eb)
985{
986 struct extent_buffer *buf = NULL;
987 struct inode *btree_inode = root->fs_info->btree_inode;
988 struct extent_io_tree *io_tree = &BTRFS_I(btree_inode)->io_tree;
989 int ret;
990
991 buf = btrfs_find_create_tree_block(root, bytenr, blocksize);
992 if (!buf)
993 return 0;
994
995 set_bit(EXTENT_BUFFER_READAHEAD, &buf->bflags);
996
997 ret = read_extent_buffer_pages(io_tree, buf, 0, WAIT_PAGE_LOCK,
998 btree_get_extent, mirror_num);
999 if (ret) {
1000 free_extent_buffer(buf);
1001 return ret;
1002 }
1003
1004 if (test_bit(EXTENT_BUFFER_CORRUPT, &buf->bflags)) {
1005 free_extent_buffer(buf);
1006 return -EIO;
1007 } else if (extent_buffer_uptodate(io_tree, buf, NULL)) {
1008 *eb = buf;
1009 } else {
1010 free_extent_buffer(buf);
1011 }
1012 return 0;
1013}
1014
983struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root, 1015struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
984 u64 bytenr, u32 blocksize) 1016 u64 bytenr, u32 blocksize)
985{ 1017{