@@ -429,7 +429,7 @@ int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
429429 return 0 ;
430430}
431431
432- static unsigned long async_submit_limit (struct btrfs_fs_info * info )
432+ unsigned long btrfs_async_submit_limit (struct btrfs_fs_info * info )
433433{
434434 unsigned long limit = min_t (unsigned long ,
435435 info -> workers .max_workers ,
@@ -439,7 +439,8 @@ static unsigned long async_submit_limit(struct btrfs_fs_info *info)
439439
440440int btrfs_congested_async (struct btrfs_fs_info * info , int iodone )
441441{
442- return atomic_read (& info -> nr_async_bios ) > async_submit_limit (info );
442+ return atomic_read (& info -> nr_async_bios ) >
443+ btrfs_async_submit_limit (info );
443444}
444445
445446static void run_one_async_submit (struct btrfs_work * work )
@@ -451,12 +452,13 @@ static void run_one_async_submit(struct btrfs_work *work)
451452 async = container_of (work , struct async_submit_bio , work );
452453 fs_info = BTRFS_I (async -> inode )-> root -> fs_info ;
453454
454- limit = async_submit_limit (fs_info );
455+ limit = btrfs_async_submit_limit (fs_info );
455456 limit = limit * 2 / 3 ;
456457
457458 atomic_dec (& fs_info -> nr_async_submits );
458459
459- if (atomic_read (& fs_info -> nr_async_submits ) < limit )
460+ if (atomic_read (& fs_info -> nr_async_submits ) < limit &&
461+ waitqueue_active (& fs_info -> async_submit_wait ))
460462 wake_up (& fs_info -> async_submit_wait );
461463
462464 async -> submit_bio_hook (async -> inode , async -> rw , async -> bio ,
@@ -469,7 +471,7 @@ int btrfs_wq_submit_bio(struct btrfs_fs_info *fs_info, struct inode *inode,
469471 extent_submit_bio_hook_t * submit_bio_hook )
470472{
471473 struct async_submit_bio * async ;
472- int limit = async_submit_limit (fs_info );
474+ int limit = btrfs_async_submit_limit (fs_info );
473475
474476 async = kmalloc (sizeof (* async ), GFP_NOFS );
475477 if (!async )
@@ -1863,10 +1865,10 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr)
18631865 struct extent_io_tree * tree ;
18641866 u64 num_dirty ;
18651867 u64 start = 0 ;
1866- unsigned long thresh = 12 * 1024 * 1024 ;
1868+ unsigned long thresh = 96 * 1024 * 1024 ;
18671869 tree = & BTRFS_I (root -> fs_info -> btree_inode )-> io_tree ;
18681870
1869- if (current_is_pdflush ())
1871+ if (current_is_pdflush () || current -> flags & PF_MEMALLOC )
18701872 return ;
18711873
18721874 num_dirty = count_range_bits (tree , & start , (u64 )- 1 ,
0 commit comments