aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 7ecbe7c86186..a29a781b86c2 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -585,6 +585,31 @@ printk("adding new root for inode %lu root %p (found %p)\n", inode->i_ino, sub_r
585 return d_splice_alias(inode, dentry); 585 return d_splice_alias(inode, dentry);
586} 586}
587 587
588static void reada_leaves(struct btrfs_root *root, struct btrfs_path *path)
589{
590 struct btrfs_node *node;
591 int i;
592 int nritems;
593 u64 objectid;
594 u64 item_objectid;
595 u64 blocknr;
596 int slot;
597
598 if (!path->nodes[1])
599 return;
600 node = btrfs_buffer_node(path->nodes[1]);
601 slot = path->slots[1];
602 objectid = btrfs_disk_key_objectid(&node->ptrs[slot].key);
603 nritems = btrfs_header_nritems(&node->header);
604 for (i = slot; i < nritems; i++) {
605 item_objectid = btrfs_disk_key_objectid(&node->ptrs[i].key);
606 if (item_objectid != objectid)
607 break;
608 blocknr = btrfs_node_blockptr(node, i);
609 readahead_tree_block(root, blocknr);
610 }
611}
612
588static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 613static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
589{ 614{
590 struct inode *inode = filp->f_path.dentry->d_inode; 615 struct inode *inode = filp->f_path.dentry->d_inode;
@@ -619,6 +644,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
619 if (ret < 0) 644 if (ret < 0)
620 goto err; 645 goto err;
621 advance = 0; 646 advance = 0;
647 reada_leaves(root, path);
622 while(1) { 648 while(1) {
623 leaf = btrfs_buffer_leaf(path->nodes[0]); 649 leaf = btrfs_buffer_leaf(path->nodes[0]);
624 nritems = btrfs_header_nritems(&leaf->header); 650 nritems = btrfs_header_nritems(&leaf->header);
@@ -631,6 +657,8 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
631 leaf = btrfs_buffer_leaf(path->nodes[0]); 657 leaf = btrfs_buffer_leaf(path->nodes[0]);
632 nritems = btrfs_header_nritems(&leaf->header); 658 nritems = btrfs_header_nritems(&leaf->header);
633 slot = path->slots[0]; 659 slot = path->slots[0];
660 if (path->slots[1] == 0)
661 reada_leaves(root, path);
634 } else { 662 } else {
635 slot++; 663 slot++;
636 path->slots[0]++; 664 path->slots[0]++;