aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-04-12 06:24:32 -0400
committerJens Axboe <axboe@fb.com>2017-04-20 14:09:55 -0400
commit9e11ceee23f25b6bb03de97ad1b729784f09538c (patch)
tree42b051657092fb3db14cbc0eadb5e2fd50e8478e
parent71304feba33f4b007cdb5cbbbe24c0e8d87ff689 (diff)
btrfs: Convert to separately allocated bdi
Allocate struct backing_dev_info separately instead of embedding it inside superblock. This unifies handling of bdi among users. CC: Chris Mason <clm@fb.com> CC: Josef Bacik <jbacik@fb.com> CC: David Sterba <dsterba@suse.com> CC: linux-btrfs@vger.kernel.org Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: David Sterba <dsterba@suse.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/disk-io.c36
-rw-r--r--fs/btrfs/super.c7
3 files changed, 14 insertions, 30 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 29b7fc28c607..f6019ce20035 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -810,7 +810,6 @@ struct btrfs_fs_info {
810 struct btrfs_super_block *super_for_commit; 810 struct btrfs_super_block *super_for_commit;
811 struct super_block *sb; 811 struct super_block *sb;
812 struct inode *btree_inode; 812 struct inode *btree_inode;
813 struct backing_dev_info bdi;
814 struct mutex tree_log_mutex; 813 struct mutex tree_log_mutex;
815 struct mutex transaction_kthread_mutex; 814 struct mutex transaction_kthread_mutex;
816 struct mutex cleaner_mutex; 815 struct mutex cleaner_mutex;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 08b74daf35d0..a7d8c342f604 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1808,21 +1808,6 @@ static int btrfs_congested_fn(void *congested_data, int bdi_bits)
1808 return ret; 1808 return ret;
1809} 1809}
1810 1810
1811static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
1812{
1813 int err;
1814
1815 err = bdi_setup_and_register(bdi, "btrfs");
1816 if (err)
1817 return err;
1818
1819 bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
1820 bdi->congested_fn = btrfs_congested_fn;
1821 bdi->congested_data = info;
1822 bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
1823 return 0;
1824}
1825
1826/* 1811/*
1827 * called by the kthread helper functions to finally call the bio end_io 1812 * called by the kthread helper functions to finally call the bio end_io
1828 * functions. This is where read checksum verification actually happens 1813 * functions. This is where read checksum verification actually happens
@@ -2601,16 +2586,10 @@ int open_ctree(struct super_block *sb,
2601 goto fail; 2586 goto fail;
2602 } 2587 }
2603 2588
2604 ret = setup_bdi(fs_info, &fs_info->bdi);
2605 if (ret) {
2606 err = ret;
2607 goto fail_srcu;
2608 }
2609
2610 ret = percpu_counter_init(&fs_info->dirty_metadata_bytes, 0, GFP_KERNEL); 2589 ret = percpu_counter_init(&fs_info->dirty_metadata_bytes, 0, GFP_KERNEL);
2611 if (ret) { 2590 if (ret) {
2612 err = ret; 2591 err = ret;
2613 goto fail_bdi; 2592 goto fail_srcu;
2614 } 2593 }
2615 fs_info->dirty_metadata_batch = PAGE_SIZE * 2594 fs_info->dirty_metadata_batch = PAGE_SIZE *
2616 (1 + ilog2(nr_cpu_ids)); 2595 (1 + ilog2(nr_cpu_ids));
@@ -2718,7 +2697,6 @@ int open_ctree(struct super_block *sb,
2718 2697
2719 sb->s_blocksize = 4096; 2698 sb->s_blocksize = 4096;
2720 sb->s_blocksize_bits = blksize_bits(4096); 2699 sb->s_blocksize_bits = blksize_bits(4096);
2721 sb->s_bdi = &fs_info->bdi;
2722 2700
2723 btrfs_init_btree_inode(fs_info); 2701 btrfs_init_btree_inode(fs_info);
2724 2702
@@ -2915,9 +2893,12 @@ int open_ctree(struct super_block *sb,
2915 goto fail_sb_buffer; 2893 goto fail_sb_buffer;
2916 } 2894 }
2917 2895
2918 fs_info->bdi.ra_pages *= btrfs_super_num_devices(disk_super); 2896 sb->s_bdi->congested_fn = btrfs_congested_fn;
2919 fs_info->bdi.ra_pages = max(fs_info->bdi.ra_pages, 2897 sb->s_bdi->congested_data = fs_info;
2920 SZ_4M / PAGE_SIZE); 2898 sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
2899 sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
2900 sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);
2901 sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE);
2921 2902
2922 sb->s_blocksize = sectorsize; 2903 sb->s_blocksize = sectorsize;
2923 sb->s_blocksize_bits = blksize_bits(sectorsize); 2904 sb->s_blocksize_bits = blksize_bits(sectorsize);
@@ -3285,8 +3266,6 @@ fail_delalloc_bytes:
3285 percpu_counter_destroy(&fs_info->delalloc_bytes); 3266 percpu_counter_destroy(&fs_info->delalloc_bytes);
3286fail_dirty_metadata_bytes: 3267fail_dirty_metadata_bytes:
3287 percpu_counter_destroy(&fs_info->dirty_metadata_bytes); 3268 percpu_counter_destroy(&fs_info->dirty_metadata_bytes);
3288fail_bdi:
3289 bdi_destroy(&fs_info->bdi);
3290fail_srcu: 3269fail_srcu:
3291 cleanup_srcu_struct(&fs_info->subvol_srcu); 3270 cleanup_srcu_struct(&fs_info->subvol_srcu);
3292fail: 3271fail:
@@ -4007,7 +3986,6 @@ void close_ctree(struct btrfs_fs_info *fs_info)
4007 percpu_counter_destroy(&fs_info->dirty_metadata_bytes); 3986 percpu_counter_destroy(&fs_info->dirty_metadata_bytes);
4008 percpu_counter_destroy(&fs_info->delalloc_bytes); 3987 percpu_counter_destroy(&fs_info->delalloc_bytes);
4009 percpu_counter_destroy(&fs_info->bio_counter); 3988 percpu_counter_destroy(&fs_info->bio_counter);
4010 bdi_destroy(&fs_info->bdi);
4011 cleanup_srcu_struct(&fs_info->subvol_srcu); 3989 cleanup_srcu_struct(&fs_info->subvol_srcu);
4012 3990
4013 btrfs_free_stripe_hash_table(fs_info); 3991 btrfs_free_stripe_hash_table(fs_info);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index da687dc79cce..e0a7503ab31e 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -1133,6 +1133,13 @@ static int btrfs_fill_super(struct super_block *sb,
1133#endif 1133#endif
1134 sb->s_flags |= MS_I_VERSION; 1134 sb->s_flags |= MS_I_VERSION;
1135 sb->s_iflags |= SB_I_CGROUPWB; 1135 sb->s_iflags |= SB_I_CGROUPWB;
1136
1137 err = super_setup_bdi(sb);
1138 if (err) {
1139 btrfs_err(fs_info, "super_setup_bdi failed");
1140 return err;
1141 }
1142
1136 err = open_ctree(sb, fs_devices, (char *)data); 1143 err = open_ctree(sb, fs_devices, (char *)data);
1137 if (err) { 1144 if (err) {
1138 btrfs_err(fs_info, "open_ctree failed"); 1145 btrfs_err(fs_info, "open_ctree failed");