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()
122 int ret = -EINVAL; in test_find_delalloc()
129 return -ENOMEM; in test_find_delalloc()
142 ret = -ENOMEM; in test_find_delalloc()
145 tmp = &BTRFS_I(inode)->io_tree; in test_find_delalloc()
146 BTRFS_I(inode)->root = root; in test_find_delalloc()
160 page = find_or_create_page(inode->i_mapping, index, GFP_KERNEL); in test_find_delalloc()
163 ret = -ENOMEM; in test_find_delalloc()
176 * |--- delalloc ---| in test_find_delalloc()
177 * |--- search ---| in test_find_delalloc()
179 btrfs_set_extent_bit(tmp, 0, sectorsize - 1, EXTENT_DELALLOC, NULL); in test_find_delalloc()
181 end = start + PAGE_SIZE - 1; in test_find_delalloc()
188 if (start != 0 || end != (sectorsize - 1)) { in test_find_delalloc()
190 sectorsize - 1, start, end); in test_find_delalloc()
200 * |--- delalloc ---| in test_find_delalloc()
201 * |--- search ---| in test_find_delalloc()
204 locked_page = find_lock_page(inode->i_mapping, in test_find_delalloc()
210 btrfs_set_extent_bit(tmp, sectorsize, max_bytes - 1, EXTENT_DELALLOC, NULL); in test_find_delalloc()
212 end = start + PAGE_SIZE - 1; in test_find_delalloc()
219 if (start != test_start || end != max_bytes - 1) { in test_find_delalloc()
221 test_start, max_bytes - 1, start, end); in test_find_delalloc()
235 * |--- delalloc ---| in test_find_delalloc()
236 * |--- search ---| in test_find_delalloc()
239 locked_page = find_lock_page(inode->i_mapping, test_start >> in test_find_delalloc()
246 end = start + PAGE_SIZE - 1; in test_find_delalloc()
253 if (end != test_start + PAGE_SIZE - 1) { in test_find_delalloc()
260 * [------- delalloc -------| in test_find_delalloc()
261 * [max_bytes]|-- search--| in test_find_delalloc()
263 * We are re-using our test_start from above since it works out well. in test_find_delalloc()
265 btrfs_set_extent_bit(tmp, max_bytes, total_dirty - 1, EXTENT_DELALLOC, NULL); in test_find_delalloc()
267 end = start + PAGE_SIZE - 1; in test_find_delalloc()
274 if (start != test_start || end != total_dirty - 1) { in test_find_delalloc()
276 test_start, total_dirty - 1, start, end); in test_find_delalloc()
290 page = find_get_page(inode->i_mapping, in test_find_delalloc()
302 end = start + PAGE_SIZE - 1; in test_find_delalloc()
305 * will adjust max_bytes down to PAGE_SIZE and then re-search. If in test_find_delalloc()
315 if (start != test_start && end != test_start + PAGE_SIZE - 1) { in test_find_delalloc()
317 test_start, test_start + PAGE_SIZE - 1, start, end); in test_find_delalloc()
329 btrfs_clear_extent_bit(tmp, 0, total_dirty - 1, (unsigned)-1, NULL); in test_find_delalloc()
333 process_page_range(inode, 0, total_dirty - 1, in test_find_delalloc()
345 for (i = 0; i < eb->len * BITS_PER_BYTE; i++) { in check_eb_bitmap()
360 return -EINVAL; in check_eb_bitmap()
376 return -EINVAL; in check_eb_bitmap()
414 unsigned long byte_len = eb->len; in __test_eb_bitmaps()
459 PAGE_SIZE - sizeof(long) / 2, 0, in __test_eb_bitmaps()
470 PAGE_SIZE - sizeof(long) / 2, 0, in __test_eb_bitmaps()
477 * Generate a wonky pseudo-random bit pattern for the sake of not using in __test_eb_bitmaps()
478 * something repetitive that could miss some hypothetical off-by-n bug. in __test_eb_bitmaps()
517 return -ENOMEM; in test_eb_bitmaps()
523 ret = -ENOMEM; in test_eb_bitmaps()
530 ret = -ENOMEM; in test_eb_bitmaps()
547 ret = -ENOMEM; in test_eb_bitmaps()
563 int ret = -EINVAL; in test_find_first_clear_extent_bit()
571 if (start != 0 || end != -1) { in test_find_first_clear_extent_bit()
578 * Set 1M-4M alloc/discard and 32M-64M thus leaving a hole between in test_find_first_clear_extent_bit()
579 * 4M-32M in test_find_first_clear_extent_bit()
581 btrfs_set_extent_bit(&tree, SZ_1M, SZ_4M - 1, in test_find_first_clear_extent_bit()
587 if (start != 0 || end != SZ_1M - 1) { in test_find_first_clear_extent_bit()
593 /* Now add 32M-64M so that we have a hole between 4M-32M */ in test_find_first_clear_extent_bit()
594 btrfs_set_extent_bit(&tree, SZ_32M, SZ_64M - 1, in test_find_first_clear_extent_bit()
598 * Request first hole starting at 12M, we should get 4M-32M in test_find_first_clear_extent_bit()
603 if (start != SZ_4M || end != SZ_32M - 1) { in test_find_first_clear_extent_bit()
611 * available, which happens to be unallocated -> 4M-32M in test_find_first_clear_extent_bit()
616 if (start != SZ_4M || end != SZ_32M - 1) { in test_find_first_clear_extent_bit()
623 * Set 64M-72M with CHUNK_ALLOC flag, then search for CHUNK_TRIMMED flag in test_find_first_clear_extent_bit()
624 * being unset in this range, we should get the entry in range 64M-72M in test_find_first_clear_extent_bit()
626 btrfs_set_extent_bit(&tree, SZ_64M, SZ_64M + SZ_8M - 1, CHUNK_ALLOCATED, NULL); in test_find_first_clear_extent_bit()
630 if (start != SZ_64M || end != SZ_64M + SZ_8M - 1) { in test_find_first_clear_extent_bit()
636 btrfs_find_first_clear_extent_bit(&tree, SZ_64M - SZ_8M, &start, &end, in test_find_first_clear_extent_bit()
643 if (start != SZ_64M || end != SZ_64M + SZ_8M - 1) { in test_find_first_clear_extent_bit()
651 * and end should be -1 in test_find_first_clear_extent_bit()
653 btrfs_find_first_clear_extent_bit(&tree, -1, &start, &end, CHUNK_TRIMMED); in test_find_first_clear_extent_bit()
654 if (start != SZ_64M + SZ_8M || end != -1) { in test_find_first_clear_extent_bit()
665 btrfs_clear_extent_bit(&tree, 0, (u64)-1, CHUNK_TRIMMED | CHUNK_ALLOCATED, NULL); in test_find_first_clear_extent_bit()
673 for (int i = 0; i < eb->len; i++) { in dump_eb_and_memory_contents()
674 struct page *page = folio_page(eb->folios[i >> PAGE_SHIFT], 0); in dump_eb_and_memory_contents()
689 for (int i = 0; i < (eb->len >> PAGE_SHIFT); i++) { in verify_eb_and_memory()
690 void *eb_addr = folio_address(eb->folios[i]); in verify_eb_and_memory()
694 return -EUCLEAN; in verify_eb_and_memory()
706 get_random_bytes(memory, eb->len); in init_eb_and_memory()
707 write_extent_buffer(eb, memory, 0, eb->len); in init_eb_and_memory()
722 return -ENOMEM; in test_eb_mem_ops()
728 ret = -ENOMEM; in test_eb_mem_ops()
735 ret = -ENOMEM; in test_eb_mem_ops()
746 ret = verify_eb_and_memory(eb, memory, "same page non-overlapping memcpy 1"); in test_eb_mem_ops()
752 ret = verify_eb_and_memory(eb, memory, "same page non-overlapping memcpy 2"); in test_eb_mem_ops()
757 ret = verify_eb_and_memory(eb, memory, "same page non-overlapping memcpy 3"); in test_eb_mem_ops()
763 ret = verify_eb_and_memory(eb, memory, "same page overlapping memcpy 1"); in test_eb_mem_ops()
769 ret = verify_eb_and_memory(eb, memory, "same page overlapping memcpy 2"); in test_eb_mem_ops()
774 ret = verify_eb_and_memory(eb, memory, "same page overlapping memcpy 3"); in test_eb_mem_ops()
779 memcpy(memory, memory + 4096 - 128, 256); in test_eb_mem_ops()
780 memcpy_extent_buffer(eb, 0, 4096 - 128, 256); in test_eb_mem_ops()
781 ret = verify_eb_and_memory(eb, memory, "cross page non-overlapping memcpy 1"); in test_eb_mem_ops()
785 memcpy(memory + 4096 - 128, memory + 4096 + 128, 256); in test_eb_mem_ops()
786 memcpy_extent_buffer(eb, 4096 - 128, 4096 + 128, 256); in test_eb_mem_ops()
787 ret = verify_eb_and_memory(eb, memory, "cross page non-overlapping memcpy 2"); in test_eb_mem_ops()
791 memmove(memory + 4096 - 128, memory + 4096 - 64, 256); in test_eb_mem_ops()
792 memmove_extent_buffer(eb, 4096 - 128, 4096 - 64, 256); in test_eb_mem_ops()
793 ret = verify_eb_and_memory(eb, memory, "cross page overlapping memcpy 1"); in test_eb_mem_ops()
797 memmove(memory + 4096 - 64, memory + 4096 - 128, 256); in test_eb_mem_ops()
798 memmove_extent_buffer(eb, 4096 - 64, 4096 - 128, 256); in test_eb_mem_ops()
799 ret = verify_eb_and_memory(eb, memory, "cross page overlapping memcpy 2"); in test_eb_mem_ops()