aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/disk-io.c32
-rw-r--r--fs/btrfs/disk-io.h2
-rw-r--r--fs/btrfs/extent_io.h1
3 files changed, 35 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{
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index bec3ea4bd67f..b3bdb5c1390f 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -40,6 +40,8 @@ struct extent_buffer *read_tree_block(struct btrfs_root *root, u64 bytenr,
40 u32 blocksize, u64 parent_transid); 40 u32 blocksize, u64 parent_transid);
41int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize, 41int readahead_tree_block(struct btrfs_root *root, u64 bytenr, u32 blocksize,
42 u64 parent_transid); 42 u64 parent_transid);
43int reada_tree_block_flagged(struct btrfs_root *root, u64 bytenr, u32 blocksize,
44 int mirror_num, struct extent_buffer **eb);
43struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, 45struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root,
44 u64 bytenr, u32 blocksize); 46 u64 bytenr, u32 blocksize);
45int clean_tree_block(struct btrfs_trans_handle *trans, 47int clean_tree_block(struct btrfs_trans_handle *trans,
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index 6d74c6b34691..fcaf49bcb880 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -32,6 +32,7 @@
32#define EXTENT_BUFFER_BLOCKING 1 32#define EXTENT_BUFFER_BLOCKING 1
33#define EXTENT_BUFFER_DIRTY 2 33#define EXTENT_BUFFER_DIRTY 2
34#define EXTENT_BUFFER_CORRUPT 3 34#define EXTENT_BUFFER_CORRUPT 3
35#define EXTENT_BUFFER_READAHEAD 4 /* this got triggered by readahead */
35 36
36/* these are flags for extent_clear_unlock_delalloc */ 37/* these are flags for extent_clear_unlock_delalloc */
37#define EXTENT_CLEAR_UNLOCK_PAGE 0x1 38#define EXTENT_CLEAR_UNLOCK_PAGE 0x1