aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-03-26 10:28:07 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:01 -0400
commit04160088141a6be06d5cb9e53e34076b51803ffc (patch)
tree8dc407b1fe8fced2588121e8d58450f3a8ed8807 /fs/btrfs/disk-io.c
parent593060d756e0c2382d59cf00d5f3b9e3a336c408 (diff)
Create a btrfs backing dev info
This allows intelligent versions of unplug and congestion functions Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d8474796dea2..6a70e4916ab4 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -655,6 +655,55 @@ static int add_hasher(struct btrfs_fs_info *info, char *type) {
655 return 0; 655 return 0;
656} 656}
657#endif 657#endif
658
659static int btrfs_congested_fn(void *congested_data, int bdi_bits)
660{
661 struct btrfs_fs_info *info = (struct btrfs_fs_info *)congested_data;
662 int ret = 0;
663 struct list_head *cur;
664 struct btrfs_device *device;
665 struct backing_dev_info *bdi;
666
667 list_for_each(cur, &info->fs_devices->devices) {
668 device = list_entry(cur, struct btrfs_device, dev_list);
669 bdi = blk_get_backing_dev_info(device->bdev);
670 if (bdi && bdi_congested(bdi, bdi_bits)) {
671 ret = 1;
672 break;
673 }
674 }
675 return ret;
676}
677
678void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)
679{
680 struct list_head *cur;
681 struct btrfs_device *device;
682 struct btrfs_fs_info *info;
683
684 info = (struct btrfs_fs_info *)bdi->unplug_io_data;
685 list_for_each(cur, &info->fs_devices->devices) {
686 device = list_entry(cur, struct btrfs_device, dev_list);
687 bdi = blk_get_backing_dev_info(device->bdev);
688 if (bdi->unplug_io_fn) {
689 bdi->unplug_io_fn(bdi, page);
690 }
691 }
692}
693
694static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
695{
696 bdi_init(bdi);
697 bdi->ra_pages = default_backing_dev_info.ra_pages;
698 bdi->state = 0;
699 bdi->capabilities = default_backing_dev_info.capabilities;
700 bdi->unplug_io_fn = btrfs_unplug_io_fn;
701 bdi->unplug_io_data = info;
702 bdi->congested_fn = btrfs_congested_fn;
703 bdi->congested_data = info;
704 return 0;
705}
706
658struct btrfs_root *open_ctree(struct super_block *sb, 707struct btrfs_root *open_ctree(struct super_block *sb,
659 struct btrfs_fs_devices *fs_devices) 708 struct btrfs_fs_devices *fs_devices)
660{ 709{
@@ -708,11 +757,14 @@ struct btrfs_root *open_ctree(struct super_block *sb,
708 fs_info->max_extent = (u64)-1; 757 fs_info->max_extent = (u64)-1;
709 fs_info->max_inline = 8192 * 1024; 758 fs_info->max_inline = 8192 * 1024;
710 fs_info->delalloc_bytes = 0; 759 fs_info->delalloc_bytes = 0;
760 setup_bdi(fs_info, &fs_info->bdi);
711 fs_info->btree_inode = new_inode(sb); 761 fs_info->btree_inode = new_inode(sb);
712 fs_info->btree_inode->i_ino = 1; 762 fs_info->btree_inode->i_ino = 1;
713 fs_info->btree_inode->i_nlink = 1; 763 fs_info->btree_inode->i_nlink = 1;
714 fs_info->btree_inode->i_size = sb->s_bdev->bd_inode->i_size; 764 fs_info->btree_inode->i_size = sb->s_bdev->bd_inode->i_size;
715 fs_info->btree_inode->i_mapping->a_ops = &btree_aops; 765 fs_info->btree_inode->i_mapping->a_ops = &btree_aops;
766 fs_info->btree_inode->i_mapping->backing_dev_info = &fs_info->bdi;
767
716 extent_io_tree_init(&BTRFS_I(fs_info->btree_inode)->io_tree, 768 extent_io_tree_init(&BTRFS_I(fs_info->btree_inode)->io_tree,
717 fs_info->btree_inode->i_mapping, 769 fs_info->btree_inode->i_mapping,
718 GFP_NOFS); 770 GFP_NOFS);
@@ -992,6 +1044,7 @@ int close_ctree(struct btrfs_root *root)
992#endif 1044#endif
993 close_all_devices(fs_info); 1045 close_all_devices(fs_info);
994 btrfs_mapping_tree_free(&fs_info->mapping_tree); 1046 btrfs_mapping_tree_free(&fs_info->mapping_tree);
1047 bdi_destroy(&fs_info->bdi);
995 1048
996 kfree(fs_info->extent_root); 1049 kfree(fs_info->extent_root);
997 kfree(fs_info->tree_root); 1050 kfree(fs_info->tree_root);