if (btrfs_item_size(eb, 0) != strlen(split1)) {
test_err("invalid len in the first split");
ret = -EINVAL; goto out;
}
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 0),
strlen(split1)); if (memcmp(buf, split1, strlen(split1))) {
test_err( "data in the buffer doesn't match what it should in the first split have='%.*s' want '%s'",
(int)strlen(split1), buf, split1);
ret = -EINVAL; goto out;
}
btrfs_item_key_to_cpu(eb, &key, 1); if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 3) {
test_err("invalid key at slot 1");
ret = -EINVAL; goto out;
}
if (btrfs_item_size(eb, 1) != strlen(split2)) {
test_err("invalid len in the second split");
ret = -EINVAL; goto out;
}
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 1),
strlen(split2)); if (memcmp(buf, split2, strlen(split2))) {
test_err( "data in the buffer doesn't match what it should in the second split");
ret = -EINVAL; goto out;
}
key.offset = 1; /* Do it again so we test memmoving the other items in the leaf */
ret = btrfs_split_item(NULL, root, path, &key, 4); if (ret) {
test_err("second split item failed %d", ret); goto out;
}
btrfs_item_key_to_cpu(eb, &key, 0); if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 0) {
test_err("invalid key at slot 0");
ret = -EINVAL; goto out;
}
if (btrfs_item_size(eb, 0) != strlen(split3)) {
test_err("invalid len in the first split");
ret = -EINVAL; goto out;
}
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 0),
strlen(split3)); if (memcmp(buf, split3, strlen(split3))) {
test_err( "data in the buffer doesn't match what it should in the third split");
ret = -EINVAL; goto out;
}
btrfs_item_key_to_cpu(eb, &key, 1); if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 1) {
test_err("invalid key at slot 1");
ret = -EINVAL; goto out;
}
if (btrfs_item_size(eb, 1) != strlen(split4)) {
test_err("invalid len in the second split");
ret = -EINVAL; goto out;
}
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 1),
strlen(split4)); if (memcmp(buf, split4, strlen(split4))) {
test_err( "data in the buffer doesn't match what it should in the fourth split");
ret = -EINVAL; goto out;
}
btrfs_item_key_to_cpu(eb, &key, 2); if (key.objectid != 0 || key.type != BTRFS_EXTENT_CSUM_KEY ||
key.offset != 3) {
test_err("invalid key at slot 2");
ret = -EINVAL; goto out;
}
if (btrfs_item_size(eb, 2) != strlen(split2)) {
test_err("invalid len in the second split");
ret = -EINVAL; goto out;
}
read_extent_buffer(eb, buf, btrfs_item_ptr_offset(eb, 2),
strlen(split2)); if (memcmp(buf, split2, strlen(split2))) {
test_err( "data in the buffer doesn't match what it should in the last chunk");
ret = -EINVAL; goto out;
}
out:
btrfs_free_path(path);
btrfs_free_dummy_root(root);
btrfs_free_dummy_fs_info(fs_info); return ret;
}