Lines Matching full:ordered
121 * look find the first ordered struct that has this offset, otherwise
147 * Add an ordered extent to the per-inode tree.
160 * tree is given a single reference on the ordered extent that was inserted.
185 * The ordered extent has reserved qgroup space, release now in btrfs_add_ordered_extent()
231 "inconsistency in ordered tree at offset %llu", in btrfs_add_ordered_extent()
261 * when an ordered extent is finished. If the list covers more than one
262 * ordered extent, it is split across multiples.
284 * Mark all ordered extents io inside the specified range finished.
288 * updated to indicate whether the pending ordered io is finished.
293 * This function is called for endio, thus the range must have ordered
324 /* No ordered extents at all */ in btrfs_mark_ordered_io_finished()
337 /* No more ordered extents, exit */ in btrfs_mark_ordered_io_finished()
343 /* Go to next ordered extent and continue */ in btrfs_mark_ordered_io_finished()
358 * Now we are definitely inside one ordered extent. in btrfs_mark_ordered_io_finished()
371 * Ordered (Private2) bit indicates whether we still in btrfs_mark_ordered_io_finished()
372 * have pending io unfinished for the ordered extent. in btrfs_mark_ordered_io_finished()
387 "bad ordered extent accounting, root=%llu ino=%llu OE offset=%llu OE len=%llu to_dec=%u left=%llu", in btrfs_mark_ordered_io_finished()
402 * All the IO of the ordered extent is finished, we need to queue in btrfs_mark_ordered_io_finished()
421 * Finish IO for one ordered extent across a given range. The range can only
422 * contain one ordered extent.
424 * @cached: The cached ordered extent. If not NULL, we can skip the tree
425 * search and use the ordered extent directly.
426 * Will be also used to store the finished ordered extent.
430 * Return true if the ordered extent is finished in the range, and update
434 * NOTE: The range can NOT cross multiple ordered extents.
435 * Thus caller should ensure the range doesn't cross ordered extents.
464 "bad ordered accounting left %llu size %llu", in btrfs_dec_test_ordered_pending()
489 * used to drop a reference on an ordered extent. This will free
516 * remove an ordered extent from the tree. No references are dropped
530 * If this is a free space inode the thread has not acquired the ordered in btrfs_remove_ordered_extent()
613 struct btrfs_ordered_extent *ordered; in btrfs_run_ordered_extent_work() local
615 ordered = container_of(work, struct btrfs_ordered_extent, flush_work); in btrfs_run_ordered_extent_work()
616 btrfs_start_ordered_extent(ordered, 1); in btrfs_run_ordered_extent_work()
617 complete(&ordered->completion); in btrfs_run_ordered_extent_work()
621 * wait for all the ordered extents in a root. This is done when balancing
631 struct btrfs_ordered_extent *ordered, *next; in btrfs_wait_ordered_extents() local
639 ordered = list_first_entry(&splice, struct btrfs_ordered_extent, in btrfs_wait_ordered_extents()
642 if (range_end <= ordered->disk_bytenr || in btrfs_wait_ordered_extents()
643 ordered->disk_bytenr + ordered->disk_num_bytes <= range_start) { in btrfs_wait_ordered_extents()
644 list_move_tail(&ordered->root_extent_list, &skipped); in btrfs_wait_ordered_extents()
649 list_move_tail(&ordered->root_extent_list, in btrfs_wait_ordered_extents()
651 refcount_inc(&ordered->refs); in btrfs_wait_ordered_extents()
654 btrfs_init_work(&ordered->flush_work, in btrfs_wait_ordered_extents()
656 list_add_tail(&ordered->work_list, &works); in btrfs_wait_ordered_extents()
657 btrfs_queue_work(fs_info->flush_workers, &ordered->flush_work); in btrfs_wait_ordered_extents()
669 list_for_each_entry_safe(ordered, next, &works, work_list) { in btrfs_wait_ordered_extents()
670 list_del_init(&ordered->work_list); in btrfs_wait_ordered_extents()
671 wait_for_completion(&ordered->completion); in btrfs_wait_ordered_extents()
672 btrfs_put_ordered_extent(ordered); in btrfs_wait_ordered_extents()
716 * Used to start IO or wait for a given ordered extent to finish.
732 * If this is a free space inode do not take the ordered extents lockdep in btrfs_start_ordered_extent()
753 * Used to wait on ordered extents across a large range of bytes.
761 struct btrfs_ordered_extent *ordered; in btrfs_wait_ordered_range() local
780 * for any ordered extents that haven't completed yet. This is to make in btrfs_wait_ordered_range()
782 * before the ordered extents complete - to avoid failures (-EEXIST) in btrfs_wait_ordered_range()
783 * when adding the new ordered extents to the ordered tree. in btrfs_wait_ordered_range()
789 ordered = btrfs_lookup_first_ordered_extent(BTRFS_I(inode), end); in btrfs_wait_ordered_range()
790 if (!ordered) in btrfs_wait_ordered_range()
792 if (ordered->file_offset > orig_end) { in btrfs_wait_ordered_range()
793 btrfs_put_ordered_extent(ordered); in btrfs_wait_ordered_range()
796 if (ordered->file_offset + ordered->num_bytes <= start) { in btrfs_wait_ordered_range()
797 btrfs_put_ordered_extent(ordered); in btrfs_wait_ordered_range()
800 btrfs_start_ordered_extent(ordered, 1); in btrfs_wait_ordered_range()
801 end = ordered->file_offset; in btrfs_wait_ordered_range()
803 * If the ordered extent had an error save the error but don't in btrfs_wait_ordered_range()
804 * exit without waiting first for all other ordered extents in in btrfs_wait_ordered_range()
807 if (test_bit(BTRFS_ORDERED_IOERR, &ordered->flags)) in btrfs_wait_ordered_range()
809 btrfs_put_ordered_extent(ordered); in btrfs_wait_ordered_range()
818 * find an ordered extent corresponding to file_offset. return NULL if
847 /* Since the DIO code tries to lock a wide area we need to look for any ordered
890 * Adds all ordered extents to the given list. The list ends up sorted by the
891 * file_offset of the ordered extents.
903 struct btrfs_ordered_extent *ordered; in btrfs_get_ordered_extents_for_logging() local
905 ordered = rb_entry(n, struct btrfs_ordered_extent, rb_node); in btrfs_get_ordered_extents_for_logging()
907 if (test_bit(BTRFS_ORDERED_LOGGED, &ordered->flags)) in btrfs_get_ordered_extents_for_logging()
910 ASSERT(list_empty(&ordered->log_list)); in btrfs_get_ordered_extents_for_logging()
911 list_add_tail(&ordered->log_list, list); in btrfs_get_ordered_extents_for_logging()
912 refcount_inc(&ordered->refs); in btrfs_get_ordered_extents_for_logging()
913 trace_btrfs_ordered_extent_lookup_for_logging(inode, ordered); in btrfs_get_ordered_extents_for_logging()
944 * Lookup the first ordered extent that overlaps the range
948 * that this one won't return any ordered extent that does not overlap the range.
950 * ensures the first ordered extent gets returned.
967 * And __tree_search() can't return the adjacent ordered extents in btrfs_lookup_first_ordered_range()
979 * Direct hit, got an ordered extent that starts at in btrfs_lookup_first_ordered_range()
1009 /* No ordered extent in the range */ in btrfs_lookup_first_ordered_range()
1023 * ordered extents in it are run to completion.
1025 * @inode: Inode whose ordered tree is to be searched
1038 struct btrfs_ordered_extent *ordered; in btrfs_lock_and_flush_ordered_range() local
1047 ordered = btrfs_lookup_ordered_range(inode, start, in btrfs_lock_and_flush_ordered_range()
1049 if (!ordered) { in btrfs_lock_and_flush_ordered_range()
1060 btrfs_start_ordered_extent(ordered, 1); in btrfs_lock_and_flush_ordered_range()
1061 btrfs_put_ordered_extent(ordered); in btrfs_lock_and_flush_ordered_range()
1066 * Lock the passed range and ensure all pending ordered extents in it are run
1074 struct btrfs_ordered_extent *ordered; in btrfs_try_lock_ordered_range() local
1079 ordered = btrfs_lookup_ordered_range(inode, start, end - start + 1); in btrfs_try_lock_ordered_range()
1080 if (!ordered) in btrfs_try_lock_ordered_range()
1083 btrfs_put_ordered_extent(ordered); in btrfs_try_lock_ordered_range()
1090 static int clone_ordered_extent(struct btrfs_ordered_extent *ordered, u64 pos, in clone_ordered_extent() argument
1093 struct inode *inode = ordered->inode; in clone_ordered_extent()
1095 u64 file_offset = ordered->file_offset + pos; in clone_ordered_extent()
1096 u64 disk_bytenr = ordered->disk_bytenr + pos; in clone_ordered_extent()
1097 unsigned long flags = ordered->flags & BTRFS_ORDERED_TYPE_FLAGS; in clone_ordered_extent()
1108 ordered->compress_type); in clone_ordered_extent()
1111 int btrfs_split_ordered_extent(struct btrfs_ordered_extent *ordered, u64 pre, in btrfs_split_ordered_extent() argument
1114 struct inode *inode = ordered->inode; in btrfs_split_ordered_extent()
1120 trace_btrfs_ordered_extent_split(BTRFS_I(inode), ordered); in btrfs_split_ordered_extent()
1124 node = &ordered->rb_node; in btrfs_split_ordered_extent()
1130 ordered->file_offset += pre; in btrfs_split_ordered_extent()
1131 ordered->disk_bytenr += pre; in btrfs_split_ordered_extent()
1132 ordered->num_bytes -= (pre + post); in btrfs_split_ordered_extent()
1133 ordered->disk_num_bytes -= (pre + post); in btrfs_split_ordered_extent()
1134 ordered->bytes_left -= (pre + post); in btrfs_split_ordered_extent()
1137 node = tree_insert(&tree->tree, ordered->file_offset, &ordered->rb_node); in btrfs_split_ordered_extent()
1140 "zoned: inconsistency in ordered tree at offset %llu", in btrfs_split_ordered_extent()
1141 ordered->file_offset); in btrfs_split_ordered_extent()
1146 ret = clone_ordered_extent(ordered, 0, pre); in btrfs_split_ordered_extent()
1148 ret = clone_ordered_extent(ordered, pre + ordered->disk_num_bytes, in btrfs_split_ordered_extent()