Lines Matching +full:out +full:-
1 // SPDX-License-Identifier: GPL-2.0
8 #include "../disk-io.h"
11 #include "../raid-stripe-tree.h"
12 #include "btrfs-tests.h"
26 list_for_each_entry(dev, &fs_devices->devices, dev_list) { in btrfs_device_by_devid()
27 if (dev->devid == devid) in btrfs_device_by_devid()
40 struct btrfs_fs_info *fs_info = trans->fs_info; in test_punch_hole_3extents()
57 ret = -ENOMEM; in test_punch_hole_3extents()
58 goto out; in test_punch_hole_3extents()
61 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_punch_hole_3extents()
64 bioc->map_type = map_type; in test_punch_hole_3extents()
65 bioc->size = len1; in test_punch_hole_3extents()
68 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_punch_hole_3extents()
70 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_punch_hole_3extents()
71 if (!stripe->dev) { in test_punch_hole_3extents()
73 ret = -EINVAL; in test_punch_hole_3extents()
74 goto out; in test_punch_hole_3extents()
77 stripe->physical = logical1 + i * SZ_1G; in test_punch_hole_3extents()
83 goto out; in test_punch_hole_3extents()
86 bioc->logical = logical2; in test_punch_hole_3extents()
87 bioc->size = len2; in test_punch_hole_3extents()
89 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_punch_hole_3extents()
91 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_punch_hole_3extents()
92 if (!stripe->dev) { in test_punch_hole_3extents()
94 ret = -EINVAL; in test_punch_hole_3extents()
95 goto out; in test_punch_hole_3extents()
98 stripe->physical = logical2 + i * SZ_1G; in test_punch_hole_3extents()
104 goto out; in test_punch_hole_3extents()
107 bioc->logical = logical3; in test_punch_hole_3extents()
108 bioc->size = len3; in test_punch_hole_3extents()
110 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_punch_hole_3extents()
112 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_punch_hole_3extents()
113 if (!stripe->dev) { in test_punch_hole_3extents()
115 ret = -EINVAL; in test_punch_hole_3extents()
116 goto out; in test_punch_hole_3extents()
119 stripe->physical = logical3 + i * SZ_1G; in test_punch_hole_3extents()
125 goto out; in test_punch_hole_3extents()
137 goto out; in test_punch_hole_3extents()
146 goto out; in test_punch_hole_3extents()
152 ret = -EINVAL; in test_punch_hole_3extents()
153 goto out; in test_punch_hole_3extents()
159 ret = -EINVAL; in test_punch_hole_3extents()
160 goto out; in test_punch_hole_3extents()
166 if (ret != -ENODATA) { in test_punch_hole_3extents()
169 ret = -EINVAL; in test_punch_hole_3extents()
170 goto out; in test_punch_hole_3extents()
180 goto out; in test_punch_hole_3extents()
186 ret = -EINVAL; in test_punch_hole_3extents()
187 goto out; in test_punch_hole_3extents()
190 if (len3 != SZ_1M - SZ_256K) { in test_punch_hole_3extents()
192 (u64)SZ_1M - SZ_256K, len3); in test_punch_hole_3extents()
193 ret = -EINVAL; in test_punch_hole_3extents()
194 goto out; in test_punch_hole_3extents()
201 goto out; in test_punch_hole_3extents()
208 goto out; in test_punch_hole_3extents()
211 out: in test_punch_hole_3extents()
218 struct btrfs_fs_info *fs_info = trans->fs_info; in test_delete_two_extents()
233 ret = -ENOMEM; in test_delete_two_extents()
234 goto out; in test_delete_two_extents()
237 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_delete_two_extents()
240 bioc->map_type = map_type; in test_delete_two_extents()
241 bioc->size = len1; in test_delete_two_extents()
244 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_delete_two_extents()
246 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_delete_two_extents()
247 if (!stripe->dev) { in test_delete_two_extents()
249 ret = -EINVAL; in test_delete_two_extents()
250 goto out; in test_delete_two_extents()
253 stripe->physical = logical1 + i * SZ_1G; in test_delete_two_extents()
259 goto out; in test_delete_two_extents()
262 bioc->logical = logical2; in test_delete_two_extents()
263 bioc->size = len2; in test_delete_two_extents()
265 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_delete_two_extents()
267 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_delete_two_extents()
268 if (!stripe->dev) { in test_delete_two_extents()
270 ret = -EINVAL; in test_delete_two_extents()
271 goto out; in test_delete_two_extents()
274 stripe->physical = logical2 + i * SZ_1G; in test_delete_two_extents()
280 goto out; in test_delete_two_extents()
283 bioc->logical = logical3; in test_delete_two_extents()
284 bioc->size = len3; in test_delete_two_extents()
286 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_delete_two_extents()
288 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_delete_two_extents()
289 if (!stripe->dev) { in test_delete_two_extents()
291 ret = -EINVAL; in test_delete_two_extents()
292 goto out; in test_delete_two_extents()
295 stripe->physical = logical3 + i * SZ_1G; in test_delete_two_extents()
301 goto out; in test_delete_two_extents()
312 goto out; in test_delete_two_extents()
317 if (ret != -ENODATA) { in test_delete_two_extents()
320 goto out; in test_delete_two_extents()
325 if (ret != -ENODATA) { in test_delete_two_extents()
328 goto out; in test_delete_two_extents()
336 goto out; in test_delete_two_extents()
342 ret = -EINVAL; in test_delete_two_extents()
343 goto out; in test_delete_two_extents()
349 ret = -EINVAL; in test_delete_two_extents()
350 goto out; in test_delete_two_extents()
354 out: in test_delete_two_extents()
359 /* Test punching a hole into a single RAID stripe-extent. */
362 struct btrfs_fs_info *fs_info = trans->fs_info; in test_punch_hole()
372 u64 len2 = len - len1 - hole_len; in test_punch_hole()
378 ret = -ENOMEM; in test_punch_hole()
379 goto out; in test_punch_hole()
382 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_punch_hole()
383 bioc->map_type = map_type; in test_punch_hole()
384 bioc->size = len; in test_punch_hole()
387 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_punch_hole()
389 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_punch_hole()
390 if (!stripe->dev) { in test_punch_hole()
392 ret = -EINVAL; in test_punch_hole()
393 goto out; in test_punch_hole()
396 stripe->physical = logical1 + i * SZ_1G; in test_punch_hole()
402 goto out; in test_punch_hole()
410 goto out; in test_punch_hole()
416 ret = -EINVAL; in test_punch_hole()
417 goto out; in test_punch_hole()
423 ret = -EINVAL; in test_punch_hole()
424 goto out; in test_punch_hole()
431 goto out; in test_punch_hole()
439 goto out; in test_punch_hole()
445 ret = -EINVAL; in test_punch_hole()
446 goto out; in test_punch_hole()
452 ret = -EINVAL; in test_punch_hole()
453 goto out; in test_punch_hole()
461 goto out; in test_punch_hole()
467 ret = -EINVAL; in test_punch_hole()
468 goto out; in test_punch_hole()
471 if (len2 != len - len1 - hole_len) { in test_punch_hole()
473 len - len1 - hole_len, len2); in test_punch_hole()
474 ret = -EINVAL; in test_punch_hole()
475 goto out; in test_punch_hole()
481 if (ret != -ENODATA) { in test_punch_hole()
482 ret = -EINVAL; in test_punch_hole()
485 goto out; in test_punch_hole()
490 goto out; in test_punch_hole()
493 out: in test_punch_hole()
505 struct btrfs_fs_info *fs_info = trans->fs_info; in test_front_delete_prev_item()
517 ret = -ENOMEM; in test_front_delete_prev_item()
518 goto out; in test_front_delete_prev_item()
521 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_front_delete_prev_item()
522 bioc->map_type = map_type; in test_front_delete_prev_item()
523 bioc->size = len; in test_front_delete_prev_item()
527 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_front_delete_prev_item()
529 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_front_delete_prev_item()
530 if (!stripe->dev) { in test_front_delete_prev_item()
532 ret = -EINVAL; in test_front_delete_prev_item()
533 goto out; in test_front_delete_prev_item()
536 stripe->physical = logical1 + i * SZ_1G; in test_front_delete_prev_item()
542 goto out; in test_front_delete_prev_item()
545 bioc->logical = logical2; in test_front_delete_prev_item()
548 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_front_delete_prev_item()
550 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_front_delete_prev_item()
551 if (!stripe->dev) { in test_front_delete_prev_item()
553 ret = -EINVAL; in test_front_delete_prev_item()
554 goto out; in test_front_delete_prev_item()
557 stripe->physical = logical2 + i * SZ_1G; in test_front_delete_prev_item()
563 goto out; in test_front_delete_prev_item()
570 goto out; in test_front_delete_prev_item()
579 goto out; in test_front_delete_prev_item()
585 ret = -EINVAL; in test_front_delete_prev_item()
586 goto out; in test_front_delete_prev_item()
592 ret = -EINVAL; in test_front_delete_prev_item()
593 goto out; in test_front_delete_prev_item()
602 goto out; in test_front_delete_prev_item()
608 ret = -EINVAL; in test_front_delete_prev_item()
609 goto out; in test_front_delete_prev_item()
615 ret = -EINVAL; in test_front_delete_prev_item()
616 goto out; in test_front_delete_prev_item()
623 if (ret != -ENODATA) { in test_front_delete_prev_item()
626 goto out; in test_front_delete_prev_item()
632 goto out; in test_front_delete_prev_item()
636 out: in test_front_delete_prev_item()
647 struct btrfs_fs_info *fs_info = trans->fs_info; in test_front_delete()
658 ret = -ENOMEM; in test_front_delete()
659 goto out; in test_front_delete()
662 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_front_delete()
663 bioc->map_type = map_type; in test_front_delete()
664 bioc->size = len; in test_front_delete()
667 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_front_delete()
669 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_front_delete()
670 if (!stripe->dev) { in test_front_delete()
672 ret = -EINVAL; in test_front_delete()
673 goto out; in test_front_delete()
676 stripe->physical = logical + i * SZ_1G; in test_front_delete()
682 goto out; in test_front_delete()
689 goto out; in test_front_delete()
695 ret = -EINVAL; in test_front_delete()
696 goto out; in test_front_delete()
702 ret = -EINVAL; in test_front_delete()
703 goto out; in test_front_delete()
710 goto out; in test_front_delete()
713 len -= SZ_16K; in test_front_delete()
719 goto out; in test_front_delete()
725 ret = -EINVAL; in test_front_delete()
726 goto out; in test_front_delete()
732 ret = -EINVAL; in test_front_delete()
733 goto out; in test_front_delete()
737 if (ret != -ENODATA) { in test_front_delete()
738 ret = -EINVAL; in test_front_delete()
741 goto out; in test_front_delete()
745 out: in test_front_delete()
756 struct btrfs_fs_info *fs_info = trans->fs_info; in test_tail_delete()
767 ret = -ENOMEM; in test_tail_delete()
768 goto out; in test_tail_delete()
771 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_tail_delete()
772 bioc->map_type = map_type; in test_tail_delete()
773 bioc->size = len; in test_tail_delete()
776 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_tail_delete()
778 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_tail_delete()
779 if (!stripe->dev) { in test_tail_delete()
781 ret = -EINVAL; in test_tail_delete()
782 goto out; in test_tail_delete()
785 stripe->physical = logical + i * SZ_1G; in test_tail_delete()
791 goto out; in test_tail_delete()
794 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_tail_delete()
796 ret = -EINVAL; in test_tail_delete()
797 goto out; in test_tail_delete()
804 goto out; in test_tail_delete()
810 ret = -EINVAL; in test_tail_delete()
811 goto out; in test_tail_delete()
817 ret = -EINVAL; in test_tail_delete()
818 goto out; in test_tail_delete()
825 goto out; in test_tail_delete()
833 goto out; in test_tail_delete()
839 ret = -EINVAL; in test_tail_delete()
840 goto out; in test_tail_delete()
846 ret = -EINVAL; in test_tail_delete()
847 goto out; in test_tail_delete()
853 if (ret != -ENODATA) { in test_tail_delete()
856 ret = -EINVAL; in test_tail_delete()
857 goto out; in test_tail_delete()
865 out: in test_tail_delete()
878 struct btrfs_fs_info *fs_info = trans->fs_info; in test_create_update_delete()
889 ret = -ENOMEM; in test_create_update_delete()
890 goto out; in test_create_update_delete()
893 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_create_update_delete()
894 bioc->map_type = map_type; in test_create_update_delete()
895 bioc->size = len; in test_create_update_delete()
898 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_create_update_delete()
900 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_create_update_delete()
901 if (!stripe->dev) { in test_create_update_delete()
903 ret = -EINVAL; in test_create_update_delete()
904 goto out; in test_create_update_delete()
907 stripe->physical = logical + i * SZ_1G; in test_create_update_delete()
913 goto out; in test_create_update_delete()
916 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_create_update_delete()
918 ret = -EINVAL; in test_create_update_delete()
919 goto out; in test_create_update_delete()
926 goto out; in test_create_update_delete()
932 ret = -EINVAL; in test_create_update_delete()
933 goto out; in test_create_update_delete()
939 ret = -EINVAL; in test_create_update_delete()
940 goto out; in test_create_update_delete()
944 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_create_update_delete()
946 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_create_update_delete()
947 if (!stripe->dev) { in test_create_update_delete()
949 ret = -EINVAL; in test_create_update_delete()
950 goto out; in test_create_update_delete()
953 stripe->physical = SZ_1G + logical + i * SZ_1G; in test_create_update_delete()
959 goto out; in test_create_update_delete()
966 goto out; in test_create_update_delete()
972 ret = -EINVAL; in test_create_update_delete()
973 goto out; in test_create_update_delete()
979 ret = -EINVAL; in test_create_update_delete()
980 goto out; in test_create_update_delete()
988 out: in test_create_update_delete()
999 struct btrfs_fs_info *fs_info = trans->fs_info; in test_simple_create_delete()
1010 ret = -ENOMEM; in test_simple_create_delete()
1011 goto out; in test_simple_create_delete()
1014 bioc->map_type = map_type; in test_simple_create_delete()
1015 bioc->size = SZ_64K; in test_simple_create_delete()
1018 struct btrfs_io_stripe *stripe = &bioc->stripes[i]; in test_simple_create_delete()
1020 stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i); in test_simple_create_delete()
1021 if (!stripe->dev) { in test_simple_create_delete()
1023 ret = -EINVAL; in test_simple_create_delete()
1024 goto out; in test_simple_create_delete()
1027 stripe->physical = logical + i * SZ_1G; in test_simple_create_delete()
1033 goto out; in test_simple_create_delete()
1036 io_stripe.dev = btrfs_device_by_devid(fs_info->fs_devices, 0); in test_simple_create_delete()
1038 ret = -EINVAL; in test_simple_create_delete()
1039 goto out; in test_simple_create_delete()
1046 goto out; in test_simple_create_delete()
1052 ret = -EINVAL; in test_simple_create_delete()
1053 goto out; in test_simple_create_delete()
1059 ret = -EINVAL; in test_simple_create_delete()
1060 goto out; in test_simple_create_delete()
1068 out: in test_simple_create_delete()
1094 ret = -ENOMEM; in run_test()
1095 goto out; in run_test()
1102 goto out; in run_test()
1104 btrfs_set_super_incompat_flags(root->fs_info->super_copy, in run_test()
1106 root->root_key.objectid = BTRFS_RAID_STRIPE_TREE_OBJECTID; in run_test()
1107 root->root_key.type = BTRFS_ROOT_ITEM_KEY; in run_test()
1108 root->root_key.offset = 0; in run_test()
1109 fs_info->stripe_root = root; in run_test()
1110 root->fs_info->tree_root = root; in run_test()
1112 root->node = alloc_test_extent_buffer(root->fs_info, nodesize); in run_test()
1113 if (IS_ERR(root->node)) { in run_test()
1115 ret = PTR_ERR(root->node); in run_test()
1116 goto out; in run_test()
1118 btrfs_set_header_level(root->node, 0); in run_test()
1119 btrfs_set_header_nritems(root->node, 0); in run_test()
1120 root->alloc_bytenr += 2 * nodesize; in run_test()
1129 goto out; in run_test()
1131 dev->devid = i; in run_test()
1134 btrfs_init_dummy_trans(&trans, root->fs_info); in run_test()
1137 goto out; in run_test()
1139 out: in run_test()
1150 test_msg("running raid-stripe-tree tests"); in btrfs_test_raid_stripe_tree()
1154 test_err("test-case %ps failed with %d\n", tests[i], ret); in btrfs_test_raid_stripe_tree()
1155 goto out; in btrfs_test_raid_stripe_tree()
1159 out: in btrfs_test_raid_stripe_tree()