Lines Matching +full:non +full:- +full:overlapping
1 // SPDX-License-Identifier: GPL-2.0
11 #include "btrfs-tests.h"
14 #include "../disk-io.h"
35 ret = filemap_get_folios_contig(inode->i_mapping, &index, in process_page_range()
66 if (state->state & EXTENT_##name) \
67 cur += scnprintf(dest + cur, STATE_FLAG_STR_LEN - cur, \
96 node = rb_first(&tree->state); in dump_extent_io_tree()
103 test_msg(" start=%llu len=%llu flags=%s", state->start, in dump_extent_io_tree()
104 state->end + 1 - state->start, flags_str); in dump_extent_io_tree()
123 int ret = -EINVAL; in test_find_delalloc()
130 return -ENOMEM; in test_find_delalloc()
143 ret = -ENOMEM; in test_find_delalloc()
146 tmp = &BTRFS_I(inode)->io_tree; in test_find_delalloc()
147 BTRFS_I(inode)->root = root; in test_find_delalloc()
161 page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL); in test_find_delalloc()
164 ret = -ENOMEM; in test_find_delalloc()
177 * |--- delalloc ---| in test_find_delalloc()
178 * |--- search ---| in test_find_delalloc()
180 set_extent_bit(tmp, 0, sectorsize - 1, EXTENT_DELALLOC, NULL); in test_find_delalloc()
182 end = start + PAGE_SIZE - 1; in test_find_delalloc()
189 if (start != 0 || end != (sectorsize - 1)) { in test_find_delalloc()
191 sectorsize - 1, start, end); in test_find_delalloc()
201 * |--- delalloc ---| in test_find_delalloc()
202 * |--- search ---| in test_find_delalloc()
205 locked_page = find_lock_page(inode->i_mapping, in test_find_delalloc()
211 set_extent_bit(tmp, sectorsize, max_bytes - 1, EXTENT_DELALLOC, NULL); in test_find_delalloc()
213 end = start + PAGE_SIZE - 1; in test_find_delalloc()
220 if (start != test_start || end != max_bytes - 1) { in test_find_delalloc()
222 test_start, max_bytes - 1, start, end); in test_find_delalloc()
236 * |--- delalloc ---| in test_find_delalloc()
237 * |--- search ---| in test_find_delalloc()
240 locked_page = find_lock_page(inode->i_mapping, test_start >> in test_find_delalloc()
247 end = start + PAGE_SIZE - 1; in test_find_delalloc()
254 if (end != test_start + PAGE_SIZE - 1) { in test_find_delalloc()
261 * [------- delalloc -------| in test_find_delalloc()
262 * [max_bytes]|-- search--| in test_find_delalloc()
264 * We are re-using our test_start from above since it works out well. in test_find_delalloc()
266 set_extent_bit(tmp, max_bytes, total_dirty - 1, EXTENT_DELALLOC, NULL); in test_find_delalloc()
268 end = start + PAGE_SIZE - 1; in test_find_delalloc()
275 if (start != test_start || end != total_dirty - 1) { in test_find_delalloc()
277 test_start, total_dirty - 1, start, end); in test_find_delalloc()
291 page = find_get_page(inode->i_mapping, in test_find_delalloc()
303 end = start + PAGE_SIZE - 1; in test_find_delalloc()
306 * will adjust max_bytes down to PAGE_SIZE and then re-search. If in test_find_delalloc()
316 if (start != test_start && end != test_start + PAGE_SIZE - 1) { in test_find_delalloc()
318 test_start, test_start + PAGE_SIZE - 1, start, end); in test_find_delalloc()
330 clear_extent_bits(tmp, 0, total_dirty - 1, (unsigned)-1); in test_find_delalloc()
334 process_page_range(inode, 0, total_dirty - 1, in test_find_delalloc()
346 for (i = 0; i < eb->len * BITS_PER_BYTE; i++) { in check_eb_bitmap()
361 return -EINVAL; in check_eb_bitmap()
377 return -EINVAL; in check_eb_bitmap()
415 unsigned long byte_len = eb->len; in __test_eb_bitmaps()
460 PAGE_SIZE - sizeof(long) / 2, 0, in __test_eb_bitmaps()
471 PAGE_SIZE - sizeof(long) / 2, 0, in __test_eb_bitmaps()
478 * Generate a wonky pseudo-random bit pattern for the sake of not using in __test_eb_bitmaps()
479 * something repetitive that could miss some hypothetical off-by-n bug. in __test_eb_bitmaps()
518 return -ENOMEM; in test_eb_bitmaps()
524 ret = -ENOMEM; in test_eb_bitmaps()
531 ret = -ENOMEM; in test_eb_bitmaps()
548 ret = -ENOMEM; in test_eb_bitmaps()
564 int ret = -EINVAL; in test_find_first_clear_extent_bit()
572 if (start != 0 || end != -1) { in test_find_first_clear_extent_bit()
579 * Set 1M-4M alloc/discard and 32M-64M thus leaving a hole between in test_find_first_clear_extent_bit()
580 * 4M-32M in test_find_first_clear_extent_bit()
582 set_extent_bit(&tree, SZ_1M, SZ_4M - 1, in test_find_first_clear_extent_bit()
588 if (start != 0 || end != SZ_1M - 1) { in test_find_first_clear_extent_bit()
594 /* Now add 32M-64M so that we have a hole between 4M-32M */ in test_find_first_clear_extent_bit()
595 set_extent_bit(&tree, SZ_32M, SZ_64M - 1, in test_find_first_clear_extent_bit()
599 * Request first hole starting at 12M, we should get 4M-32M in test_find_first_clear_extent_bit()
604 if (start != SZ_4M || end != SZ_32M - 1) { in test_find_first_clear_extent_bit()
612 * available, which happens to be unallocated -> 4M-32M in test_find_first_clear_extent_bit()
617 if (start != SZ_4M || end != SZ_32M - 1) { in test_find_first_clear_extent_bit()
624 * Set 64M-72M with CHUNK_ALLOC flag, then search for CHUNK_TRIMMED flag in test_find_first_clear_extent_bit()
625 * being unset in this range, we should get the entry in range 64M-72M in test_find_first_clear_extent_bit()
627 set_extent_bit(&tree, SZ_64M, SZ_64M + SZ_8M - 1, CHUNK_ALLOCATED, NULL); in test_find_first_clear_extent_bit()
631 if (start != SZ_64M || end != SZ_64M + SZ_8M - 1) { in test_find_first_clear_extent_bit()
637 find_first_clear_extent_bit(&tree, SZ_64M - SZ_8M, &start, &end, in test_find_first_clear_extent_bit()
644 if (start != SZ_64M || end != SZ_64M + SZ_8M - 1) { in test_find_first_clear_extent_bit()
652 * and end should be -1 in test_find_first_clear_extent_bit()
654 find_first_clear_extent_bit(&tree, -1, &start, &end, CHUNK_TRIMMED); in test_find_first_clear_extent_bit()
655 if (start != SZ_64M + SZ_8M || end != -1) { in test_find_first_clear_extent_bit()
666 clear_extent_bits(&tree, 0, (u64)-1, CHUNK_TRIMMED | CHUNK_ALLOCATED); in test_find_first_clear_extent_bit()
674 for (int i = 0; i < eb->len; i++) { in dump_eb_and_memory_contents()
675 struct page *page = folio_page(eb->folios[i >> PAGE_SHIFT], 0); in dump_eb_and_memory_contents()
690 for (int i = 0; i < (eb->len >> PAGE_SHIFT); i++) { in verify_eb_and_memory()
691 void *eb_addr = folio_address(eb->folios[i]); in verify_eb_and_memory()
695 return -EUCLEAN; in verify_eb_and_memory()
707 get_random_bytes(memory, eb->len); in init_eb_and_memory()
708 write_extent_buffer(eb, memory, 0, eb->len); in init_eb_and_memory()
723 return -ENOMEM; in test_eb_mem_ops()
729 ret = -ENOMEM; in test_eb_mem_ops()
736 ret = -ENOMEM; in test_eb_mem_ops()
747 ret = verify_eb_and_memory(eb, memory, "same page non-overlapping memcpy 1"); in test_eb_mem_ops()
753 ret = verify_eb_and_memory(eb, memory, "same page non-overlapping memcpy 2"); in test_eb_mem_ops()
758 ret = verify_eb_and_memory(eb, memory, "same page non-overlapping memcpy 3"); in test_eb_mem_ops()
764 ret = verify_eb_and_memory(eb, memory, "same page overlapping memcpy 1"); in test_eb_mem_ops()
770 ret = verify_eb_and_memory(eb, memory, "same page overlapping memcpy 2"); in test_eb_mem_ops()
775 ret = verify_eb_and_memory(eb, memory, "same page overlapping memcpy 3"); in test_eb_mem_ops()
780 memcpy(memory, memory + 4096 - 128, 256); in test_eb_mem_ops()
781 memcpy_extent_buffer(eb, 0, 4096 - 128, 256); in test_eb_mem_ops()
782 ret = verify_eb_and_memory(eb, memory, "cross page non-overlapping memcpy 1"); in test_eb_mem_ops()
786 memcpy(memory + 4096 - 128, memory + 4096 + 128, 256); in test_eb_mem_ops()
787 memcpy_extent_buffer(eb, 4096 - 128, 4096 + 128, 256); in test_eb_mem_ops()
788 ret = verify_eb_and_memory(eb, memory, "cross page non-overlapping memcpy 2"); in test_eb_mem_ops()
792 memmove(memory + 4096 - 128, memory + 4096 - 64, 256); in test_eb_mem_ops()
793 memmove_extent_buffer(eb, 4096 - 128, 4096 - 64, 256); in test_eb_mem_ops()
794 ret = verify_eb_and_memory(eb, memory, "cross page overlapping memcpy 1"); in test_eb_mem_ops()
798 memmove(memory + 4096 - 64, memory + 4096 - 128, 256); in test_eb_mem_ops()
799 memmove_extent_buffer(eb, 4096 - 64, 4096 - 128, 256); in test_eb_mem_ops()
800 ret = verify_eb_and_memory(eb, memory, "cross page overlapping memcpy 2"); in test_eb_mem_ops()