Lines Matching refs:entry

23 static u64 entry_end(struct btrfs_ordered_extent *entry)  in entry_end()  argument
25 if (entry->file_offset + entry->num_bytes < entry->file_offset) in entry_end()
27 return entry->file_offset + entry->num_bytes; in entry_end()
38 struct btrfs_ordered_extent *entry; in tree_insert() local
42 entry = rb_entry(parent, struct btrfs_ordered_extent, rb_node); in tree_insert()
44 if (file_offset < entry->file_offset) in tree_insert()
46 else if (file_offset >= entry_end(entry)) in tree_insert()
67 struct btrfs_ordered_extent *entry; in __tree_search() local
71 entry = rb_entry(n, struct btrfs_ordered_extent, rb_node); in __tree_search()
73 prev_entry = entry; in __tree_search()
75 if (file_offset < entry->file_offset) in __tree_search()
77 else if (file_offset >= entry_end(entry)) in __tree_search()
111 static int range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset, in range_overlaps() argument
114 if (file_offset + len <= entry->file_offset || in range_overlaps()
115 entry->file_offset + entry->num_bytes <= file_offset) in range_overlaps()
130 struct btrfs_ordered_extent *entry; in tree_search() local
133 entry = rb_entry(tree->last, struct btrfs_ordered_extent, in tree_search()
135 if (in_range(file_offset, entry->file_offset, entry->num_bytes)) in tree_search()
161 struct btrfs_ordered_extent *entry; in __btrfs_add_ordered_extent() local
179 entry = kmem_cache_zalloc(btrfs_ordered_extent_cache, GFP_NOFS); in __btrfs_add_ordered_extent()
180 if (!entry) in __btrfs_add_ordered_extent()
183 entry->file_offset = file_offset; in __btrfs_add_ordered_extent()
184 entry->disk_bytenr = disk_bytenr; in __btrfs_add_ordered_extent()
185 entry->num_bytes = num_bytes; in __btrfs_add_ordered_extent()
186 entry->disk_num_bytes = disk_num_bytes; in __btrfs_add_ordered_extent()
187 entry->bytes_left = num_bytes; in __btrfs_add_ordered_extent()
188 entry->inode = igrab(&inode->vfs_inode); in __btrfs_add_ordered_extent()
189 entry->compress_type = compress_type; in __btrfs_add_ordered_extent()
190 entry->truncated_len = (u64)-1; in __btrfs_add_ordered_extent()
191 entry->qgroup_rsv = ret; in __btrfs_add_ordered_extent()
192 entry->physical = (u64)-1; in __btrfs_add_ordered_extent()
198 set_bit(type, &entry->flags); in __btrfs_add_ordered_extent()
204 set_bit(BTRFS_ORDERED_DIRECT, &entry->flags); in __btrfs_add_ordered_extent()
207 refcount_set(&entry->refs, 1); in __btrfs_add_ordered_extent()
208 init_waitqueue_head(&entry->wait); in __btrfs_add_ordered_extent()
209 INIT_LIST_HEAD(&entry->list); in __btrfs_add_ordered_extent()
210 INIT_LIST_HEAD(&entry->log_list); in __btrfs_add_ordered_extent()
211 INIT_LIST_HEAD(&entry->root_extent_list); in __btrfs_add_ordered_extent()
212 INIT_LIST_HEAD(&entry->work_list); in __btrfs_add_ordered_extent()
213 init_completion(&entry->completion); in __btrfs_add_ordered_extent()
215 trace_btrfs_ordered_extent_add(inode, entry); in __btrfs_add_ordered_extent()
219 &entry->rb_node); in __btrfs_add_ordered_extent()
227 list_add_tail(&entry->root_extent_list, in __btrfs_add_ordered_extent()
290 void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry, in btrfs_add_ordered_sum() argument
295 tree = &BTRFS_I(entry->inode)->ordered_tree; in btrfs_add_ordered_sum()
297 list_add_tail(&sum->list, &entry->list); in btrfs_add_ordered_sum()
325 struct btrfs_ordered_extent *entry = NULL; in btrfs_mark_ordered_io_finished() local
349 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); in btrfs_mark_ordered_io_finished()
350 entry_end = entry->file_offset + entry->num_bytes; in btrfs_mark_ordered_io_finished()
361 entry = rb_entry(node, struct btrfs_ordered_extent, in btrfs_mark_ordered_io_finished()
365 cur = entry->file_offset; in btrfs_mark_ordered_io_finished()
373 if (cur < entry->file_offset) { in btrfs_mark_ordered_io_finished()
374 cur = entry->file_offset; in btrfs_mark_ordered_io_finished()
385 end = min(entry->file_offset + entry->num_bytes, in btrfs_mark_ordered_io_finished()
405 if (unlikely(len > entry->bytes_left)) { in btrfs_mark_ordered_io_finished()
411 entry->file_offset, in btrfs_mark_ordered_io_finished()
412 entry->num_bytes, in btrfs_mark_ordered_io_finished()
413 len, entry->bytes_left); in btrfs_mark_ordered_io_finished()
414 entry->bytes_left = 0; in btrfs_mark_ordered_io_finished()
416 entry->bytes_left -= len; in btrfs_mark_ordered_io_finished()
420 set_bit(BTRFS_ORDERED_IOERR, &entry->flags); in btrfs_mark_ordered_io_finished()
426 if (entry->bytes_left == 0) { in btrfs_mark_ordered_io_finished()
427 set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags); in btrfs_mark_ordered_io_finished()
428 cond_wake_up(&entry->wait); in btrfs_mark_ordered_io_finished()
429 refcount_inc(&entry->refs); in btrfs_mark_ordered_io_finished()
431 btrfs_init_work(&entry->work, finish_func, NULL, NULL); in btrfs_mark_ordered_io_finished()
432 btrfs_queue_work(wq, &entry->work); in btrfs_mark_ordered_io_finished()
463 struct btrfs_ordered_extent *entry = NULL; in btrfs_dec_test_ordered_pending() local
469 entry = *cached; in btrfs_dec_test_ordered_pending()
477 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); in btrfs_dec_test_ordered_pending()
479 if (!in_range(file_offset, entry->file_offset, entry->num_bytes)) in btrfs_dec_test_ordered_pending()
482 if (io_size > entry->bytes_left) in btrfs_dec_test_ordered_pending()
485 entry->bytes_left, io_size); in btrfs_dec_test_ordered_pending()
487 entry->bytes_left -= io_size; in btrfs_dec_test_ordered_pending()
489 if (entry->bytes_left == 0) { in btrfs_dec_test_ordered_pending()
494 finished = !test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags); in btrfs_dec_test_ordered_pending()
496 cond_wake_up_nomb(&entry->wait); in btrfs_dec_test_ordered_pending()
499 if (finished && cached && entry) { in btrfs_dec_test_ordered_pending()
500 *cached = entry; in btrfs_dec_test_ordered_pending()
501 refcount_inc(&entry->refs); in btrfs_dec_test_ordered_pending()
511 void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) in btrfs_put_ordered_extent() argument
516 trace_btrfs_ordered_extent_put(BTRFS_I(entry->inode), entry); in btrfs_put_ordered_extent()
518 if (refcount_dec_and_test(&entry->refs)) { in btrfs_put_ordered_extent()
519 ASSERT(list_empty(&entry->root_extent_list)); in btrfs_put_ordered_extent()
520 ASSERT(list_empty(&entry->log_list)); in btrfs_put_ordered_extent()
521 ASSERT(RB_EMPTY_NODE(&entry->rb_node)); in btrfs_put_ordered_extent()
522 if (entry->inode) in btrfs_put_ordered_extent()
523 btrfs_add_delayed_iput(entry->inode); in btrfs_put_ordered_extent()
524 while (!list_empty(&entry->list)) { in btrfs_put_ordered_extent()
525 cur = entry->list.next; in btrfs_put_ordered_extent()
530 kmem_cache_free(btrfs_ordered_extent_cache, entry); in btrfs_put_ordered_extent()
539 struct btrfs_ordered_extent *entry) in btrfs_remove_ordered_extent() argument
552 btrfs_delalloc_release_metadata(btrfs_inode, entry->num_bytes, in btrfs_remove_ordered_extent()
555 percpu_counter_add_batch(&fs_info->ordered_bytes, -entry->num_bytes, in btrfs_remove_ordered_extent()
560 node = &entry->rb_node; in btrfs_remove_ordered_extent()
565 set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags); in btrfs_remove_ordered_extent()
566 pending = test_and_clear_bit(BTRFS_ORDERED_PENDING, &entry->flags); in btrfs_remove_ordered_extent()
597 list_del_init(&entry->root_extent_list); in btrfs_remove_ordered_extent()
600 trace_btrfs_ordered_extent_remove(btrfs_inode, entry); in btrfs_remove_ordered_extent()
609 wake_up(&entry->wait); in btrfs_remove_ordered_extent()
723 void btrfs_start_ordered_extent(struct btrfs_ordered_extent *entry, int wait) in btrfs_start_ordered_extent() argument
725 u64 start = entry->file_offset; in btrfs_start_ordered_extent()
726 u64 end = start + entry->num_bytes - 1; in btrfs_start_ordered_extent()
727 struct btrfs_inode *inode = BTRFS_I(entry->inode); in btrfs_start_ordered_extent()
729 trace_btrfs_ordered_extent_start(inode, entry); in btrfs_start_ordered_extent()
736 if (!test_bit(BTRFS_ORDERED_DIRECT, &entry->flags)) in btrfs_start_ordered_extent()
739 wait_event(entry->wait, test_bit(BTRFS_ORDERED_COMPLETE, in btrfs_start_ordered_extent()
740 &entry->flags)); in btrfs_start_ordered_extent()
818 struct btrfs_ordered_extent *entry = NULL; in btrfs_lookup_ordered_extent() local
827 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); in btrfs_lookup_ordered_extent()
828 if (!in_range(file_offset, entry->file_offset, entry->num_bytes)) in btrfs_lookup_ordered_extent()
829 entry = NULL; in btrfs_lookup_ordered_extent()
830 if (entry) in btrfs_lookup_ordered_extent()
831 refcount_inc(&entry->refs); in btrfs_lookup_ordered_extent()
834 return entry; in btrfs_lookup_ordered_extent()
845 struct btrfs_ordered_extent *entry = NULL; in btrfs_lookup_ordered_range() local
857 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); in btrfs_lookup_ordered_range()
858 if (range_overlaps(entry, file_offset, len)) in btrfs_lookup_ordered_range()
861 if (entry->file_offset >= file_offset + len) { in btrfs_lookup_ordered_range()
862 entry = NULL; in btrfs_lookup_ordered_range()
865 entry = NULL; in btrfs_lookup_ordered_range()
871 if (entry) in btrfs_lookup_ordered_range()
872 refcount_inc(&entry->refs); in btrfs_lookup_ordered_range()
874 return entry; in btrfs_lookup_ordered_range()
914 struct btrfs_ordered_extent *entry = NULL; in btrfs_lookup_first_ordered_extent() local
922 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); in btrfs_lookup_first_ordered_extent()
923 refcount_inc(&entry->refs); in btrfs_lookup_first_ordered_extent()
926 return entry; in btrfs_lookup_first_ordered_extent()
946 struct btrfs_ordered_extent *entry = NULL; in btrfs_lookup_first_ordered_range() local
957 entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); in btrfs_lookup_first_ordered_range()
959 if (file_offset < entry->file_offset) { in btrfs_lookup_first_ordered_range()
961 } else if (file_offset >= entry_end(entry)) { in btrfs_lookup_first_ordered_range()
971 if (!entry) { in btrfs_lookup_first_ordered_range()
976 cur = &entry->rb_node; in btrfs_lookup_first_ordered_range()
978 if (entry->file_offset < file_offset) { in btrfs_lookup_first_ordered_range()
986 entry = rb_entry(prev, struct btrfs_ordered_extent, rb_node); in btrfs_lookup_first_ordered_range()
987 if (range_overlaps(entry, file_offset, len)) in btrfs_lookup_first_ordered_range()
991 entry = rb_entry(next, struct btrfs_ordered_extent, rb_node); in btrfs_lookup_first_ordered_range()
992 if (range_overlaps(entry, file_offset, len)) in btrfs_lookup_first_ordered_range()
996 entry = NULL; in btrfs_lookup_first_ordered_range()
998 if (entry) in btrfs_lookup_first_ordered_range()
999 refcount_inc(&entry->refs); in btrfs_lookup_first_ordered_range()
1001 return entry; in btrfs_lookup_first_ordered_range()