fs/btrfs/tests/raid-stripe-tree-tests.c

Source file repositories/reference/linux-study-clean/fs/btrfs/tests/raid-stripe-tree-tests.c

File Facts

System
Linux kernel
Corpus path
fs/btrfs/tests/raid-stripe-tree-tests.c
Extension
.c
Size
29013 bytes
Lines
1162
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!stripe->dev) {
			test_err("cannot find device with devid %d", i);
			ret = -EINVAL;
			goto out;
		}

		stripe->physical = logical1 + i * SZ_1G;
	}

	ret = btrfs_insert_one_raid_extent(trans, bioc);
	if (ret) {
		test_err("inserting RAID extent failed: %d", ret);
		goto out;
	}

	bioc->logical = logical2;
	bioc->size = len2;
	for (int i = 0; i < RST_TEST_NUM_DEVICES; i++) {
		struct btrfs_io_stripe *stripe = &bioc->stripes[i];

		stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i);
		if (!stripe->dev) {
			test_err("cannot find device with devid %d", i);
			ret = -EINVAL;
			goto out;
		}

		stripe->physical = logical2 + i * SZ_1G;
	}

	ret = btrfs_insert_one_raid_extent(trans, bioc);
	if (ret) {
		test_err("inserting RAID extent failed: %d", ret);
		goto out;
	}

	bioc->logical = logical3;
	bioc->size = len3;
	for (int i = 0; i < RST_TEST_NUM_DEVICES; i++) {
		struct btrfs_io_stripe *stripe = &bioc->stripes[i];

		stripe->dev = btrfs_device_by_devid(fs_info->fs_devices, i);
		if (!stripe->dev) {
			test_err("cannot find device with devid %d", i);
			ret = -EINVAL;
			goto out;
		}

		stripe->physical = logical3 + i * SZ_1G;
	}

	ret = btrfs_insert_one_raid_extent(trans, bioc);
	if (ret) {
		test_err("inserting RAID extent failed: %d", ret);
		goto out;
	}

	/*
	 * Delete a range starting at logical1 + 256K and 2M in length. Extent
	 * 1 is truncated to 256k length, extent 2 is completely dropped and
	 * extent 3 is moved 256K to the right.
	 */
	ret = btrfs_delete_raid_extent(trans, hole_start, hole_len);
	if (ret) {
		test_err("deleting RAID extent [%llu, %llu] failed",
			 hole_start, hole_start + hole_len);
		goto out;
	}

	/* Get the first extent and check its size. */
	ret = btrfs_get_raid_extent_offset(fs_info, logical1, &len1, map_type,
					   0, &io_stripe);
	if (ret) {
		test_err("lookup of RAID extent [%llu, %llu] failed",
			 logical1, logical1 + len1);
		goto out;
	}

	if (io_stripe.physical != logical1) {
		test_err("invalid physical address, expected %llu, got %llu",
			 logical1, io_stripe.physical);
		ret = -EINVAL;
		goto out;
	}

	if (len1 != SZ_256K) {
		test_err("invalid stripe length, expected %llu, got %llu",
			 (u64)SZ_256K, len1);
		ret = -EINVAL;
		goto out;

Annotation

Implementation Notes