diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-05-01 08:53:32 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-05-01 08:53:32 -0400 |
commit | 090d18753c7fb73f7d846c3a89a50cd35136d144 (patch) | |
tree | e36965065fd68633c06cbe4b8312e5afe49997f4 /fs/btrfs/disk-io.c | |
parent | 31f3c99b73483f7b738a886c552050cbd6128ff3 (diff) |
Btrfs: directory readahead
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index e1b6e13a5ae8..354524adf984 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/scatterlist.h> | 5 | #include <linux/scatterlist.h> |
6 | #include <linux/swap.h> | 6 | #include <linux/swap.h> |
7 | #include <linux/radix-tree.h> | 7 | #include <linux/radix-tree.h> |
8 | #include <linux/file.h> | ||
8 | #include "ctree.h" | 9 | #include "ctree.h" |
9 | #include "disk-io.h" | 10 | #include "disk-io.h" |
10 | #include "transaction.h" | 11 | #include "transaction.h" |
@@ -253,6 +254,29 @@ static struct address_space_operations btree_aops = { | |||
253 | .sync_page = block_sync_page, | 254 | .sync_page = block_sync_page, |
254 | }; | 255 | }; |
255 | 256 | ||
257 | int readahead_tree_block(struct btrfs_root *root, u64 blocknr) | ||
258 | { | ||
259 | struct buffer_head *bh = NULL; | ||
260 | |||
261 | bh = btrfs_find_create_tree_block(root, blocknr); | ||
262 | if (!bh) | ||
263 | return 0; | ||
264 | if (buffer_uptodate(bh)) | ||
265 | goto done; | ||
266 | if (test_set_buffer_locked(bh)) | ||
267 | goto done; | ||
268 | if (!buffer_uptodate(bh)) { | ||
269 | get_bh(bh); | ||
270 | bh->b_end_io = end_buffer_read_sync; | ||
271 | submit_bh(READ, bh); | ||
272 | } else { | ||
273 | unlock_buffer(bh); | ||
274 | } | ||
275 | done: | ||
276 | brelse(bh); | ||
277 | return 0; | ||
278 | } | ||
279 | |||
256 | struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr) | 280 | struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr) |
257 | { | 281 | { |
258 | struct buffer_head *bh = NULL; | 282 | struct buffer_head *bh = NULL; |
@@ -270,11 +294,14 @@ struct buffer_head *read_tree_block(struct btrfs_root *root, u64 blocknr) | |||
270 | wait_on_buffer(bh); | 294 | wait_on_buffer(bh); |
271 | if (!buffer_uptodate(bh)) | 295 | if (!buffer_uptodate(bh)) |
272 | goto fail; | 296 | goto fail; |
273 | csum_tree_block(root, bh, 1); | ||
274 | } else { | 297 | } else { |
275 | unlock_buffer(bh); | 298 | unlock_buffer(bh); |
276 | } | 299 | } |
277 | uptodate: | 300 | uptodate: |
301 | if (!buffer_checked(bh)) { | ||
302 | csum_tree_block(root, bh, 1); | ||
303 | set_buffer_checked(bh); | ||
304 | } | ||
278 | if (check_tree_block(root, bh)) | 305 | if (check_tree_block(root, bh)) |
279 | BUG(); | 306 | BUG(); |
280 | return bh; | 307 | return bh; |