@@ -72,21 +72,41 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root);
7272static void btrfs_error_commit_super (struct btrfs_root * root );
7373
7474/*
75- * end_io_wq structs are used to do processing in task context when an IO is
76- * complete. This is used during reads to verify checksums, and it is used
75+ * btrfs_end_io_wq structs are used to do processing in task context when an IO
76+ * is complete. This is used during reads to verify checksums, and it is used
7777 * by writes to insert metadata for new file extents after IO is complete.
7878 */
79- struct end_io_wq {
79+ struct btrfs_end_io_wq {
8080 struct bio * bio ;
8181 bio_end_io_t * end_io ;
8282 void * private ;
8383 struct btrfs_fs_info * info ;
8484 int error ;
85- int metadata ;
85+ enum btrfs_wq_endio_type metadata ;
8686 struct list_head list ;
8787 struct btrfs_work work ;
8888};
8989
90+ static struct kmem_cache * btrfs_end_io_wq_cache ;
91+
92+ int __init btrfs_end_io_wq_init (void )
93+ {
94+ btrfs_end_io_wq_cache = kmem_cache_create ("btrfs_end_io_wq" ,
95+ sizeof (struct btrfs_end_io_wq ),
96+ 0 ,
97+ SLAB_RECLAIM_ACCOUNT | SLAB_MEM_SPREAD ,
98+ NULL );
99+ if (!btrfs_end_io_wq_cache )
100+ return - ENOMEM ;
101+ return 0 ;
102+ }
103+
104+ void btrfs_end_io_wq_exit (void )
105+ {
106+ if (btrfs_end_io_wq_cache )
107+ kmem_cache_destroy (btrfs_end_io_wq_cache );
108+ }
109+
90110/*
91111 * async submit bios are used to offload expensive checksumming
92112 * onto the worker threads. They checksum file and metadata bios
@@ -327,8 +347,7 @@ static int verify_parent_transid(struct extent_io_tree *io_tree,
327347{
328348 struct extent_state * cached_state = NULL ;
329349 int ret ;
330- bool need_lock = (current -> journal_info ==
331- (void * )BTRFS_SEND_TRANS_STUB );
350+ bool need_lock = (current -> journal_info == BTRFS_SEND_TRANS_STUB );
332351
333352 if (!parent_transid || btrfs_header_generation (eb ) == parent_transid )
334353 return 0 ;
@@ -690,7 +709,7 @@ static int btree_io_failed_hook(struct page *page, int failed_mirror)
690709
691710static void end_workqueue_bio (struct bio * bio , int err )
692711{
693- struct end_io_wq * end_io_wq = bio -> bi_private ;
712+ struct btrfs_end_io_wq * end_io_wq = bio -> bi_private ;
694713 struct btrfs_fs_info * fs_info ;
695714 struct btrfs_workqueue * wq ;
696715 btrfs_work_func_t func ;
@@ -733,20 +752,12 @@ static void end_workqueue_bio(struct bio *bio, int err)
733752 btrfs_queue_work (wq , & end_io_wq -> work );
734753}
735754
736- /*
737- * For the metadata arg you want
738- *
739- * 0 - if data
740- * 1 - if normal metadta
741- * 2 - if writing to the free space cache area
742- * 3 - raid parity work
743- */
744755int btrfs_bio_wq_end_io (struct btrfs_fs_info * info , struct bio * bio ,
745- int metadata )
756+ enum btrfs_wq_endio_type metadata )
746757{
747- struct end_io_wq * end_io_wq ;
758+ struct btrfs_end_io_wq * end_io_wq ;
748759
749- end_io_wq = kmalloc ( sizeof ( * end_io_wq ) , GFP_NOFS );
760+ end_io_wq = kmem_cache_alloc ( btrfs_end_io_wq_cache , GFP_NOFS );
750761 if (!end_io_wq )
751762 return - ENOMEM ;
752763
@@ -930,7 +941,7 @@ static int btree_submit_bio_hook(struct inode *inode, int rw, struct bio *bio,
930941 * can happen in the async kernel threads
931942 */
932943 ret = btrfs_bio_wq_end_io (BTRFS_I (inode )-> root -> fs_info ,
933- bio , 1 );
944+ bio , BTRFS_WQ_ENDIO_METADATA );
934945 if (ret )
935946 goto out_w_error ;
936947 ret = btrfs_map_bio (BTRFS_I (inode )-> root , rw , bio ,
@@ -1119,11 +1130,9 @@ struct extent_buffer *btrfs_find_tree_block(struct btrfs_root *root,
11191130struct extent_buffer * btrfs_find_create_tree_block (struct btrfs_root * root ,
11201131 u64 bytenr , u32 blocksize )
11211132{
1122- #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
1123- if (unlikely (test_bit (BTRFS_ROOT_DUMMY_ROOT , & root -> state )))
1133+ if (btrfs_test_is_dummy_root (root ))
11241134 return alloc_test_extent_buffer (root -> fs_info , bytenr ,
11251135 blocksize );
1126- #endif
11271136 return alloc_extent_buffer (root -> fs_info , bytenr , blocksize );
11281137}
11291138
@@ -1731,16 +1740,16 @@ static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
17311740static void end_workqueue_fn (struct btrfs_work * work )
17321741{
17331742 struct bio * bio ;
1734- struct end_io_wq * end_io_wq ;
1743+ struct btrfs_end_io_wq * end_io_wq ;
17351744 int error ;
17361745
1737- end_io_wq = container_of (work , struct end_io_wq , work );
1746+ end_io_wq = container_of (work , struct btrfs_end_io_wq , work );
17381747 bio = end_io_wq -> bio ;
17391748
17401749 error = end_io_wq -> error ;
17411750 bio -> bi_private = end_io_wq -> private ;
17421751 bio -> bi_end_io = end_io_wq -> end_io ;
1743- kfree ( end_io_wq );
1752+ kmem_cache_free ( btrfs_end_io_wq_cache , end_io_wq );
17441753 bio_endio_nodec (bio , error );
17451754}
17461755
@@ -2260,7 +2269,7 @@ int open_ctree(struct super_block *sb,
22602269 atomic_set (& fs_info -> qgroup_op_seq , 0 );
22612270 atomic64_set (& fs_info -> tree_mod_seq , 0 );
22622271 fs_info -> sb = sb ;
2263- fs_info -> max_inline = 8192 * 1024 ;
2272+ fs_info -> max_inline = BTRFS_DEFAULT_MAX_INLINE ;
22642273 fs_info -> metadata_ratio = 0 ;
22652274 fs_info -> defrag_inodes = RB_ROOT ;
22662275 fs_info -> free_chunk_space = 0 ;
0 commit comments