diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-25 14:03:08 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-25 14:03:08 -0400 |
commit | dcea79152cfb7cf244bdd9c23f4291831ffd6adf (patch) | |
tree | 1499d640d6a7f38282bdc879cd3878eaf671a751 /fs | |
parent | 134e97313491c3a3d6bc3eca3b7c9c64408cbd08 (diff) |
Btrfs: very simple readdir readahead
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/super.c | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f96bd92155cc..e76fcd80db6a 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -332,6 +332,34 @@ static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry, | |||
332 | return d_splice_alias(inode, dentry); | 332 | return d_splice_alias(inode, dentry); |
333 | } | 333 | } |
334 | 334 | ||
335 | static void reada_leaves(struct btrfs_root *root, struct btrfs_path *path) | ||
336 | { | ||
337 | struct buffer_head *bh; | ||
338 | struct btrfs_node *node; | ||
339 | int i; | ||
340 | int nritems; | ||
341 | u64 objectid; | ||
342 | u64 item_objectid; | ||
343 | u64 blocknr; | ||
344 | int slot; | ||
345 | |||
346 | if (!path->nodes[1]) | ||
347 | return; | ||
348 | node = btrfs_buffer_node(path->nodes[1]); | ||
349 | slot = path->slots[1]; | ||
350 | objectid = btrfs_disk_key_objectid(&node->ptrs[slot].key); | ||
351 | nritems = btrfs_header_nritems(&node->header); | ||
352 | for (i = slot; i < nritems; i++) { | ||
353 | item_objectid = btrfs_disk_key_objectid(&node->ptrs[i].key); | ||
354 | if (item_objectid != objectid) | ||
355 | break; | ||
356 | blocknr = btrfs_node_blockptr(node, i); | ||
357 | bh = sb_getblk(root->fs_info->sb, blocknr); | ||
358 | ll_rw_block(READ, 1, &bh); | ||
359 | brelse(bh); | ||
360 | } | ||
361 | |||
362 | } | ||
335 | static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | 363 | static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) |
336 | { | 364 | { |
337 | struct inode *inode = filp->f_path.dentry->d_inode; | 365 | struct inode *inode = filp->f_path.dentry->d_inode; |
@@ -358,6 +386,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
358 | goto err; | 386 | goto err; |
359 | } | 387 | } |
360 | advance = 0; | 388 | advance = 0; |
389 | reada_leaves(root, &path); | ||
361 | while(1) { | 390 | while(1) { |
362 | leaf = btrfs_buffer_leaf(path.nodes[0]); | 391 | leaf = btrfs_buffer_leaf(path.nodes[0]); |
363 | nritems = btrfs_header_nritems(&leaf->header); | 392 | nritems = btrfs_header_nritems(&leaf->header); |
@@ -370,13 +399,8 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
370 | leaf = btrfs_buffer_leaf(path.nodes[0]); | 399 | leaf = btrfs_buffer_leaf(path.nodes[0]); |
371 | nritems = btrfs_header_nritems(&leaf->header); | 400 | nritems = btrfs_header_nritems(&leaf->header); |
372 | slot = path.slots[0]; | 401 | slot = path.slots[0]; |
373 | #if 0 | 402 | if (path.nodes[1] && path.slots[1] == 0) |
374 | page_cache_readahead( | 403 | reada_leaves(root, &path); |
375 | inode->i_sb->s_bdev->bd_inode->i_mapping, | ||
376 | &filp->f_ra, filp, | ||
377 | path.nodes[0]->b_blocknr >> | ||
378 | (PAGE_CACHE_SHIFT - inode->i_blkbits), 1); | ||
379 | #endif | ||
380 | } else { | 404 | } else { |
381 | slot++; | 405 | slot++; |
382 | path.slots[0]++; | 406 | path.slots[0]++; |