diff options
-rw-r--r-- | fs/btrfs/dev-replace.c | 4 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 11 | ||||
-rw-r--r-- | fs/btrfs/ioctl.c | 2 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.c | 26 | ||||
-rw-r--r-- | fs/btrfs/ordered-data.h | 6 | ||||
-rw-r--r-- | fs/btrfs/relocation.c | 4 | ||||
-rw-r--r-- | fs/btrfs/super.c | 2 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 2 |
8 files changed, 38 insertions, 19 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 26bcb487f958..3371f9e546d9 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -403,7 +403,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, | |||
403 | if (ret) | 403 | if (ret) |
404 | btrfs_err(root->fs_info, "kobj add dev failed %d\n", ret); | 404 | btrfs_err(root->fs_info, "kobj add dev failed %d\n", ret); |
405 | 405 | ||
406 | btrfs_wait_ordered_roots(root->fs_info, -1); | 406 | btrfs_wait_ordered_roots(root->fs_info, -1, 0, (u64)-1); |
407 | 407 | ||
408 | /* force writing the updated state information to disk */ | 408 | /* force writing the updated state information to disk */ |
409 | trans = btrfs_start_transaction(root, 0); | 409 | trans = btrfs_start_transaction(root, 0); |
@@ -495,7 +495,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, | |||
495 | mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); | 495 | mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); |
496 | return ret; | 496 | return ret; |
497 | } | 497 | } |
498 | btrfs_wait_ordered_roots(root->fs_info, -1); | 498 | btrfs_wait_ordered_roots(root->fs_info, -1, 0, (u64)-1); |
499 | 499 | ||
500 | trans = btrfs_start_transaction(root, 0); | 500 | trans = btrfs_start_transaction(root, 0); |
501 | if (IS_ERR(trans)) { | 501 | if (IS_ERR(trans)) { |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 84e060eb0de8..251452a2b72c 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -4141,7 +4141,7 @@ commit_trans: | |||
4141 | 4141 | ||
4142 | if (need_commit > 0) { | 4142 | if (need_commit > 0) { |
4143 | btrfs_start_delalloc_roots(fs_info, 0, -1); | 4143 | btrfs_start_delalloc_roots(fs_info, 0, -1); |
4144 | btrfs_wait_ordered_roots(fs_info, -1); | 4144 | btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1); |
4145 | } | 4145 | } |
4146 | 4146 | ||
4147 | trans = btrfs_join_transaction(root); | 4147 | trans = btrfs_join_transaction(root); |
@@ -4583,7 +4583,8 @@ static void btrfs_writeback_inodes_sb_nr(struct btrfs_root *root, | |||
4583 | */ | 4583 | */ |
4584 | btrfs_start_delalloc_roots(root->fs_info, 0, nr_items); | 4584 | btrfs_start_delalloc_roots(root->fs_info, 0, nr_items); |
4585 | if (!current->journal_info) | 4585 | if (!current->journal_info) |
4586 | btrfs_wait_ordered_roots(root->fs_info, nr_items); | 4586 | btrfs_wait_ordered_roots(root->fs_info, nr_items, |
4587 | 0, (u64)-1); | ||
4587 | } | 4588 | } |
4588 | } | 4589 | } |
4589 | 4590 | ||
@@ -4632,7 +4633,8 @@ static void shrink_delalloc(struct btrfs_root *root, u64 to_reclaim, u64 orig, | |||
4632 | if (trans) | 4633 | if (trans) |
4633 | return; | 4634 | return; |
4634 | if (wait_ordered) | 4635 | if (wait_ordered) |
4635 | btrfs_wait_ordered_roots(root->fs_info, items); | 4636 | btrfs_wait_ordered_roots(root->fs_info, items, |
4637 | 0, (u64)-1); | ||
4636 | return; | 4638 | return; |
4637 | } | 4639 | } |
4638 | 4640 | ||
@@ -4671,7 +4673,8 @@ skip_async: | |||
4671 | 4673 | ||
4672 | loops++; | 4674 | loops++; |
4673 | if (wait_ordered && !trans) { | 4675 | if (wait_ordered && !trans) { |
4674 | btrfs_wait_ordered_roots(root->fs_info, items); | 4676 | btrfs_wait_ordered_roots(root->fs_info, items, |
4677 | 0, (u64)-1); | ||
4675 | } else { | 4678 | } else { |
4676 | time_left = schedule_timeout_killable(1); | 4679 | time_left = schedule_timeout_killable(1); |
4677 | if (time_left) | 4680 | if (time_left) |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 5a23806ae418..697cc336bd1c 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
@@ -681,7 +681,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir, | |||
681 | if (ret) | 681 | if (ret) |
682 | goto dec_and_free; | 682 | goto dec_and_free; |
683 | 683 | ||
684 | btrfs_wait_ordered_extents(root, -1); | 684 | btrfs_wait_ordered_extents(root, -1, 0, (u64)-1); |
685 | 685 | ||
686 | btrfs_init_block_rsv(&pending_snapshot->block_rsv, | 686 | btrfs_init_block_rsv(&pending_snapshot->block_rsv, |
687 | BTRFS_BLOCK_RSV_TEMP); | 687 | BTRFS_BLOCK_RSV_TEMP); |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 0de7da5a610d..559170464d7c 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
@@ -661,14 +661,15 @@ static void btrfs_run_ordered_extent_work(struct btrfs_work *work) | |||
661 | * wait for all the ordered extents in a root. This is done when balancing | 661 | * wait for all the ordered extents in a root. This is done when balancing |
662 | * space between drives. | 662 | * space between drives. |
663 | */ | 663 | */ |
664 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr) | 664 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr, |
665 | const u64 range_start, const u64 range_len) | ||
665 | { | 666 | { |
666 | struct list_head splice, works; | 667 | LIST_HEAD(splice); |
668 | LIST_HEAD(skipped); | ||
669 | LIST_HEAD(works); | ||
667 | struct btrfs_ordered_extent *ordered, *next; | 670 | struct btrfs_ordered_extent *ordered, *next; |
668 | int count = 0; | 671 | int count = 0; |
669 | 672 | const u64 range_end = range_start + range_len; | |
670 | INIT_LIST_HEAD(&splice); | ||
671 | INIT_LIST_HEAD(&works); | ||
672 | 673 | ||
673 | mutex_lock(&root->ordered_extent_mutex); | 674 | mutex_lock(&root->ordered_extent_mutex); |
674 | spin_lock(&root->ordered_extent_lock); | 675 | spin_lock(&root->ordered_extent_lock); |
@@ -676,6 +677,14 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr) | |||
676 | while (!list_empty(&splice) && nr) { | 677 | while (!list_empty(&splice) && nr) { |
677 | ordered = list_first_entry(&splice, struct btrfs_ordered_extent, | 678 | ordered = list_first_entry(&splice, struct btrfs_ordered_extent, |
678 | root_extent_list); | 679 | root_extent_list); |
680 | |||
681 | if (range_end <= ordered->start || | ||
682 | ordered->start + ordered->disk_len <= range_start) { | ||
683 | list_move_tail(&ordered->root_extent_list, &skipped); | ||
684 | cond_resched_lock(&root->ordered_extent_lock); | ||
685 | continue; | ||
686 | } | ||
687 | |||
679 | list_move_tail(&ordered->root_extent_list, | 688 | list_move_tail(&ordered->root_extent_list, |
680 | &root->ordered_extents); | 689 | &root->ordered_extents); |
681 | atomic_inc(&ordered->refs); | 690 | atomic_inc(&ordered->refs); |
@@ -694,6 +703,7 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr) | |||
694 | nr--; | 703 | nr--; |
695 | count++; | 704 | count++; |
696 | } | 705 | } |
706 | list_splice_tail(&skipped, &root->ordered_extents); | ||
697 | list_splice_tail(&splice, &root->ordered_extents); | 707 | list_splice_tail(&splice, &root->ordered_extents); |
698 | spin_unlock(&root->ordered_extent_lock); | 708 | spin_unlock(&root->ordered_extent_lock); |
699 | 709 | ||
@@ -708,7 +718,8 @@ int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr) | |||
708 | return count; | 718 | return count; |
709 | } | 719 | } |
710 | 720 | ||
711 | void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr) | 721 | void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr, |
722 | const u64 range_start, const u64 range_len) | ||
712 | { | 723 | { |
713 | struct btrfs_root *root; | 724 | struct btrfs_root *root; |
714 | struct list_head splice; | 725 | struct list_head splice; |
@@ -728,7 +739,8 @@ void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr) | |||
728 | &fs_info->ordered_roots); | 739 | &fs_info->ordered_roots); |
729 | spin_unlock(&fs_info->ordered_root_lock); | 740 | spin_unlock(&fs_info->ordered_root_lock); |
730 | 741 | ||
731 | done = btrfs_wait_ordered_extents(root, nr); | 742 | done = btrfs_wait_ordered_extents(root, nr, |
743 | range_start, range_len); | ||
732 | btrfs_put_fs_root(root); | 744 | btrfs_put_fs_root(root); |
733 | 745 | ||
734 | spin_lock(&fs_info->ordered_root_lock); | 746 | spin_lock(&fs_info->ordered_root_lock); |
diff --git a/fs/btrfs/ordered-data.h b/fs/btrfs/ordered-data.h index 23c96059cef2..8ef12623d65c 100644 --- a/fs/btrfs/ordered-data.h +++ b/fs/btrfs/ordered-data.h | |||
@@ -197,8 +197,10 @@ int btrfs_ordered_update_i_size(struct inode *inode, u64 offset, | |||
197 | struct btrfs_ordered_extent *ordered); | 197 | struct btrfs_ordered_extent *ordered); |
198 | int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, | 198 | int btrfs_find_ordered_sum(struct inode *inode, u64 offset, u64 disk_bytenr, |
199 | u32 *sum, int len); | 199 | u32 *sum, int len); |
200 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr); | 200 | int btrfs_wait_ordered_extents(struct btrfs_root *root, int nr, |
201 | void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr); | 201 | const u64 range_start, const u64 range_len); |
202 | void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr, | ||
203 | const u64 range_start, const u64 range_len); | ||
202 | void btrfs_get_logged_extents(struct inode *inode, | 204 | void btrfs_get_logged_extents(struct inode *inode, |
203 | struct list_head *logged_list, | 205 | struct list_head *logged_list, |
204 | const loff_t start, | 206 | const loff_t start, |
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 08ef890deca6..30f77ed60133 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -4259,7 +4259,9 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) | |||
4259 | err = ret; | 4259 | err = ret; |
4260 | goto out; | 4260 | goto out; |
4261 | } | 4261 | } |
4262 | btrfs_wait_ordered_roots(fs_info, -1); | 4262 | btrfs_wait_ordered_roots(fs_info, -1, |
4263 | rc->block_group->key.objectid, | ||
4264 | rc->block_group->key.offset); | ||
4263 | 4265 | ||
4264 | while (1) { | 4266 | while (1) { |
4265 | mutex_lock(&fs_info->cleaner_mutex); | 4267 | mutex_lock(&fs_info->cleaner_mutex); |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 00b8f37cc306..89d134794d47 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -1160,7 +1160,7 @@ int btrfs_sync_fs(struct super_block *sb, int wait) | |||
1160 | return 0; | 1160 | return 0; |
1161 | } | 1161 | } |
1162 | 1162 | ||
1163 | btrfs_wait_ordered_roots(fs_info, -1); | 1163 | btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1); |
1164 | 1164 | ||
1165 | trans = btrfs_attach_transaction_barrier(root); | 1165 | trans = btrfs_attach_transaction_barrier(root); |
1166 | if (IS_ERR(trans)) { | 1166 | if (IS_ERR(trans)) { |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 43885e51b882..f0bb54a77314 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -1821,7 +1821,7 @@ static inline int btrfs_start_delalloc_flush(struct btrfs_fs_info *fs_info) | |||
1821 | static inline void btrfs_wait_delalloc_flush(struct btrfs_fs_info *fs_info) | 1821 | static inline void btrfs_wait_delalloc_flush(struct btrfs_fs_info *fs_info) |
1822 | { | 1822 | { |
1823 | if (btrfs_test_opt(fs_info->tree_root, FLUSHONCOMMIT)) | 1823 | if (btrfs_test_opt(fs_info->tree_root, FLUSHONCOMMIT)) |
1824 | btrfs_wait_ordered_roots(fs_info, -1); | 1824 | btrfs_wait_ordered_roots(fs_info, -1, 0, (u64)-1); |
1825 | } | 1825 | } |
1826 | 1826 | ||
1827 | static inline void | 1827 | static inline void |