diff options
Diffstat (limited to 'fs/btrfs/ordered-data.c')
-rw-r--r-- | fs/btrfs/ordered-data.c | 123 |
1 files changed, 0 insertions, 123 deletions
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index 7187b14faa6c..963895c1f801 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
@@ -571,18 +571,6 @@ void btrfs_remove_ordered_extent(struct inode *inode, | |||
571 | 571 | ||
572 | trace_btrfs_ordered_extent_remove(inode, entry); | 572 | trace_btrfs_ordered_extent_remove(inode, entry); |
573 | 573 | ||
574 | /* | ||
575 | * we have no more ordered extents for this inode and | ||
576 | * no dirty pages. We can safely remove it from the | ||
577 | * list of ordered extents | ||
578 | */ | ||
579 | if (RB_EMPTY_ROOT(&tree->tree) && | ||
580 | !mapping_tagged(inode->i_mapping, PAGECACHE_TAG_DIRTY)) { | ||
581 | spin_lock(&root->fs_info->ordered_root_lock); | ||
582 | list_del_init(&BTRFS_I(inode)->ordered_operations); | ||
583 | spin_unlock(&root->fs_info->ordered_root_lock); | ||
584 | } | ||
585 | |||
586 | if (!root->nr_ordered_extents) { | 574 | if (!root->nr_ordered_extents) { |
587 | spin_lock(&root->fs_info->ordered_root_lock); | 575 | spin_lock(&root->fs_info->ordered_root_lock); |
588 | BUG_ON(list_empty(&root->ordered_root)); | 576 | BUG_ON(list_empty(&root->ordered_root)); |
@@ -687,81 +675,6 @@ void btrfs_wait_ordered_roots(struct btrfs_fs_info *fs_info, int nr) | |||
687 | } | 675 | } |
688 | 676 | ||
689 | /* | 677 | /* |
690 | * this is used during transaction commit to write all the inodes | ||
691 | * added to the ordered operation list. These files must be fully on | ||
692 | * disk before the transaction commits. | ||
693 | * | ||
694 | * we have two modes here, one is to just start the IO via filemap_flush | ||
695 | * and the other is to wait for all the io. When we wait, we have an | ||
696 | * extra check to make sure the ordered operation list really is empty | ||
697 | * before we return | ||
698 | */ | ||
699 | int btrfs_run_ordered_operations(struct btrfs_trans_handle *trans, | ||
700 | struct btrfs_root *root, int wait) | ||
701 | { | ||
702 | struct btrfs_inode *btrfs_inode; | ||
703 | struct inode *inode; | ||
704 | struct btrfs_transaction *cur_trans = trans->transaction; | ||
705 | struct list_head splice; | ||
706 | struct list_head works; | ||
707 | struct btrfs_delalloc_work *work, *next; | ||
708 | int ret = 0; | ||
709 | |||
710 | INIT_LIST_HEAD(&splice); | ||
711 | INIT_LIST_HEAD(&works); | ||
712 | |||
713 | mutex_lock(&root->fs_info->ordered_extent_flush_mutex); | ||
714 | spin_lock(&root->fs_info->ordered_root_lock); | ||
715 | list_splice_init(&cur_trans->ordered_operations, &splice); | ||
716 | while (!list_empty(&splice)) { | ||
717 | btrfs_inode = list_entry(splice.next, struct btrfs_inode, | ||
718 | ordered_operations); | ||
719 | inode = &btrfs_inode->vfs_inode; | ||
720 | |||
721 | list_del_init(&btrfs_inode->ordered_operations); | ||
722 | |||
723 | /* | ||
724 | * the inode may be getting freed (in sys_unlink path). | ||
725 | */ | ||
726 | inode = igrab(inode); | ||
727 | if (!inode) | ||
728 | continue; | ||
729 | |||
730 | if (!wait) | ||
731 | list_add_tail(&BTRFS_I(inode)->ordered_operations, | ||
732 | &cur_trans->ordered_operations); | ||
733 | spin_unlock(&root->fs_info->ordered_root_lock); | ||
734 | |||
735 | work = btrfs_alloc_delalloc_work(inode, wait, 1); | ||
736 | if (!work) { | ||
737 | spin_lock(&root->fs_info->ordered_root_lock); | ||
738 | if (list_empty(&BTRFS_I(inode)->ordered_operations)) | ||
739 | list_add_tail(&btrfs_inode->ordered_operations, | ||
740 | &splice); | ||
741 | list_splice_tail(&splice, | ||
742 | &cur_trans->ordered_operations); | ||
743 | spin_unlock(&root->fs_info->ordered_root_lock); | ||
744 | ret = -ENOMEM; | ||
745 | goto out; | ||
746 | } | ||
747 | list_add_tail(&work->list, &works); | ||
748 | btrfs_queue_work(root->fs_info->flush_workers, | ||
749 | &work->work); | ||
750 | |||
751 | cond_resched(); | ||
752 | spin_lock(&root->fs_info->ordered_root_lock); | ||
753 | } | ||
754 | spin_unlock(&root->fs_info->ordered_root_lock); | ||
755 | out: | ||
756 | list_for_each_entry_safe(work, next, &works, list) { | ||
757 | list_del_init(&work->list); | ||
758 | btrfs_wait_and_free_delalloc_work(work); | ||
759 | } | ||
760 | mutex_unlock(&root->fs_info->ordered_extent_flush_mutex); | ||
761 | return ret; | ||
762 | } | ||
763 | |||
764 | /* | ||
765 | * Used to start IO or wait for a given ordered extent to finish. | 678 | * Used to start IO or wait for a given ordered extent to finish. |
766 | * | 679 | * |
767 | * If wait is one, this effectively waits on page writeback for all the pages | 680 | * If wait is one, this effectively waits on page writeback for all the pages |
@@ -1120,42 +1033,6 @@ out: | |||
1120 | return index; | 1033 | return index; |
1121 | } | 1034 | } |
1122 | 1035 | ||
1123 | |||
1124 | /* | ||
1125 | * add a given inode to the list of inodes that must be fully on | ||
1126 | * disk before a transaction commit finishes. | ||
1127 | * | ||
1128 | * This basically gives us the ext3 style data=ordered mode, and it is mostly | ||
1129 | * used to make sure renamed files are fully on disk. | ||
1130 | * | ||
1131 | * It is a noop if the inode is already fully on disk. | ||
1132 | * | ||
1133 | * If trans is not null, we'll do a friendly check for a transaction that | ||
1134 | * is already flushing things and force the IO down ourselves. | ||
1135 | */ | ||
1136 | void btrfs_add_ordered_operation(struct btrfs_trans_handle *trans, | ||
1137 | struct btrfs_root *root, struct inode *inode) | ||
1138 | { | ||
1139 | struct btrfs_transaction *cur_trans = trans->transaction; | ||
1140 | u64 last_mod; | ||
1141 | |||
1142 | last_mod = max(BTRFS_I(inode)->generation, BTRFS_I(inode)->last_trans); | ||
1143 | |||
1144 | /* | ||
1145 | * if this file hasn't been changed since the last transaction | ||
1146 | * commit, we can safely return without doing anything | ||
1147 | */ | ||
1148 | if (last_mod <= root->fs_info->last_trans_committed) | ||
1149 | return; | ||
1150 | |||
1151 | spin_lock(&root->fs_info->ordered_root_lock); | ||
1152 | if (list_empty(&BTRFS_I(inode)->ordered_operations)) { | ||
1153 | list_add_tail(&BTRFS_I(inode)->ordered_operations, | ||
1154 | &cur_trans->ordered_operations); | ||
1155 | } | ||
1156 | spin_unlock(&root->fs_info->ordered_root_lock); | ||
1157 | } | ||
1158 | |||
1159 | int __init ordered_data_init(void) | 1036 | int __init ordered_data_init(void) |
1160 | { | 1037 | { |
1161 | btrfs_ordered_extent_cache = kmem_cache_create("btrfs_ordered_extent", | 1038 | btrfs_ordered_extent_cache = kmem_cache_create("btrfs_ordered_extent", |