aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 92e14dd9bddb..bbba14b629d2 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -429,7 +429,7 @@ int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
429 return 0; 429 return 0;
430} 430}
431 431
432static unsigned long async_submit_limit(struct btrfs_fs_info *info) 432unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
433{ 433{
434 unsigned long limit = min_t(unsigned long, 434 unsigned long limit = min_t(unsigned long,
435 info->workers.max_workers, 435 info->workers.max_workers,
@@ -439,7 +439,8 @@ static unsigned long async_submit_limit(struct btrfs_fs_info *info)
439 439
440int btrfs_congested_async(struct btrfs_fs_info *info, int iodone) 440int btrfs_congested_async(struct btrfs_fs_info *info, int iodone)
441{ 441{
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);
443} 444}
444 445
445static void run_one_async_submit(struct btrfs_work *work) 446static void run_one_async_submit(struct btrfs_work *work)
@@ -451,12 +452,13 @@ static void run_one_async_submit(struct btrfs_work *work)
451 async = container_of(work, struct async_submit_bio, work); 452 async = container_of(work, struct async_submit_bio, work);
452 fs_info = BTRFS_I(async->inode)->root->fs_info; 453 fs_info = BTRFS_I(async->inode)->root->fs_info;
453 454
454 limit = async_submit_limit(fs_info); 455 limit = btrfs_async_submit_limit(fs_info);
455 limit = limit * 2 / 3; 456 limit = limit * 2 / 3;
456 457
457 atomic_dec(&fs_info->nr_async_submits); 458 atomic_dec(&fs_info->nr_async_submits);
458 459
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))
460 wake_up(&fs_info->async_submit_wait); 462 wake_up(&fs_info->async_submit_wait);
461 463
462 async->submit_bio_hook(async->inode, async->rw, async->bio, 464 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,
469 extent_submit_bio_hook_t *submit_bio_hook) 471 extent_submit_bio_hook_t *submit_bio_hook)
470{ 472{
471 struct async_submit_bio *async; 473 struct async_submit_bio *async;
472 int limit = async_submit_limit(fs_info); 474 int limit = btrfs_async_submit_limit(fs_info);
473 475
474 async = kmalloc(sizeof(*async), GFP_NOFS); 476 async = kmalloc(sizeof(*async), GFP_NOFS);
475 if (!async) 477 if (!async)
@@ -1863,10 +1865,10 @@ void btrfs_btree_balance_dirty(struct btrfs_root *root, unsigned long nr)
1863 struct extent_io_tree *tree; 1865 struct extent_io_tree *tree;
1864 u64 num_dirty; 1866 u64 num_dirty;
1865 u64 start = 0; 1867 u64 start = 0;
1866 unsigned long thresh = 12 * 1024 * 1024; 1868 unsigned long thresh = 96 * 1024 * 1024;
1867 tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree; 1869 tree = &BTRFS_I(root->fs_info->btree_inode)->io_tree;
1868 1870
1869 if (current_is_pdflush()) 1871 if (current_is_pdflush() || current->flags & PF_MEMALLOC)
1870 return; 1872 return;
1871 1873
1872 num_dirty = count_range_bits(tree, &start, (u64)-1, 1874 num_dirty = count_range_bits(tree, &start, (u64)-1,