diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-04 18:31:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-04 18:31:36 -0400 |
commit | 53c566625fb872e7826a237f0f5c21458028e94a (patch) | |
tree | 8ef9990ed2124f085442bc5a44c3f5212bf4002d /fs/btrfs/inode.c | |
parent | 34917f9713905a937816ebb7ee5f25bef7a6441c (diff) | |
parent | 00fdf13a2e9f313a044288aa59d3b8ec29ff904a (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs
Pull btrfs changes from Chris Mason:
"This is a pretty long stream of bug fixes and performance fixes.
Qu Wenruo has replaced the btrfs async threads with regular kernel
workqueues. We'll keep an eye out for performance differences, but
it's nice to be using more generic code for this.
We still have some corruption fixes and other patches coming in for
the merge window, but this batch is tested and ready to go"
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs: (108 commits)
Btrfs: fix a crash of clone with inline extents's split
btrfs: fix uninit variable warning
Btrfs: take into account total references when doing backref lookup
Btrfs: part 2, fix incremental send's decision to delay a dir move/rename
Btrfs: fix incremental send's decision to delay a dir move/rename
Btrfs: remove unnecessary inode generation lookup in send
Btrfs: fix race when updating existing ref head
btrfs: Add trace for btrfs_workqueue alloc/destroy
Btrfs: less fs tree lock contention when using autodefrag
Btrfs: return EPERM when deleting a default subvolume
Btrfs: add missing kfree in btrfs_destroy_workqueue
Btrfs: cache extent states in defrag code path
Btrfs: fix deadlock with nested trans handles
Btrfs: fix possible empty list access when flushing the delalloc inodes
Btrfs: split the global ordered extents mutex
Btrfs: don't flush all delalloc inodes when we doesn't get s_umount lock
Btrfs: reclaim delalloc metadata more aggressively
Btrfs: remove unnecessary lock in may_commit_transaction()
Btrfs: remove the unnecessary flush when preparing the pages
Btrfs: just do dirty page flush for the inode with compression before direct IO
...
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 121 |
1 files changed, 75 insertions, 46 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 49ec1398879f..06e9a4152b14 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -864,7 +864,8 @@ static noinline int cow_file_range(struct inode *inode, | |||
864 | 864 | ||
865 | if (btrfs_is_free_space_inode(inode)) { | 865 | if (btrfs_is_free_space_inode(inode)) { |
866 | WARN_ON_ONCE(1); | 866 | WARN_ON_ONCE(1); |
867 | return -EINVAL; | 867 | ret = -EINVAL; |
868 | goto out_unlock; | ||
868 | } | 869 | } |
869 | 870 | ||
870 | num_bytes = ALIGN(end - start + 1, blocksize); | 871 | num_bytes = ALIGN(end - start + 1, blocksize); |
@@ -1075,17 +1076,15 @@ static int cow_file_range_async(struct inode *inode, struct page *locked_page, | |||
1075 | async_cow->end = cur_end; | 1076 | async_cow->end = cur_end; |
1076 | INIT_LIST_HEAD(&async_cow->extents); | 1077 | INIT_LIST_HEAD(&async_cow->extents); |
1077 | 1078 | ||
1078 | async_cow->work.func = async_cow_start; | 1079 | btrfs_init_work(&async_cow->work, async_cow_start, |
1079 | async_cow->work.ordered_func = async_cow_submit; | 1080 | async_cow_submit, async_cow_free); |
1080 | async_cow->work.ordered_free = async_cow_free; | ||
1081 | async_cow->work.flags = 0; | ||
1082 | 1081 | ||
1083 | nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >> | 1082 | nr_pages = (cur_end - start + PAGE_CACHE_SIZE) >> |
1084 | PAGE_CACHE_SHIFT; | 1083 | PAGE_CACHE_SHIFT; |
1085 | atomic_add(nr_pages, &root->fs_info->async_delalloc_pages); | 1084 | atomic_add(nr_pages, &root->fs_info->async_delalloc_pages); |
1086 | 1085 | ||
1087 | btrfs_queue_worker(&root->fs_info->delalloc_workers, | 1086 | btrfs_queue_work(root->fs_info->delalloc_workers, |
1088 | &async_cow->work); | 1087 | &async_cow->work); |
1089 | 1088 | ||
1090 | if (atomic_read(&root->fs_info->async_delalloc_pages) > limit) { | 1089 | if (atomic_read(&root->fs_info->async_delalloc_pages) > limit) { |
1091 | wait_event(root->fs_info->async_submit_wait, | 1090 | wait_event(root->fs_info->async_submit_wait, |
@@ -1843,9 +1842,9 @@ static int btrfs_writepage_start_hook(struct page *page, u64 start, u64 end) | |||
1843 | 1842 | ||
1844 | SetPageChecked(page); | 1843 | SetPageChecked(page); |
1845 | page_cache_get(page); | 1844 | page_cache_get(page); |
1846 | fixup->work.func = btrfs_writepage_fixup_worker; | 1845 | btrfs_init_work(&fixup->work, btrfs_writepage_fixup_worker, NULL, NULL); |
1847 | fixup->page = page; | 1846 | fixup->page = page; |
1848 | btrfs_queue_worker(&root->fs_info->fixup_workers, &fixup->work); | 1847 | btrfs_queue_work(root->fs_info->fixup_workers, &fixup->work); |
1849 | return -EBUSY; | 1848 | return -EBUSY; |
1850 | } | 1849 | } |
1851 | 1850 | ||
@@ -2239,6 +2238,11 @@ static noinline int relink_extent_backref(struct btrfs_path *path, | |||
2239 | return PTR_ERR(root); | 2238 | return PTR_ERR(root); |
2240 | } | 2239 | } |
2241 | 2240 | ||
2241 | if (btrfs_root_readonly(root)) { | ||
2242 | srcu_read_unlock(&fs_info->subvol_srcu, index); | ||
2243 | return 0; | ||
2244 | } | ||
2245 | |||
2242 | /* step 2: get inode */ | 2246 | /* step 2: get inode */ |
2243 | key.objectid = backref->inum; | 2247 | key.objectid = backref->inum; |
2244 | key.type = BTRFS_INODE_ITEM_KEY; | 2248 | key.type = BTRFS_INODE_ITEM_KEY; |
@@ -2759,7 +2763,7 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end, | |||
2759 | struct inode *inode = page->mapping->host; | 2763 | struct inode *inode = page->mapping->host; |
2760 | struct btrfs_root *root = BTRFS_I(inode)->root; | 2764 | struct btrfs_root *root = BTRFS_I(inode)->root; |
2761 | struct btrfs_ordered_extent *ordered_extent = NULL; | 2765 | struct btrfs_ordered_extent *ordered_extent = NULL; |
2762 | struct btrfs_workers *workers; | 2766 | struct btrfs_workqueue *workers; |
2763 | 2767 | ||
2764 | trace_btrfs_writepage_end_io_hook(page, start, end, uptodate); | 2768 | trace_btrfs_writepage_end_io_hook(page, start, end, uptodate); |
2765 | 2769 | ||
@@ -2768,14 +2772,13 @@ static int btrfs_writepage_end_io_hook(struct page *page, u64 start, u64 end, | |||
2768 | end - start + 1, uptodate)) | 2772 | end - start + 1, uptodate)) |
2769 | return 0; | 2773 | return 0; |
2770 | 2774 | ||
2771 | ordered_extent->work.func = finish_ordered_fn; | 2775 | btrfs_init_work(&ordered_extent->work, finish_ordered_fn, NULL, NULL); |
2772 | ordered_extent->work.flags = 0; | ||
2773 | 2776 | ||
2774 | if (btrfs_is_free_space_inode(inode)) | 2777 | if (btrfs_is_free_space_inode(inode)) |
2775 | workers = &root->fs_info->endio_freespace_worker; | 2778 | workers = root->fs_info->endio_freespace_worker; |
2776 | else | 2779 | else |
2777 | workers = &root->fs_info->endio_write_workers; | 2780 | workers = root->fs_info->endio_write_workers; |
2778 | btrfs_queue_worker(workers, &ordered_extent->work); | 2781 | btrfs_queue_work(workers, &ordered_extent->work); |
2779 | 2782 | ||
2780 | return 0; | 2783 | return 0; |
2781 | } | 2784 | } |
@@ -4924,7 +4927,8 @@ void btrfs_invalidate_inodes(struct btrfs_root *root) | |||
4924 | struct inode *inode; | 4927 | struct inode *inode; |
4925 | u64 objectid = 0; | 4928 | u64 objectid = 0; |
4926 | 4929 | ||
4927 | WARN_ON(btrfs_root_refs(&root->root_item) != 0); | 4930 | if (!test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) |
4931 | WARN_ON(btrfs_root_refs(&root->root_item) != 0); | ||
4928 | 4932 | ||
4929 | spin_lock(&root->inode_lock); | 4933 | spin_lock(&root->inode_lock); |
4930 | again: | 4934 | again: |
@@ -5799,6 +5803,7 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry, | |||
5799 | } | 5803 | } |
5800 | out_unlock: | 5804 | out_unlock: |
5801 | btrfs_end_transaction(trans, root); | 5805 | btrfs_end_transaction(trans, root); |
5806 | btrfs_balance_delayed_items(root); | ||
5802 | btrfs_btree_balance_dirty(root); | 5807 | btrfs_btree_balance_dirty(root); |
5803 | if (drop_inode) { | 5808 | if (drop_inode) { |
5804 | inode_dec_link_count(inode); | 5809 | inode_dec_link_count(inode); |
@@ -5872,6 +5877,7 @@ out_unlock: | |||
5872 | inode_dec_link_count(inode); | 5877 | inode_dec_link_count(inode); |
5873 | iput(inode); | 5878 | iput(inode); |
5874 | } | 5879 | } |
5880 | btrfs_balance_delayed_items(root); | ||
5875 | btrfs_btree_balance_dirty(root); | 5881 | btrfs_btree_balance_dirty(root); |
5876 | return err; | 5882 | return err; |
5877 | } | 5883 | } |
@@ -5930,6 +5936,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, | |||
5930 | } | 5936 | } |
5931 | 5937 | ||
5932 | btrfs_end_transaction(trans, root); | 5938 | btrfs_end_transaction(trans, root); |
5939 | btrfs_balance_delayed_items(root); | ||
5933 | fail: | 5940 | fail: |
5934 | if (drop_inode) { | 5941 | if (drop_inode) { |
5935 | inode_dec_link_count(inode); | 5942 | inode_dec_link_count(inode); |
@@ -5996,6 +6003,7 @@ out_fail: | |||
5996 | btrfs_end_transaction(trans, root); | 6003 | btrfs_end_transaction(trans, root); |
5997 | if (drop_on_err) | 6004 | if (drop_on_err) |
5998 | iput(inode); | 6005 | iput(inode); |
6006 | btrfs_balance_delayed_items(root); | ||
5999 | btrfs_btree_balance_dirty(root); | 6007 | btrfs_btree_balance_dirty(root); |
6000 | return err; | 6008 | return err; |
6001 | } | 6009 | } |
@@ -6550,6 +6558,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, | |||
6550 | int ret; | 6558 | int ret; |
6551 | struct extent_buffer *leaf; | 6559 | struct extent_buffer *leaf; |
6552 | struct btrfs_root *root = BTRFS_I(inode)->root; | 6560 | struct btrfs_root *root = BTRFS_I(inode)->root; |
6561 | struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree; | ||
6553 | struct btrfs_file_extent_item *fi; | 6562 | struct btrfs_file_extent_item *fi; |
6554 | struct btrfs_key key; | 6563 | struct btrfs_key key; |
6555 | u64 disk_bytenr; | 6564 | u64 disk_bytenr; |
@@ -6626,6 +6635,20 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, | |||
6626 | 6635 | ||
6627 | if (btrfs_extent_readonly(root, disk_bytenr)) | 6636 | if (btrfs_extent_readonly(root, disk_bytenr)) |
6628 | goto out; | 6637 | goto out; |
6638 | |||
6639 | num_bytes = min(offset + *len, extent_end) - offset; | ||
6640 | if (!nocow && found_type == BTRFS_FILE_EXTENT_PREALLOC) { | ||
6641 | u64 range_end; | ||
6642 | |||
6643 | range_end = round_up(offset + num_bytes, root->sectorsize) - 1; | ||
6644 | ret = test_range_bit(io_tree, offset, range_end, | ||
6645 | EXTENT_DELALLOC, 0, NULL); | ||
6646 | if (ret) { | ||
6647 | ret = -EAGAIN; | ||
6648 | goto out; | ||
6649 | } | ||
6650 | } | ||
6651 | |||
6629 | btrfs_release_path(path); | 6652 | btrfs_release_path(path); |
6630 | 6653 | ||
6631 | /* | 6654 | /* |
@@ -6654,7 +6677,6 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, | |||
6654 | */ | 6677 | */ |
6655 | disk_bytenr += backref_offset; | 6678 | disk_bytenr += backref_offset; |
6656 | disk_bytenr += offset - key.offset; | 6679 | disk_bytenr += offset - key.offset; |
6657 | num_bytes = min(offset + *len, extent_end) - offset; | ||
6658 | if (csum_exist_in_range(root, disk_bytenr, num_bytes)) | 6680 | if (csum_exist_in_range(root, disk_bytenr, num_bytes)) |
6659 | goto out; | 6681 | goto out; |
6660 | /* | 6682 | /* |
@@ -7024,10 +7046,9 @@ again: | |||
7024 | if (!ret) | 7046 | if (!ret) |
7025 | goto out_test; | 7047 | goto out_test; |
7026 | 7048 | ||
7027 | ordered->work.func = finish_ordered_fn; | 7049 | btrfs_init_work(&ordered->work, finish_ordered_fn, NULL, NULL); |
7028 | ordered->work.flags = 0; | 7050 | btrfs_queue_work(root->fs_info->endio_write_workers, |
7029 | btrfs_queue_worker(&root->fs_info->endio_write_workers, | 7051 | &ordered->work); |
7030 | &ordered->work); | ||
7031 | out_test: | 7052 | out_test: |
7032 | /* | 7053 | /* |
7033 | * our bio might span multiple ordered extents. If we haven't | 7054 | * our bio might span multiple ordered extents. If we haven't |
@@ -7404,15 +7425,15 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb, | |||
7404 | smp_mb__after_atomic_inc(); | 7425 | smp_mb__after_atomic_inc(); |
7405 | 7426 | ||
7406 | /* | 7427 | /* |
7407 | * The generic stuff only does filemap_write_and_wait_range, which isn't | 7428 | * The generic stuff only does filemap_write_and_wait_range, which |
7408 | * enough if we've written compressed pages to this area, so we need to | 7429 | * isn't enough if we've written compressed pages to this area, so |
7409 | * call btrfs_wait_ordered_range to make absolutely sure that any | 7430 | * we need to flush the dirty pages again to make absolutely sure |
7410 | * outstanding dirty pages are on disk. | 7431 | * that any outstanding dirty pages are on disk. |
7411 | */ | 7432 | */ |
7412 | count = iov_length(iov, nr_segs); | 7433 | count = iov_length(iov, nr_segs); |
7413 | ret = btrfs_wait_ordered_range(inode, offset, count); | 7434 | if (test_bit(BTRFS_INODE_HAS_ASYNC_EXTENT, |
7414 | if (ret) | 7435 | &BTRFS_I(inode)->runtime_flags)) |
7415 | return ret; | 7436 | filemap_fdatawrite_range(inode->i_mapping, offset, count); |
7416 | 7437 | ||
7417 | if (rw & WRITE) { | 7438 | if (rw & WRITE) { |
7418 | /* | 7439 | /* |
@@ -8404,7 +8425,7 @@ struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode, | |||
8404 | work->inode = inode; | 8425 | work->inode = inode; |
8405 | work->wait = wait; | 8426 | work->wait = wait; |
8406 | work->delay_iput = delay_iput; | 8427 | work->delay_iput = delay_iput; |
8407 | work->work.func = btrfs_run_delalloc_work; | 8428 | btrfs_init_work(&work->work, btrfs_run_delalloc_work, NULL, NULL); |
8408 | 8429 | ||
8409 | return work; | 8430 | return work; |
8410 | } | 8431 | } |
@@ -8419,7 +8440,8 @@ void btrfs_wait_and_free_delalloc_work(struct btrfs_delalloc_work *work) | |||
8419 | * some fairly slow code that needs optimization. This walks the list | 8440 | * some fairly slow code that needs optimization. This walks the list |
8420 | * of all the inodes with pending delalloc and forces them to disk. | 8441 | * of all the inodes with pending delalloc and forces them to disk. |
8421 | */ | 8442 | */ |
8422 | static int __start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | 8443 | static int __start_delalloc_inodes(struct btrfs_root *root, int delay_iput, |
8444 | int nr) | ||
8423 | { | 8445 | { |
8424 | struct btrfs_inode *binode; | 8446 | struct btrfs_inode *binode; |
8425 | struct inode *inode; | 8447 | struct inode *inode; |
@@ -8431,6 +8453,7 @@ static int __start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
8431 | INIT_LIST_HEAD(&works); | 8453 | INIT_LIST_HEAD(&works); |
8432 | INIT_LIST_HEAD(&splice); | 8454 | INIT_LIST_HEAD(&splice); |
8433 | 8455 | ||
8456 | mutex_lock(&root->delalloc_mutex); | ||
8434 | spin_lock(&root->delalloc_lock); | 8457 | spin_lock(&root->delalloc_lock); |
8435 | list_splice_init(&root->delalloc_inodes, &splice); | 8458 | list_splice_init(&root->delalloc_inodes, &splice); |
8436 | while (!list_empty(&splice)) { | 8459 | while (!list_empty(&splice)) { |
@@ -8453,12 +8476,14 @@ static int __start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
8453 | else | 8476 | else |
8454 | iput(inode); | 8477 | iput(inode); |
8455 | ret = -ENOMEM; | 8478 | ret = -ENOMEM; |
8456 | goto out; | 8479 | break; |
8457 | } | 8480 | } |
8458 | list_add_tail(&work->list, &works); | 8481 | list_add_tail(&work->list, &works); |
8459 | btrfs_queue_worker(&root->fs_info->flush_workers, | 8482 | btrfs_queue_work(root->fs_info->flush_workers, |
8460 | &work->work); | 8483 | &work->work); |
8461 | 8484 | ret++; | |
8485 | if (nr != -1 && ret >= nr) | ||
8486 | break; | ||
8462 | cond_resched(); | 8487 | cond_resched(); |
8463 | spin_lock(&root->delalloc_lock); | 8488 | spin_lock(&root->delalloc_lock); |
8464 | } | 8489 | } |
@@ -8468,18 +8493,13 @@ static int __start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
8468 | list_del_init(&work->list); | 8493 | list_del_init(&work->list); |
8469 | btrfs_wait_and_free_delalloc_work(work); | 8494 | btrfs_wait_and_free_delalloc_work(work); |
8470 | } | 8495 | } |
8471 | return 0; | ||
8472 | out: | ||
8473 | list_for_each_entry_safe(work, next, &works, list) { | ||
8474 | list_del_init(&work->list); | ||
8475 | btrfs_wait_and_free_delalloc_work(work); | ||
8476 | } | ||
8477 | 8496 | ||
8478 | if (!list_empty_careful(&splice)) { | 8497 | if (!list_empty_careful(&splice)) { |
8479 | spin_lock(&root->delalloc_lock); | 8498 | spin_lock(&root->delalloc_lock); |
8480 | list_splice_tail(&splice, &root->delalloc_inodes); | 8499 | list_splice_tail(&splice, &root->delalloc_inodes); |
8481 | spin_unlock(&root->delalloc_lock); | 8500 | spin_unlock(&root->delalloc_lock); |
8482 | } | 8501 | } |
8502 | mutex_unlock(&root->delalloc_mutex); | ||
8483 | return ret; | 8503 | return ret; |
8484 | } | 8504 | } |
8485 | 8505 | ||
@@ -8490,7 +8510,9 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
8490 | if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) | 8510 | if (test_bit(BTRFS_FS_STATE_ERROR, &root->fs_info->fs_state)) |
8491 | return -EROFS; | 8511 | return -EROFS; |
8492 | 8512 | ||
8493 | ret = __start_delalloc_inodes(root, delay_iput); | 8513 | ret = __start_delalloc_inodes(root, delay_iput, -1); |
8514 | if (ret > 0) | ||
8515 | ret = 0; | ||
8494 | /* | 8516 | /* |
8495 | * the filemap_flush will queue IO into the worker threads, but | 8517 | * the filemap_flush will queue IO into the worker threads, but |
8496 | * we have to make sure the IO is actually started and that | 8518 | * we have to make sure the IO is actually started and that |
@@ -8507,7 +8529,8 @@ int btrfs_start_delalloc_inodes(struct btrfs_root *root, int delay_iput) | |||
8507 | return ret; | 8529 | return ret; |
8508 | } | 8530 | } |
8509 | 8531 | ||
8510 | int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput) | 8532 | int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput, |
8533 | int nr) | ||
8511 | { | 8534 | { |
8512 | struct btrfs_root *root; | 8535 | struct btrfs_root *root; |
8513 | struct list_head splice; | 8536 | struct list_head splice; |
@@ -8518,9 +8541,10 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput) | |||
8518 | 8541 | ||
8519 | INIT_LIST_HEAD(&splice); | 8542 | INIT_LIST_HEAD(&splice); |
8520 | 8543 | ||
8544 | mutex_lock(&fs_info->delalloc_root_mutex); | ||
8521 | spin_lock(&fs_info->delalloc_root_lock); | 8545 | spin_lock(&fs_info->delalloc_root_lock); |
8522 | list_splice_init(&fs_info->delalloc_roots, &splice); | 8546 | list_splice_init(&fs_info->delalloc_roots, &splice); |
8523 | while (!list_empty(&splice)) { | 8547 | while (!list_empty(&splice) && nr) { |
8524 | root = list_first_entry(&splice, struct btrfs_root, | 8548 | root = list_first_entry(&splice, struct btrfs_root, |
8525 | delalloc_root); | 8549 | delalloc_root); |
8526 | root = btrfs_grab_fs_root(root); | 8550 | root = btrfs_grab_fs_root(root); |
@@ -8529,15 +8553,20 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput) | |||
8529 | &fs_info->delalloc_roots); | 8553 | &fs_info->delalloc_roots); |
8530 | spin_unlock(&fs_info->delalloc_root_lock); | 8554 | spin_unlock(&fs_info->delalloc_root_lock); |
8531 | 8555 | ||
8532 | ret = __start_delalloc_inodes(root, delay_iput); | 8556 | ret = __start_delalloc_inodes(root, delay_iput, nr); |
8533 | btrfs_put_fs_root(root); | 8557 | btrfs_put_fs_root(root); |
8534 | if (ret) | 8558 | if (ret < 0) |
8535 | goto out; | 8559 | goto out; |
8536 | 8560 | ||
8561 | if (nr != -1) { | ||
8562 | nr -= ret; | ||
8563 | WARN_ON(nr < 0); | ||
8564 | } | ||
8537 | spin_lock(&fs_info->delalloc_root_lock); | 8565 | spin_lock(&fs_info->delalloc_root_lock); |
8538 | } | 8566 | } |
8539 | spin_unlock(&fs_info->delalloc_root_lock); | 8567 | spin_unlock(&fs_info->delalloc_root_lock); |
8540 | 8568 | ||
8569 | ret = 0; | ||
8541 | atomic_inc(&fs_info->async_submit_draining); | 8570 | atomic_inc(&fs_info->async_submit_draining); |
8542 | while (atomic_read(&fs_info->nr_async_submits) || | 8571 | while (atomic_read(&fs_info->nr_async_submits) || |
8543 | atomic_read(&fs_info->async_delalloc_pages)) { | 8572 | atomic_read(&fs_info->async_delalloc_pages)) { |
@@ -8546,13 +8575,13 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int delay_iput) | |||
8546 | atomic_read(&fs_info->async_delalloc_pages) == 0)); | 8575 | atomic_read(&fs_info->async_delalloc_pages) == 0)); |
8547 | } | 8576 | } |
8548 | atomic_dec(&fs_info->async_submit_draining); | 8577 | atomic_dec(&fs_info->async_submit_draining); |
8549 | return 0; | ||
8550 | out: | 8578 | out: |
8551 | if (!list_empty_careful(&splice)) { | 8579 | if (!list_empty_careful(&splice)) { |
8552 | spin_lock(&fs_info->delalloc_root_lock); | 8580 | spin_lock(&fs_info->delalloc_root_lock); |
8553 | list_splice_tail(&splice, &fs_info->delalloc_roots); | 8581 | list_splice_tail(&splice, &fs_info->delalloc_roots); |
8554 | spin_unlock(&fs_info->delalloc_root_lock); | 8582 | spin_unlock(&fs_info->delalloc_root_lock); |
8555 | } | 8583 | } |
8584 | mutex_unlock(&fs_info->delalloc_root_mutex); | ||
8556 | return ret; | 8585 | return ret; |
8557 | } | 8586 | } |
8558 | 8587 | ||