Btrfs: dirindex optimizations

Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 4fd2b16..d4ee780 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -482,6 +482,11 @@
 		item = leaf->items + slot;
 		if (btrfs_disk_key_objectid(&item->key) != key.objectid)
 			break;
+		if (btrfs_disk_key_offset(&item->key) >
+		    root->fs_info->highest_inode) {
+printk("stopping at highest inode %Lu\n", root->fs_info->highest_inode);
+			break;
+		}
 		if (btrfs_disk_key_type(&item->key) != BTRFS_DIR_INDEX_KEY)
 			continue;
 		if (btrfs_disk_key_offset(&item->key) < filp->f_pos)