aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/ordered-data.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index f14b17432117..9489fa96e3ed 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -626,14 +626,10 @@ int btrfs_run_ordered_operations(struct btrfs_root *root, int wait)
626 626
627 mutex_lock(&root->fs_info->ordered_operations_mutex); 627 mutex_lock(&root->fs_info->ordered_operations_mutex);
628 spin_lock(&root->fs_info->ordered_extent_lock); 628 spin_lock(&root->fs_info->ordered_extent_lock);
629again:
630 list_splice_init(&root->fs_info->ordered_operations, &splice); 629 list_splice_init(&root->fs_info->ordered_operations, &splice);
631
632 while (!list_empty(&splice)) { 630 while (!list_empty(&splice)) {
633
634 btrfs_inode = list_entry(splice.next, struct btrfs_inode, 631 btrfs_inode = list_entry(splice.next, struct btrfs_inode,
635 ordered_operations); 632 ordered_operations);
636
637 inode = &btrfs_inode->vfs_inode; 633 inode = &btrfs_inode->vfs_inode;
638 634
639 list_del_init(&btrfs_inode->ordered_operations); 635 list_del_init(&btrfs_inode->ordered_operations);
@@ -642,22 +638,20 @@ again:
642 * the inode may be getting freed (in sys_unlink path). 638 * the inode may be getting freed (in sys_unlink path).
643 */ 639 */
644 inode = igrab(inode); 640 inode = igrab(inode);
645
646 if (!wait && inode) {
647 list_add_tail(&BTRFS_I(inode)->ordered_operations,
648 &root->fs_info->ordered_operations);
649 }
650
651 if (!inode) 641 if (!inode)
652 continue; 642 continue;
643
644 if (!wait)
645 list_add_tail(&BTRFS_I(inode)->ordered_operations,
646 &root->fs_info->ordered_operations);
653 spin_unlock(&root->fs_info->ordered_extent_lock); 647 spin_unlock(&root->fs_info->ordered_extent_lock);
654 648
655 work = btrfs_alloc_delalloc_work(inode, wait, 1); 649 work = btrfs_alloc_delalloc_work(inode, wait, 1);
656 if (!work) { 650 if (!work) {
651 spin_lock(&root->fs_info->ordered_extent_lock);
657 if (list_empty(&BTRFS_I(inode)->ordered_operations)) 652 if (list_empty(&BTRFS_I(inode)->ordered_operations))
658 list_add_tail(&btrfs_inode->ordered_operations, 653 list_add_tail(&btrfs_inode->ordered_operations,
659 &splice); 654 &splice);
660 spin_lock(&root->fs_info->ordered_extent_lock);
661 list_splice_tail(&splice, 655 list_splice_tail(&splice,
662 &root->fs_info->ordered_operations); 656 &root->fs_info->ordered_operations);
663 spin_unlock(&root->fs_info->ordered_extent_lock); 657 spin_unlock(&root->fs_info->ordered_extent_lock);
@@ -671,9 +665,6 @@ again:
671 cond_resched(); 665 cond_resched();
672 spin_lock(&root->fs_info->ordered_extent_lock); 666 spin_lock(&root->fs_info->ordered_extent_lock);
673 } 667 }
674 if (wait && !list_empty(&root->fs_info->ordered_operations))
675 goto again;
676
677 spin_unlock(&root->fs_info->ordered_extent_lock); 668 spin_unlock(&root->fs_info->ordered_extent_lock);
678out: 669out:
679 list_for_each_entry_safe(work, next, &works, list) { 670 list_for_each_entry_safe(work, next, &works, list) {